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

@ -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});