mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
Improve SettingsUserStore handling
This commit is contained in:
parent
ce74b2e92f
commit
97d5f8762d
8 changed files with 49 additions and 96 deletions
|
|
@ -84,7 +84,6 @@ export class GeneralUserSettings {
|
|||
];
|
||||
});
|
||||
|
||||
|
||||
const fReloadLanguageHelper = (saveSettingsStep) => () => {
|
||||
this.languageTrigger(saveSettingsStep);
|
||||
setTimeout(() => this.languageTrigger(SaveSettingsStep.Idle), 1000);
|
||||
|
|
@ -93,56 +92,39 @@ export class GeneralUserSettings {
|
|||
language: value => {
|
||||
this.languageTrigger(SaveSettingsStep.Animate);
|
||||
translatorReload(false, value)
|
||||
.then(fReloadLanguageHelper(SaveSettingsStep.TrueResult), fReloadLanguageHelper(SaveSettingsStep.FalseResult))
|
||||
.then(() => {
|
||||
Remote.saveSettings(null, {
|
||||
'Language': value
|
||||
});
|
||||
});
|
||||
.then(fReloadLanguageHelper(SaveSettingsStep.TrueResult),
|
||||
fReloadLanguageHelper(SaveSettingsStep.FalseResult))
|
||||
.then(() => Remote.saveSetting('Language', value));
|
||||
},
|
||||
|
||||
editorDefaultType:
|
||||
Remote.saveSettingsHelper('EditorDefaultType', null,
|
||||
settingsSaveHelperSimpleFunction(this.editorDefaultTypeTrigger, this)),
|
||||
editorDefaultType: value => Remote.saveSetting('EditorDefaultType', value,
|
||||
settingsSaveHelperSimpleFunction(this.editorDefaultTypeTrigger, this)),
|
||||
|
||||
messagesPerPage: Remote.saveSettingsHelper('MPP', null, settingsSaveHelperSimpleFunction(this.mppTrigger, this)),
|
||||
messagesPerPage: value => Remote.saveSetting('MPP', value,
|
||||
settingsSaveHelperSimpleFunction(this.mppTrigger, this)),
|
||||
|
||||
showImages: Remote.saveSettingsHelper('ShowImages', v=>v?'1':'0'),
|
||||
showImages: value => Remote.saveSetting('ShowImages', value ? 1 : 0),
|
||||
|
||||
removeColors: Remote.saveSettingsHelper('RemoveColors', v=>v?'1':'0'),
|
||||
removeColors: value => {
|
||||
Remote.saveSetting('RemoveColors', value ? 1 : 0);
|
||||
},
|
||||
|
||||
useCheckboxesInList: Remote.saveSettingsHelper('UseCheckboxesInList', v=>v?'1':'0'),
|
||||
useCheckboxesInList: value => Remote.saveSetting('UseCheckboxesInList', value ? 1 : 0),
|
||||
|
||||
enableDesktopNotification: (value =>
|
||||
Remote.saveSettings(null, {
|
||||
'DesktopNotifications': value ? 1 : 0
|
||||
})
|
||||
).debounce(3000),
|
||||
enableDesktopNotification: value => Remote.saveSetting('DesktopNotifications', value ? 1 : 0),
|
||||
|
||||
enableSoundNotification: (value =>
|
||||
Remote.saveSettings(null, {
|
||||
'SoundNotification': value ? 1 : 0
|
||||
})
|
||||
).debounce(3000),
|
||||
enableSoundNotification: value => Remote.saveSetting('SoundNotification', value ? 1 : 0),
|
||||
|
||||
replySameFolder: (value =>
|
||||
Remote.saveSettings(null, {
|
||||
'ReplySameFolder': value ? 1 : 0
|
||||
})
|
||||
).debounce(3000),
|
||||
replySameFolder: value => Remote.saveSetting('ReplySameFolder', value ? 1 : 0),
|
||||
|
||||
useThreads: value => {
|
||||
MessageUserStore.list([]);
|
||||
Remote.saveSettings(null, {
|
||||
'UseThreads': value ? 1 : 0
|
||||
});
|
||||
Remote.saveSetting('UseThreads', value ? 1 : 0);
|
||||
},
|
||||
|
||||
layout: value => {
|
||||
MessageUserStore.list([]);
|
||||
Remote.saveSettings(settingsSaveHelperSimpleFunction(this.layoutTrigger, this), {
|
||||
'Layout': value
|
||||
});
|
||||
Remote.saveSetting('Layout', value, settingsSaveHelperSimpleFunction(this.layoutTrigger, this));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ export class OpenPgpUserSettings {
|
|||
this.openPgpKeyForDeletion = ko.observable(null).deleteAccessHelper();
|
||||
|
||||
this.allowDraftAutosave = SettingsUserStore.allowDraftAutosave;
|
||||
|
||||
this.allowDraftAutosave.subscribe(value => Remote.saveSetting('AllowDraftAutosave', value ? 1 : 0))
|
||||
}
|
||||
|
||||
addOpenPgpKey() {
|
||||
|
|
@ -61,10 +63,4 @@ export class OpenPgpUserSettings {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
setTimeout(() => {
|
||||
this.allowDraftAutosave.subscribe(Remote.saveSettingsHelper('AllowDraftAutosave', v=>v?'1':'0'));
|
||||
}, 50);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export class SecurityUserSettings {
|
|||
this.capaTwoFactor = Settings.capa(Capa.TwoFactor);
|
||||
|
||||
this.autoLogout = SettingsUserStore.autoLogout;
|
||||
this.autoLogout.trigger = ko.observable(SaveSettingsStep.Idle);
|
||||
this.autoLogoutTrigger = ko.observable(SaveSettingsStep.Idle);
|
||||
|
||||
let i18nLogout = (key, params) => i18n('SETTINGS_SECURITY/AUTOLOGIN_' + key, params);
|
||||
this.autoLogoutOptions = ko.computed(() => {
|
||||
|
|
@ -35,20 +35,16 @@ export class SecurityUserSettings {
|
|||
{ 'id': 60 * 10, 'name': i18nLogout('HOURS_OPTION_NAME', { 'HOURS': 10 }) }
|
||||
];
|
||||
});
|
||||
|
||||
if (this.capaAutoLogout) {
|
||||
this.autoLogout.subscribe(value => Remote.saveSetting(
|
||||
'AutoLogout', pInt(value),
|
||||
settingsSaveHelperSimpleFunction(this.autoLogoutTrigger, this)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
configureTwoFactor() {
|
||||
showScreenPopup(TwoFactorConfigurationPopupView);
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
if (this.capaAutoLogout) {
|
||||
setTimeout(() =>
|
||||
this.autoLogout.subscribe(Remote.saveSettingsHelper(
|
||||
'AutoLogout', pInt,
|
||||
settingsSaveHelperSimpleFunction(this.autoLogout.trigger, this)
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue