Added message ttl setting storage

pull/131/head
Mikunj 6 years ago
parent 61c4447ab0
commit 87113b6cc1

@ -221,6 +221,10 @@
}
first = false;
// The min and max message ttl value
const MIN_MESSAGE_TTL = 12;
const MAX_MESSAGE_TTL = 96;
// These make key operations available to IPC handlers created in preload.js
window.Events = {
getDeviceName: () => textsecure.storage.user.getDeviceName(),
@ -237,6 +241,18 @@
window.setMenuBarVisibility(!value);
},
getMessageTTL: () => {
// Make sure the ttl is between a given range
const current = storage.get('message-ttl', 24);
return Math.max(MIN_MESSAGE_TTL, Math.min(current, MAX_MESSAGE_TTL));
},
setMessageTTL: value => {
// Make sure the ttl is between a given range and is valid
const ttl = (typeof value !== 'number') ? 24 : value;
const current = Math.max(MIN_MESSAGE_TTL, Math.min(ttl, MAX_MESSAGE_TTL));
storage.put('message-ttl', current);
},
getReadReceiptSetting: () =>
storage.get('read-receipt-setting'),
setReadReceiptSetting: value =>

@ -18,6 +18,7 @@ const getInitialData = async () => ({
themeSetting: await window.getThemeSetting(),
hideMenuBar: await window.getHideMenuBar(),
messageTTL: await window.getMessageTTL(),
readReceiptSetting: await window.getReadReceiptSetting(),
notificationSetting: await window.getNotificationSetting(),
audioNotification: await window.getAudioNotification(),

@ -1053,6 +1053,9 @@ installSettingsSetter('theme-setting');
installSettingsGetter('hide-menu-bar');
installSettingsSetter('hide-menu-bar');
installSettingsGetter('message-ttl');
installSettingsSetter('message-ttl');
installSettingsGetter('read-receipt-setting');
installSettingsSetter('read-receipt-setting');
installSettingsGetter('notification-setting');

@ -154,6 +154,16 @@ installSetter('theme-setting', 'setThemeSetting');
installGetter('hide-menu-bar', 'getHideMenuBar');
installSetter('hide-menu-bar', 'setHideMenuBar');
// Get the message TTL setting
window.getMessageTTL = () => {
if (window.Events.getMessageTTL) {
return window.Events.getMessageTTL();
}
return null;
}
installGetter('message-ttl', 'getMessageTTL');
installSetter('message-ttl', 'setMessageTTL');
installGetter('read-receipt-setting', 'getReadReceiptSetting');
installSetter('read-receipt-setting', 'setReadReceiptSetting');
installGetter('notification-setting', 'getNotificationSetting');

@ -41,6 +41,9 @@ window.setHideMenuBar = makeSetter('hide-menu-bar');
window.getSpellCheck = makeGetter('spell-check');
window.setSpellCheck = makeSetter('spell-check');
window.getMessageTTL = makeGetter('message-ttl');
window.setMessageTTL = makeSetter('message-ttl');
window.getReadReceiptSetting = makeGetter('read-receipt-setting');
window.setReadReceiptSetting = makeSetter('read-receipt-setting');
window.getNotificationSetting = makeGetter('notification-setting');

Loading…
Cancel
Save