Add cmd interface

Code refactoring
This commit is contained in:
RainLoop Team 2016-08-24 01:17:50 +03:00
parent e6e1a19477
commit 962391e2a0
23 changed files with 180 additions and 223 deletions

View file

@ -1,6 +1,7 @@
import ko from 'ko';
import _ from '_';
import {Magics} from 'Common/Enums';
import * as Settings from 'Storage/Settings';
class AccountUserStore
@ -12,7 +13,7 @@ class AccountUserStore
this.signature = ko.observable('');
this.accounts = ko.observableArray([]);
this.accounts.loading = ko.observable(false).extend({throttle: 100});
this.accounts.loading = ko.observable(false).extend({throttle: Magics.Time100ms});
this.computers();
}

View file

@ -2,9 +2,10 @@
import ko from 'ko';
import {Focused, KeyState} from 'Common/Enums';
import {keyScope} from 'Common/Globals';
import * as Settings from 'Storage/Settings';
import {isNonEmptyArray} from 'Common/Utils';
import * as Settings from 'Storage/Settings';
import {AbstractAppStore} from 'Stores/AbstractApp';
class AppUserStore extends AbstractAppStore

View file

@ -1,16 +1,17 @@
import ko from 'ko';
import {Magics} from 'Common/Enums';
import * as Settings from 'Storage/Settings';
class ContactUserStore
{
constructor() {
this.contacts = ko.observableArray([]);
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
this.contacts.importing = ko.observable(false).extend({'throttle': 200});
this.contacts.syncing = ko.observable(false).extend({'throttle': 200});
this.contacts.exportingVcf = ko.observable(false).extend({'throttle': 200});
this.contacts.exportingCsv = ko.observable(false).extend({'throttle': 200});
this.contacts.loading = ko.observable(false).extend({throttle: Magics.Time200ms});
this.contacts.importing = ko.observable(false).extend({throttle: Magics.Time200ms});
this.contacts.syncing = ko.observable(false).extend({throttle: Magics.Time200ms});
this.contacts.exportingVcf = ko.observable(false).extend({throttle: Magics.Time200ms});
this.contacts.exportingCsv = ko.observable(false).extend({throttle: Magics.Time200ms});
this.allowContactsSync = ko.observable(false);
this.enableContactsSync = ko.observable(false);

View file

@ -1,5 +1,6 @@
import ko from 'ko';
import {Magics} from 'Common/Enums';
class FilterUserStore
{
@ -9,8 +10,8 @@ class FilterUserStore
this.filters = ko.observableArray([]);
this.filters.loading = ko.observable(false).extend({throttle: 200});
this.filters.saving = ko.observable(false).extend({throttle: 200});
this.filters.loading = ko.observable(false).extend({throttle: Magics.Time200ms});
this.filters.saving = ko.observable(false).extend({throttle: Magics.Time200ms});
this.raw = ko.observable('');
}

View file

@ -31,19 +31,7 @@ class FolderUserStore
this.foldersInboxUnreadCount = ko.observable(0);
this.currentFolder = ko.observable(null).extend({toggleSubscribe: [
null,
(prev) => {
if (prev) {
prev.selected(false);
}
},
(next) => {
if (next) {
next.selected(true);
}
}
]});
this.currentFolder = ko.observable(null).extend({toggleSubscribeProperty: [this, 'selected']});
this.computers();
this.subscribers();

View file

@ -2,6 +2,8 @@
import window from 'window';
import ko from 'ko';
import {Magics} from 'Common/Enums';
class QuotaUserStore
{
constructor() {
@ -24,8 +26,8 @@ class QuotaUserStore
* @param {number} usage
*/
populateData(quota, usage) {
this.quota(quota * 1024);
this.usage(usage * 1024);
this.quota(quota * Magics.BitLength1024);
this.usage(usage * Magics.BitLength1024);
}
}

View file

@ -33,7 +33,7 @@ class SettingsUserStore
this.useThreads = ko.observable(false);
this.replySameFolder = ko.observable(false);
this.autoLogout = ko.observable(30);
this.autoLogout = ko.observable(Magics.Time30mInMin);
this.computers();
this.subscribers();
@ -44,11 +44,11 @@ class SettingsUserStore
}
subscribers() {
this.layout.subscribe((nValue) => {
$html.toggleClass('rl-no-preview-pane', Layout.NoPreview === nValue);
$html.toggleClass('rl-side-preview-pane', Layout.SidePreview === nValue);
$html.toggleClass('rl-bottom-preview-pane', Layout.BottomPreview === nValue);
Events.pub('layout', [nValue]);
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]);
});
}