2015-01-26 07:09:22 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import window from 'window';
|
|
|
|
import ko from 'ko';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import {MESSAGES_PER_PAGE, MESSAGES_PER_PAGE_VALUES} from 'Common/Consts';
|
|
|
|
import {Layout, EditorDefaultType, Magics} from 'Common/Enums';
|
|
|
|
import {$html} from 'Common/Globals';
|
|
|
|
import {pInt} from 'Common/Utils';
|
|
|
|
import * as Events from 'Common/Events';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import * as Settings from 'Storage/Settings';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
class SettingsUserStore
|
2016-06-30 08:02:45 +08:00
|
|
|
{
|
2016-08-17 06:01:20 +08:00
|
|
|
constructor() {
|
|
|
|
|
|
|
|
this.iAutoLogoutTimer = 0;
|
|
|
|
|
|
|
|
this.layout = ko.observable(Layout.SidePreview)
|
|
|
|
.extend({limitedList: [Layout.SidePreview, Layout.BottomPreview, Layout.NoPreview]});
|
|
|
|
|
|
|
|
this.editorDefaultType = ko.observable(EditorDefaultType.Html)
|
|
|
|
.extend({limitedList: [
|
|
|
|
EditorDefaultType.Html, EditorDefaultType.Plain,
|
|
|
|
EditorDefaultType.HtmlForced, EditorDefaultType.PlainForced
|
|
|
|
]});
|
|
|
|
|
|
|
|
this.messagesPerPage = ko.observable(MESSAGES_PER_PAGE)
|
|
|
|
.extend({limitedList: MESSAGES_PER_PAGE_VALUES});
|
|
|
|
|
|
|
|
this.showImages = ko.observable(false);
|
|
|
|
this.useCheckboxesInList = ko.observable(true);
|
2017-06-29 00:25:53 +08:00
|
|
|
this.allowDraftAutosave = ko.observable(true);
|
2016-08-17 06:01:20 +08:00
|
|
|
this.useThreads = ko.observable(false);
|
|
|
|
this.replySameFolder = ko.observable(false);
|
|
|
|
|
2016-08-24 06:17:50 +08:00
|
|
|
this.autoLogout = ko.observable(Magics.Time30mInMin);
|
2016-08-17 06:01:20 +08:00
|
|
|
|
|
|
|
this.computers();
|
|
|
|
this.subscribers();
|
|
|
|
}
|
|
|
|
|
|
|
|
computers() {
|
|
|
|
this.usePreviewPane = ko.computed(() => Layout.NoPreview !== this.layout());
|
|
|
|
}
|
|
|
|
|
|
|
|
subscribers() {
|
2016-08-24 06:17:50 +08:00
|
|
|
this.layout.subscribe((value) => {
|
|
|
|
$html.toggleClass('rl-no-preview-pane', Layout.NoPreview === value);
|
|
|
|
$html.toggleClass('rl-side-preview-pane', Layout.SidePreview === value);
|
|
|
|
$html.toggleClass('rl-bottom-preview-pane', Layout.BottomPreview === value);
|
|
|
|
Events.pub('layout', [value]);
|
2016-08-17 06:01:20 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
populate() {
|
|
|
|
this.layout(pInt(Settings.settingsGet('Layout')));
|
|
|
|
this.editorDefaultType(Settings.settingsGet('EditorDefaultType'));
|
|
|
|
|
|
|
|
this.autoLogout(pInt(Settings.settingsGet('AutoLogout')));
|
|
|
|
this.messagesPerPage(Settings.settingsGet('MPP'));
|
|
|
|
|
|
|
|
this.showImages(!!Settings.settingsGet('ShowImages'));
|
|
|
|
this.useCheckboxesInList(!!Settings.settingsGet('UseCheckboxesInList'));
|
2017-06-29 00:25:53 +08:00
|
|
|
this.allowDraftAutosave(!!Settings.settingsGet('AllowDraftAutosave'));
|
2016-08-17 06:01:20 +08:00
|
|
|
this.useThreads(!!Settings.settingsGet('UseThreads'));
|
|
|
|
this.replySameFolder(!!Settings.settingsGet('ReplySameFolder'));
|
|
|
|
|
|
|
|
Events.sub('rl.auto-logout-refresh', () => {
|
|
|
|
window.clearTimeout(this.iAutoLogoutTimer);
|
|
|
|
if (0 < this.autoLogout() && !Settings.settingsGet('AccountSignMe'))
|
|
|
|
{
|
|
|
|
this.iAutoLogoutTimer = window.setTimeout(() => {
|
|
|
|
Events.pub('rl.auto-logout');
|
|
|
|
}, this.autoLogout() * Magics.Time1m);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Events.pub('rl.auto-logout-refresh');
|
|
|
|
}
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-09-13 04:50:21 +08:00
|
|
|
export default new SettingsUserStore();
|