2016-08-17 06:01:20 +08:00
|
|
|
import ko from 'ko';
|
2021-12-31 20:30:05 +08:00
|
|
|
import { koComputable } from 'External/ko';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2022-09-26 17:55:26 +08:00
|
|
|
import { Layout } from 'Common/EnumsUser';
|
2022-02-17 16:36:29 +08:00
|
|
|
import { pInt } from 'Common/Utils';
|
|
|
|
import { addObservablesTo } from 'External/ko';
|
2022-10-28 05:52:33 +08:00
|
|
|
import { $htmlCL, SettingsGet, fireEvent } from 'Common/Globals';
|
2021-02-17 03:12:23 +08:00
|
|
|
import { ThemeStore } from 'Stores/Theme';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
export const SettingsUserStore = new class {
|
2016-08-17 06:01:20 +08:00
|
|
|
constructor() {
|
2021-11-19 19:44:53 +08:00
|
|
|
const self = this;
|
|
|
|
|
|
|
|
self.messagesPerPage = ko.observable(25).extend({ debounce: 999 });
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2021-11-19 19:44:53 +08:00
|
|
|
self.messageReadDelay = ko.observable(5).extend({ debounce: 999 });
|
2021-09-02 20:21:50 +08:00
|
|
|
|
2021-11-19 19:44:53 +08:00
|
|
|
addObservablesTo(self, {
|
2022-01-14 21:05:33 +08:00
|
|
|
viewHTML: 1,
|
2021-11-19 19:44:53 +08:00
|
|
|
showImages: 0,
|
|
|
|
removeColors: 0,
|
2022-10-04 02:15:12 +08:00
|
|
|
listInlineAttachments: 0,
|
2021-11-19 19:44:53 +08:00
|
|
|
useCheckboxesInList: 1,
|
|
|
|
allowDraftAutosave: 1,
|
|
|
|
useThreads: 0,
|
|
|
|
replySameFolder: 0,
|
2022-01-12 18:55:41 +08:00
|
|
|
hideUnsubscribed: 0,
|
2022-08-02 20:20:07 +08:00
|
|
|
hideDeleted: 1,
|
2022-09-27 15:46:49 +08:00
|
|
|
unhideKolabFolders: 0,
|
2022-08-09 21:34:55 +08:00
|
|
|
autoLogout: 0,
|
|
|
|
|
|
|
|
requestReadReceipt: 0,
|
|
|
|
requestDsn: 0,
|
|
|
|
pgpSign: 0,
|
2022-09-26 17:55:26 +08:00
|
|
|
pgpEncrypt: 0,
|
|
|
|
|
|
|
|
layout: 1,
|
|
|
|
editorDefaultType: 'Html',
|
|
|
|
msgDefaultAction: 1
|
2020-10-27 18:09:24 +08:00
|
|
|
});
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2021-11-19 19:44:53 +08:00
|
|
|
self.init();
|
|
|
|
|
2021-12-31 20:30:05 +08:00
|
|
|
self.usePreviewPane = koComputable(() => Layout.NoPreview !== self.layout() && !ThemeStore.isMobile());
|
2020-09-24 21:08:57 +08:00
|
|
|
|
2021-03-19 17:09:30 +08:00
|
|
|
const toggleLayout = () => {
|
2021-11-19 19:44:53 +08:00
|
|
|
const value = ThemeStore.isMobile() ? Layout.NoPreview : self.layout();
|
2021-03-11 05:41:35 +08:00
|
|
|
$htmlCL.toggle('rl-no-preview-pane', Layout.NoPreview === value);
|
|
|
|
$htmlCL.toggle('rl-side-preview-pane', Layout.SidePreview === value);
|
|
|
|
$htmlCL.toggle('rl-bottom-preview-pane', Layout.BottomPreview === value);
|
2022-02-11 19:21:16 +08:00
|
|
|
fireEvent('rl-layout', value);
|
2021-03-19 17:09:30 +08:00
|
|
|
};
|
2021-11-19 19:44:53 +08:00
|
|
|
self.layout.subscribe(toggleLayout);
|
2021-03-19 17:09:30 +08:00
|
|
|
ThemeStore.isMobile.subscribe(toggleLayout);
|
|
|
|
toggleLayout();
|
2021-03-03 00:39:02 +08:00
|
|
|
|
|
|
|
let iAutoLogoutTimer;
|
2021-11-19 19:44:53 +08:00
|
|
|
self.delayLogout = (() => {
|
2021-03-03 00:39:02 +08:00
|
|
|
clearTimeout(iAutoLogoutTimer);
|
2022-10-27 22:05:28 +08:00
|
|
|
if (0 < self.autoLogout() && !SettingsGet('AccountSignMe')) {
|
2021-03-03 00:39:02 +08:00
|
|
|
iAutoLogoutTimer = setTimeout(
|
|
|
|
rl.app.logout,
|
2021-11-19 19:44:53 +08:00
|
|
|
self.autoLogout() * 60000
|
2021-03-03 00:39:02 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}).throttle(5000);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2021-11-19 19:44:53 +08:00
|
|
|
|
|
|
|
init() {
|
|
|
|
const self = this;
|
|
|
|
self.editorDefaultType(SettingsGet('EditorDefaultType'));
|
|
|
|
|
|
|
|
self.layout(pInt(SettingsGet('Layout')));
|
|
|
|
self.messagesPerPage(pInt(SettingsGet('MessagesPerPage')));
|
|
|
|
self.messageReadDelay(pInt(SettingsGet('MessageReadDelay')));
|
|
|
|
self.autoLogout(pInt(SettingsGet('AutoLogout')));
|
2022-08-31 23:31:08 +08:00
|
|
|
self.msgDefaultAction(SettingsGet('MsgDefaultAction'));
|
2021-11-19 19:44:53 +08:00
|
|
|
|
2022-01-14 21:05:33 +08:00
|
|
|
self.viewHTML(SettingsGet('ViewHTML'));
|
2022-01-12 18:55:41 +08:00
|
|
|
self.showImages(SettingsGet('ShowImages'));
|
|
|
|
self.removeColors(SettingsGet('RemoveColors'));
|
2022-10-04 02:15:12 +08:00
|
|
|
self.listInlineAttachments(SettingsGet('ListInlineAttachments'));
|
2022-01-12 18:55:41 +08:00
|
|
|
self.useCheckboxesInList(SettingsGet('UseCheckboxesInList'));
|
|
|
|
self.allowDraftAutosave(SettingsGet('AllowDraftAutosave'));
|
|
|
|
self.useThreads(SettingsGet('UseThreads'));
|
|
|
|
self.replySameFolder(SettingsGet('ReplySameFolder'));
|
2021-11-19 19:44:53 +08:00
|
|
|
|
2022-01-12 18:55:41 +08:00
|
|
|
self.hideUnsubscribed(SettingsGet('HideUnsubscribed'));
|
2022-08-02 20:20:07 +08:00
|
|
|
self.hideDeleted(SettingsGet('HideDeleted'));
|
2022-09-27 15:46:49 +08:00
|
|
|
self.unhideKolabFolders(SettingsGet('UnhideKolabFolders'));
|
2022-08-09 21:34:55 +08:00
|
|
|
|
|
|
|
self.requestReadReceipt(SettingsGet('requestReadReceipt'));
|
|
|
|
self.requestDsn(SettingsGet('requestDsn'));
|
|
|
|
self.pgpSign(SettingsGet('pgpSign'));
|
|
|
|
self.pgpEncrypt(SettingsGet('pgpEncrypt'));
|
2021-11-19 19:44:53 +08:00
|
|
|
}
|
2021-03-11 05:41:35 +08:00
|
|
|
};
|