Sound notification

Additional code refactoring
This commit is contained in:
RainLoop Team 2015-01-27 01:06:00 +04:00
parent b42ce01e7e
commit aa84077ac4
87 changed files with 1573 additions and 574 deletions

View file

@ -4,7 +4,10 @@
'use strict';
var
ko = require('ko')
ko = require('ko'),
Settings = require('Storage/Settings'),
CoreStore = require('Stores/Admin/Core')
;
/**
@ -12,25 +15,20 @@
*/
function AboutAdminSettings()
{
var
Settings = require('Storage/Settings'),
Data = require('Storage/Admin/Data')
;
this.version = ko.observable(Settings.settingsGet('Version'));
this.access = ko.observable(!!Settings.settingsGet('CoreAccess'));
this.errorDesc = ko.observable('');
this.coreReal = Data.coreReal;
this.coreChannel = Data.coreChannel;
this.coreType = Data.coreType;
this.coreUpdatable = Data.coreUpdatable;
this.coreAccess = Data.coreAccess;
this.coreChecking = Data.coreChecking;
this.coreUpdating = Data.coreUpdating;
this.coreRemoteVersion = Data.coreRemoteVersion;
this.coreRemoteRelease = Data.coreRemoteRelease;
this.coreVersionCompare = Data.coreVersionCompare;
this.coreReal = CoreStore.coreReal;
this.coreChannel = CoreStore.coreChannel;
this.coreType = CoreStore.coreType;
this.coreUpdatable = CoreStore.coreUpdatable;
this.coreAccess = CoreStore.coreAccess;
this.coreChecking = CoreStore.coreChecking;
this.coreUpdating = CoreStore.coreUpdating;
this.coreRemoteVersion = CoreStore.coreRemoteVersion;
this.coreRemoteRelease = CoreStore.coreRemoteRelease;
this.coreVersionCompare = CoreStore.coreVersionCompare;
this.statusType = ko.computed(function () {

View file

@ -12,7 +12,7 @@
PopupsDomainViewModel = require('View/Popup/Domain'),
Data = require('Storage/Admin/Data'),
DomainStore = require('Stores/Admin/Domain'),
Remote = require('Storage/Admin/Remote')
;
@ -21,12 +21,12 @@
*/
function DomainsAdminSettings()
{
this.domains = Data.domains;
this.domains = DomainStore.collection;
this.iDomainForDeletionTimeout = 0;
this.visibility = ko.computed(function () {
return Data.domains.loading() ? 'visible' : 'hidden';
return this.domains.loading() ? 'visible' : 'hidden';
}, this);
this.domainForDeletion = ko.observable(null).extend({'toggleSubscribe': [this,

View file

@ -11,10 +11,12 @@
Utils = require('Common/Utils'),
Links = require('Common/Links'),
UserSettingsStore = require('Stores/UserSettings'),
ThemeStore = require('Stores/Theme'),
LanguageStore = require('Stores/Language'),
AppAdminStore = require('Stores/Admin/App'),
CapaAdminStore = require('Stores/Admin/Capa'),
Settings = require('Storage/Settings'),
Data = require('Storage/Admin/Data')
Settings = require('Storage/Settings')
;
/**
@ -22,20 +24,20 @@
*/
function GeneralAdminSettings()
{
this.language = UserSettingsStore.language;
this.languages = UserSettingsStore.languages;
this.theme = UserSettingsStore.theme;
this.themes = UserSettingsStore.themes;
this.language = LanguageStore.language;
this.languages = LanguageStore.languages;
this.theme = ThemeStore.theme;
this.themes = ThemeStore.themes;
this.capaThemes = Data.capaThemes;
this.capaUserBackground = Data.capaUserBackground;
this.allowLanguagesOnSettings = Data.allowLanguagesOnSettings;
this.capaGravatar = Data.capaGravatar;
this.capaAdditionalAccounts = Data.capaAdditionalAccounts;
this.capaAdditionalIdentities = Data.capaAdditionalIdentities;
this.capaAttachmentThumbnails = Data.capaAttachmentThumbnails;
this.capaThemes = CapaAdminStore.themes;
this.capaUserBackground = CapaAdminStore.userBackground;
this.capaGravatar = CapaAdminStore.gravatar;
this.capaAdditionalAccounts = CapaAdminStore.additionalAccounts;
this.capaAdditionalIdentities = CapaAdminStore.additionalIdentities;
this.capaAttachmentThumbnails = CapaAdminStore.attachmentThumbnails;
this.weakPassword = Data.weakPassword;
this.allowLanguagesOnSettings = AppAdminStore.allowLanguagesOnSettings;
this.weakPassword = AppAdminStore.weakPassword;
this.mainAttachmentLimit = ko.observable(Utils.pInt(Settings.settingsGet('AttachmentLimit')) / (1024 * 1024)).extend({'posInterer': 25});
this.uploadData = Settings.settingsGet('PhpUploadSizes');

View file

@ -8,7 +8,7 @@
moment = require('moment'),
Settings = require('Storage/Settings'),
Data = require('Storage/Admin/Data')
LicenseStore = require('Stores/Admin/License')
;
/**
@ -16,12 +16,12 @@
*/
function LicensingAdminSettings()
{
this.licensing = Data.licensing;
this.licensingProcess = Data.licensingProcess;
this.licenseValid = Data.licenseValid;
this.licenseExpired = Data.licenseExpired;
this.licenseError = Data.licenseError;
this.licenseTrigger = Data.licenseTrigger;
this.licensing = LicenseStore.licensing;
this.licensingProcess = LicenseStore.licensingProcess;
this.licenseValid = LicenseStore.licenseValid;
this.licenseExpired = LicenseStore.licenseExpired;
this.licenseError = LicenseStore.licenseError;
this.licenseTrigger = LicenseStore.licenseTrigger;
this.adminDomain = ko.observable('');
this.subscriptionEnabled = ko.observable(!!Settings.settingsGet('SubscriptionEnabled'));

View file

@ -10,8 +10,9 @@
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Settings = require('Storage/Settings'),
Data = require('Storage/Admin/Data')
AppAdminStore = require('Stores/Admin/App'),
Settings = require('Storage/Settings')
;
/**
@ -19,12 +20,12 @@
*/
function LoginAdminSettings()
{
this.determineUserLanguage = Data.determineUserLanguage;
this.determineUserDomain = Data.determineUserDomain;
this.determineUserLanguage = AppAdminStore.determineUserLanguage;
this.determineUserDomain = AppAdminStore.determineUserDomain;
this.defaultDomain = ko.observable(Settings.settingsGet('LoginDefaultDomain'));
this.allowLanguagesOnLogin = Data.allowLanguagesOnLogin;
this.allowLanguagesOnLogin = AppAdminStore.allowLanguagesOnLogin;
this.defaultDomainTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.dummy = ko.observable(false);

View file

@ -5,12 +5,13 @@
var
window = require('window'),
_ = require('_'),
ko = require('ko'),
Enums = require('Common/Enums'),
Translator = require('Common/Translator'),
Data = require('Storage/Admin/Data'),
PackageStore = require('Stores/Admin/Package'),
Remote = require('Storage/Admin/Remote')
;
@ -21,9 +22,9 @@
{
this.packagesError = ko.observable('');
this.packages = Data.packages;
this.packagesReal = Data.packagesReal;
this.packagesMainUpdatable = Data.packagesMainUpdatable;
this.packages = PackageStore.collection;
this.packagesReal = PackageStore.packagesReal;
this.packagesMainUpdatable = PackageStore.packagesMainUpdatable;
this.packagesCurrent = this.packages.filter(function (oItem) {
return oItem && '' !== oItem['installed'] && !oItem['compare'];
@ -38,7 +39,7 @@
});
this.visibility = ko.computed(function () {
return Data.packages.loading() ? 'visible' : 'hidden';
return PackageStore.collection.loading() ? 'visible' : 'hidden';
}, this);
}
@ -70,7 +71,7 @@
}
}
_.each(Data.packages(), function (oItem) {
_.each(self.packages(), function (oItem) {
if (oItem && oPackage && oItem['loading']() && oPackage['file'] === oItem['file'])
{
oPackage['loading'](false);

View file

@ -12,7 +12,7 @@
Translator = require('Common/Translator'),
Settings = require('Storage/Settings'),
Data = require('Storage/Admin/Data'),
PluginStore = require('Stores/Admin/Plugin'),
Remote = require('Storage/Admin/Remote')
;
@ -23,12 +23,11 @@
{
this.enabledPlugins = ko.observable(!!Settings.settingsGet('EnabledPlugins'));
this.pluginsError = ko.observable('');
this.plugins = Data.plugins;
this.plugins = PluginStore.collection;
this.pluginsError = PluginStore.collection.error;
this.visibility = ko.computed(function () {
return Data.plugins.loading() ? 'visible' : 'hidden';
return PluginStore.collection.loading() ? 'visible' : 'hidden';
}, this);
this.onPluginLoadRequest = _.bind(this.onPluginLoadRequest, this);
@ -76,7 +75,7 @@
PluginsAdminSettings.prototype.onShow = function ()
{
this.pluginsError('');
PluginStore.collection.error('');
require('App/Admin').reloadPluginList();
};
@ -96,11 +95,11 @@
{
if (Enums.Notification.UnsupportedPluginPackage === oData.ErrorCode && oData.ErrorMessage && '' !== oData.ErrorMessage)
{
this.pluginsError(oData.ErrorMessage);
PluginStore.collection.error(oData.ErrorMessage);
}
else
{
this.pluginsError(Translator.getNotification(oData.ErrorCode));
PluginStore.collection.error(Translator.getNotification(oData.ErrorCode));
}
}
}

View file

@ -11,8 +11,10 @@
Utils = require('Common/Utils'),
Links = require('Common/Links'),
AppAdminStore = require('Stores/Admin/App'),
CapaAdminStore = require('Stores/Admin/Capa'),
Settings = require('Storage/Settings'),
Data = require('Storage/Admin/Data'),
Remote = require('Storage/Admin/Remote')
;
@ -21,12 +23,12 @@
*/
function SecurityAdminSettings()
{
this.useLocalProxyForExternalImages = Data.useLocalProxyForExternalImages;
this.useLocalProxyForExternalImages = AppAdminStore.useLocalProxyForExternalImages;
this.weakPassword = Data.weakPassword;
this.weakPassword = AppAdminStore.weakPassword;
this.capaOpenPGP = ko.observable(Settings.capa(Enums.Capa.OpenPGP));
this.capaTwoFactorAuth = ko.observable(Settings.capa(Enums.Capa.TwoFactor));
this.capaOpenPGP = CapaAdminStore.openPGP;
this.capaTwoFactorAuth = CapaAdminStore.twoFactorAuth;
this.verifySslCertificate = ko.observable(!!Settings.settingsGet('VerifySslCertificate'));
this.allowSelfSigned = ko.observable(!!Settings.settingsGet('AllowSelfSigned'));

View file

@ -6,6 +6,8 @@
var
ko = require('ko'),
AppStore = require('Stores/User/App'),
Remote = require('Storage/User/Remote'),
Data = require('Storage/User/Data')
;
@ -15,7 +17,7 @@
*/
function ContactsUserSettings()
{
this.contactsAutosave = Data.contactsAutosave;
this.contactsAutosave = AppStore.contactsAutosave;
this.allowContactsSync = Data.allowContactsSync;
this.enableContactsSync = Data.enableContactsSync;
@ -35,7 +37,7 @@
ContactsUserSettings.prototype.onBuild = function ()
{
Data.contactsAutosave.subscribe(function (bValue) {
this.contactsAutosave.subscribe(function (bValue) {
Remote.saveSettings(null, {
'ContactsAutosave': bValue ? '1' : '0'
});

View file

@ -11,7 +11,7 @@
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
FilterStore = require('Stores/Filter'),
FilterStore = require('Stores/User/Filter'),
Remote = require('Storage/User/Remote')
;

View file

@ -14,7 +14,7 @@
Data = require('Storage/User/Data'),
Cache = require('Storage/User/Cache'),
Remote = require('Storage/User/Remote'),
Local = require('Storage/Local')
Local = require('Storage/Client')
;
/**

View file

@ -13,8 +13,10 @@
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
UserSettingsStore = require('Stores/UserSettings'),
NotificationSettingsStore = require('Stores/NotificationSettings'),
AppStore = require('Stores/User/App'),
LanguageStore = require('Stores/Language'),
SettingsStore = require('Stores/User/Settings'),
NotificationStore = require('Stores/User/Notification'),
Data = require('Storage/User/Data'),
Remote = require('Storage/User/Remote')
@ -25,25 +27,27 @@
*/
function GeneralUserSettings()
{
this.language = UserSettingsStore.language;
this.messagesPerPage = UserSettingsStore.messagesPerPage;
this.language = LanguageStore.language;
this.messagesPerPage = SettingsStore.messagesPerPage;
this.messagesPerPageArray = Consts.Defaults.MessagesPerPageArray;
this.editorDefaultType = UserSettingsStore.editorDefaultType;
this.layout = UserSettingsStore.layout;
this.usePreviewPane = UserSettingsStore.usePreviewPane;
this.editorDefaultType = SettingsStore.editorDefaultType;
this.layout = SettingsStore.layout;
this.usePreviewPane = SettingsStore.usePreviewPane;
this.showImages = Data.showImages;
this.soundNotificationIsSupported = NotificationStore.soundNotificationIsSupported;
this.enableSoundNotification = NotificationStore.enableSoundNotification;
this.enableDesktopNotification = NotificationSettingsStore.enableDesktopNotification;
this.isDesktopNotificationSupported = NotificationSettingsStore.isDesktopNotificationSupported;
this.isDesktopNotificationDenied = NotificationSettingsStore.isDesktopNotificationDenied;
this.enableDesktopNotification = NotificationStore.enableDesktopNotification;
this.isDesktopNotificationSupported = NotificationStore.isDesktopNotificationSupported;
this.isDesktopNotificationDenied = NotificationStore.isDesktopNotificationDenied;
this.showImages = SettingsStore.showImages;
this.useCheckboxesInList = SettingsStore.useCheckboxesInList;
this.threading = Data.threading;
this.useThreads = Data.useThreads;
this.replySameFolder = Data.replySameFolder;
this.useCheckboxesInList = Data.useCheckboxesInList;
this.allowLanguagesOnSettings = Data.allowLanguagesOnSettings;
this.useThreads = SettingsStore.useThreads;
this.replySameFolder = SettingsStore.replySameFolder;
this.allowLanguagesOnSettings = AppStore.allowLanguagesOnSettings;
this.languageFullName = ko.computed(function () {
return Utils.convertLangName(this.language());
@ -77,6 +81,11 @@
}, this);
}
GeneralUserSettings.prototype.testSoundNotification = function ()
{
NotificationStore.playSoundNotification(true);
};
GeneralUserSettings.prototype.onBuild = function ()
{
var self = this;
@ -122,7 +131,7 @@
});
});
Data.showImages.subscribe(function (bValue) {
self.showImages.subscribe(function (bValue) {
Remote.saveSettings(null, {
'ShowImages': bValue ? '1' : '0'
});
@ -136,7 +145,15 @@
}, 3000);
});
Data.replySameFolder.subscribe(function (bValue) {
self.enableSoundNotification.subscribe(function (bValue) {
Utils.timeOutAction('SaveSoundNotification', function () {
Remote.saveSettings(null, {
'SoundNotification': bValue ? '1' : '0'
});
}, 3000);
});
self.replySameFolder.subscribe(function (bValue) {
Utils.timeOutAction('SaveReplySameFolder', function () {
Remote.saveSettings(null, {
'ReplySameFolder': bValue ? '1' : '0'
@ -144,7 +161,7 @@
}, 3000);
});
Data.useThreads.subscribe(function (bValue) {
self.useThreads.subscribe(function (bValue) {
Data.messageList([]);
@ -162,7 +179,7 @@
});
});
Data.useCheckboxesInList.subscribe(function (bValue) {
self.useCheckboxesInList.subscribe(function (bValue) {
Remote.saveSettings(null, {
'UseCheckboxesInList': bValue ? '1' : '0'
});

View file

@ -14,9 +14,9 @@
Links = require('Common/Links'),
Translator = require('Common/Translator'),
UserSettingsStore = require('Stores/UserSettings'),
ThemeStore = require('Stores/Theme'),
Data = require('Storage/User/Data'),
Settings = require('Storage/Settings'),
Remote = require('Storage/User/Remote')
;
@ -25,18 +25,18 @@
*/
function ThemesUserSettings()
{
this.theme = UserSettingsStore.theme;
this.themes = UserSettingsStore.themes;
this.theme = ThemeStore.theme;
this.themes = ThemeStore.themes;
this.themesObjects = ko.observableArray([]);
this.background = {};
this.background.name = UserSettingsStore.themeBackgroundName;
this.background.hash = UserSettingsStore.themeBackgroundHash;
this.background.name = ThemeStore.themeBackgroundName;
this.background.hash = ThemeStore.themeBackgroundHash;
this.background.uploaderButton = ko.observable(null);
this.background.loading = ko.observable(false);
this.background.error = ko.observable('');
this.capaUserBackground = Data.capaUserBackground;
this.capaUserBackground = ko.observable(Settings.capa(Enums.Capa.UserBackground));
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});