mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 04:29:21 +03:00
Sound notification
Additional code refactoring
This commit is contained in:
parent
b42ce01e7e
commit
aa84077ac4
87 changed files with 1573 additions and 574 deletions
|
|
@ -1,56 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Settings = require('Storage/Settings')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AbstractDataStorate()
|
||||
{
|
||||
Utils.initDataConstructorBySettings(this);
|
||||
}
|
||||
|
||||
AbstractDataStorate.prototype.populateDataOnStart = function()
|
||||
{
|
||||
this.capaAdditionalAccounts(Settings.capa(Enums.Capa.AdditionalAccounts));
|
||||
this.capaAdditionalIdentities(Settings.capa(Enums.Capa.AdditionalIdentities));
|
||||
this.capaGravatar(Settings.capa(Enums.Capa.Gravatar));
|
||||
this.capaAttachmentThumbnails(Settings.capa(Enums.Capa.AttachmentThumbnails));
|
||||
this.capaSieve(Settings.capa(Enums.Capa.Sieve));
|
||||
this.determineUserLanguage(!!Settings.settingsGet('DetermineUserLanguage'));
|
||||
this.determineUserDomain(!!Settings.settingsGet('DetermineUserDomain'));
|
||||
|
||||
this.weakPassword(!!Settings.settingsGet('WeakPassword'));
|
||||
|
||||
this.capaThemes(Settings.capa(Enums.Capa.Themes));
|
||||
this.capaUserBackground(Settings.capa(Enums.Capa.UserBackground));
|
||||
this.allowLanguagesOnLogin(!!Settings.settingsGet('AllowLanguagesOnLogin'));
|
||||
this.allowLanguagesOnSettings(!!Settings.settingsGet('AllowLanguagesOnSettings'));
|
||||
this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages'));
|
||||
|
||||
this.showImages(!!Settings.settingsGet('ShowImages'));
|
||||
this.contactsAutosave(!!Settings.settingsGet('ContactsAutosave'));
|
||||
this.interfaceAnimation(!!Settings.settingsGet('InterfaceAnimation'));
|
||||
|
||||
this.useThreads(!!Settings.settingsGet('UseThreads'));
|
||||
this.replySameFolder(!!Settings.settingsGet('ReplySameFolder'));
|
||||
this.useCheckboxesInList(!!Settings.settingsGet('UseCheckboxesInList'));
|
||||
|
||||
require('Stores/Social').populate();
|
||||
require('Stores/UserSettings').populate();
|
||||
require('Stores/NotificationSettings').populate();
|
||||
|
||||
this.contactsIsAllowed(!!Settings.settingsGet('ContactsIsAllowed'));
|
||||
};
|
||||
|
||||
module.exports = AbstractDataStorate;
|
||||
|
||||
}());
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
AbstractData = require('Storage/AbstractData')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractData
|
||||
*/
|
||||
function DataAdminStorage()
|
||||
{
|
||||
AbstractData.call(this);
|
||||
|
||||
this.domains = ko.observableArray([]);
|
||||
this.domains.loading = ko.observable(false).extend({'throttle': 100});
|
||||
|
||||
this.plugins = ko.observableArray([]);
|
||||
this.plugins.loading = ko.observable(false).extend({'throttle': 100});
|
||||
|
||||
this.packagesReal = ko.observable(true);
|
||||
this.packagesMainUpdatable = ko.observable(true);
|
||||
this.packages = ko.observableArray([]);
|
||||
this.packages.loading = ko.observable(false).extend({'throttle': 100});
|
||||
|
||||
this.coreReal = ko.observable(true);
|
||||
this.coreChannel = ko.observable('stable');
|
||||
this.coreType = ko.observable('stable');
|
||||
this.coreUpdatable = ko.observable(true);
|
||||
this.coreAccess = ko.observable(true);
|
||||
this.coreChecking = ko.observable(false).extend({'throttle': 100});
|
||||
this.coreUpdating = ko.observable(false).extend({'throttle': 100});
|
||||
this.coreRemoteVersion = ko.observable('');
|
||||
this.coreRemoteRelease = ko.observable('');
|
||||
this.coreVersionCompare = ko.observable(-2);
|
||||
|
||||
this.licensing = ko.observable(false);
|
||||
this.licensingProcess = ko.observable(false);
|
||||
this.licenseValid = ko.observable(false);
|
||||
this.licenseExpired = ko.observable(0);
|
||||
this.licenseError = ko.observable('');
|
||||
|
||||
this.licenseTrigger = ko.observable(false);
|
||||
|
||||
this.adminManLoading = ko.computed(function () {
|
||||
return '000' !== [this.domains.loading() ? '1' : '0', this.plugins.loading() ? '1' : '0', this.packages.loading() ? '1' : '0'].join('');
|
||||
}, this);
|
||||
|
||||
this.adminManLoadingVisibility = ko.computed(function () {
|
||||
return this.adminManLoading() ? 'visible' : 'hidden';
|
||||
}, this).extend({'rateLimit': 300});
|
||||
}
|
||||
|
||||
_.extend(DataAdminStorage.prototype, AbstractData.prototype);
|
||||
|
||||
DataAdminStorage.prototype.populateDataOnStart = function()
|
||||
{
|
||||
AbstractData.prototype.populateDataOnStart.call(this);
|
||||
};
|
||||
|
||||
module.exports = new DataAdminStorage();
|
||||
|
||||
}());
|
||||
|
|
@ -6,12 +6,12 @@
|
|||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function LocalStorage()
|
||||
function ClientStorage()
|
||||
{
|
||||
var
|
||||
NextStorageDriver = require('_').find([
|
||||
require('Storage/LocalDriver/LocalStorage'),
|
||||
require('Storage/LocalDriver/Cookie')
|
||||
require('Common/ClientStorageDriver/LocalStorage'),
|
||||
require('Common/ClientStorageDriver/Cookie')
|
||||
], function (NextStorageDriver) {
|
||||
return NextStorageDriver && NextStorageDriver.supported();
|
||||
})
|
||||
|
|
@ -28,14 +28,14 @@
|
|||
/**
|
||||
* @type {LocalStorageDriver|CookieDriver|null}
|
||||
*/
|
||||
LocalStorage.prototype.oDriver = null;
|
||||
ClientStorage.prototype.oDriver = null;
|
||||
|
||||
/**
|
||||
* @param {number} iKey
|
||||
* @param {*} mData
|
||||
* @return {boolean}
|
||||
*/
|
||||
LocalStorage.prototype.set = function (iKey, mData)
|
||||
ClientStorage.prototype.set = function (iKey, mData)
|
||||
{
|
||||
return this.oDriver ? this.oDriver.set('p' + iKey, mData) : false;
|
||||
};
|
||||
|
|
@ -44,11 +44,11 @@
|
|||
* @param {number} iKey
|
||||
* @return {*}
|
||||
*/
|
||||
LocalStorage.prototype.get = function (iKey)
|
||||
ClientStorage.prototype.get = function (iKey)
|
||||
{
|
||||
return this.oDriver ? this.oDriver.get('p' + iKey) : null;
|
||||
};
|
||||
|
||||
module.exports = new LocalStorage();
|
||||
module.exports = new ClientStorage();
|
||||
|
||||
}());
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
$ = require('$'),
|
||||
JSON = require('JSON'),
|
||||
|
||||
Consts = require('Common/Consts'),
|
||||
Utils = require('Common/Utils')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function CookieLocalDriver()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @return {boolean}
|
||||
*/
|
||||
CookieLocalDriver.supported = function ()
|
||||
{
|
||||
return !!(window.navigator && window.navigator.cookieEnabled);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sKey
|
||||
* @param {*} mData
|
||||
* @return {boolean}
|
||||
*/
|
||||
CookieLocalDriver.prototype.set = function (sKey, mData)
|
||||
{
|
||||
var
|
||||
mStorageValue = $.cookie(Consts.Values.ClientSideStorageIndexName),
|
||||
bResult = false,
|
||||
mResult = null
|
||||
;
|
||||
|
||||
try
|
||||
{
|
||||
mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
|
||||
}
|
||||
catch (oException) {}
|
||||
|
||||
if (!mResult)
|
||||
{
|
||||
mResult = {};
|
||||
}
|
||||
|
||||
mResult[sKey] = mData;
|
||||
|
||||
try
|
||||
{
|
||||
$.cookie(Consts.Values.ClientSideStorageIndexName, JSON.stringify(mResult), {
|
||||
'expires': 30
|
||||
});
|
||||
|
||||
bResult = true;
|
||||
}
|
||||
catch (oException) {}
|
||||
|
||||
return bResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sKey
|
||||
* @return {*}
|
||||
*/
|
||||
CookieLocalDriver.prototype.get = function (sKey)
|
||||
{
|
||||
var
|
||||
mStorageValue = $.cookie(Consts.Values.ClientSideStorageIndexName),
|
||||
mResult = null
|
||||
;
|
||||
|
||||
try
|
||||
{
|
||||
mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
|
||||
if (mResult && !Utils.isUnd(mResult[sKey]))
|
||||
{
|
||||
mResult = mResult[sKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
mResult = null;
|
||||
}
|
||||
}
|
||||
catch (oException) {}
|
||||
|
||||
return mResult;
|
||||
};
|
||||
|
||||
module.exports = CookieLocalDriver;
|
||||
|
||||
}());
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
JSON = require('JSON'),
|
||||
|
||||
Consts = require('Common/Consts'),
|
||||
Utils = require('Common/Utils')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function LocalStorageLocalDriver()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @return {boolean}
|
||||
*/
|
||||
LocalStorageLocalDriver.supported = function ()
|
||||
{
|
||||
return !!window.localStorage;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sKey
|
||||
* @param {*} mData
|
||||
* @return {boolean}
|
||||
*/
|
||||
LocalStorageLocalDriver.prototype.set = function (sKey, mData)
|
||||
{
|
||||
var
|
||||
mStorageValue = window.localStorage[Consts.Values.ClientSideStorageIndexName] || null,
|
||||
bResult = false,
|
||||
mResult = null
|
||||
;
|
||||
|
||||
try
|
||||
{
|
||||
mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
|
||||
}
|
||||
catch (oException) {}
|
||||
|
||||
if (!mResult)
|
||||
{
|
||||
mResult = {};
|
||||
}
|
||||
|
||||
mResult[sKey] = mData;
|
||||
|
||||
try
|
||||
{
|
||||
window.localStorage[Consts.Values.ClientSideStorageIndexName] = JSON.stringify(mResult);
|
||||
|
||||
bResult = true;
|
||||
}
|
||||
catch (oException) {}
|
||||
|
||||
return bResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sKey
|
||||
* @return {*}
|
||||
*/
|
||||
LocalStorageLocalDriver.prototype.get = function (sKey)
|
||||
{
|
||||
var
|
||||
mStorageValue = window.localStorage[Consts.Values.ClientSideStorageIndexName] || null,
|
||||
mResult = null
|
||||
;
|
||||
|
||||
try
|
||||
{
|
||||
mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
|
||||
if (mResult && !Utils.isUnd(mResult[sKey]))
|
||||
{
|
||||
mResult = mResult[sKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
mResult = null;
|
||||
}
|
||||
}
|
||||
catch (oException) {}
|
||||
|
||||
return mResult;
|
||||
};
|
||||
|
||||
module.exports = LocalStorageLocalDriver;
|
||||
|
||||
}());
|
||||
|
|
@ -17,6 +17,8 @@
|
|||
Links = require('Common/Links'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
SettingsUserStore = require('Stores/User/Settings'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Cache = require('Storage/User/Cache'),
|
||||
|
||||
|
|
@ -24,18 +26,14 @@
|
|||
|
||||
MessageModel = require('Model/Message'),
|
||||
|
||||
Local = require('Storage/Local'),
|
||||
AbstractData = require('Storage/AbstractData')
|
||||
Local = require('Storage/Client')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractData
|
||||
*/
|
||||
function DataUserStorage()
|
||||
{
|
||||
AbstractData.call(this);
|
||||
|
||||
var
|
||||
fRemoveSystemFolderType = function (observable) {
|
||||
return function () {
|
||||
|
|
@ -272,7 +270,7 @@
|
|||
|
||||
this.messageListPageCount = ko.computed(function () {
|
||||
var iPage = window.Math.ceil(this.messageListCount() /
|
||||
require('Stores/UserSettings').messagesPerPage());
|
||||
SettingsUserStore.messagesPerPage());
|
||||
return 0 >= iPage ? 1 : iPage;
|
||||
}, this);
|
||||
|
||||
|
|
@ -328,13 +326,13 @@
|
|||
this.messageFullScreenMode(false);
|
||||
this.hideMessageBodies();
|
||||
|
||||
if (Enums.Layout.NoPreview === require('Stores/UserSettings').layout() &&
|
||||
if (Enums.Layout.NoPreview === SettingsUserStore.layout() &&
|
||||
-1 < window.location.hash.indexOf('message-preview'))
|
||||
{
|
||||
require('App/User').historyBack();
|
||||
}
|
||||
}
|
||||
else if (Enums.Layout.NoPreview === require('Stores/UserSettings').layout())
|
||||
else if (Enums.Layout.NoPreview === SettingsUserStore.layout())
|
||||
{
|
||||
this.message.focused(true);
|
||||
}
|
||||
|
|
@ -348,7 +346,7 @@
|
|||
}
|
||||
else if (Enums.KeyState.MessageView === Globals.keyScope())
|
||||
{
|
||||
if (Enums.Layout.NoPreview === require('Stores/UserSettings').layout() && this.message())
|
||||
if (Enums.Layout.NoPreview === SettingsUserStore.layout() && this.message())
|
||||
{
|
||||
Globals.keyScope(Enums.KeyState.MessageView);
|
||||
}
|
||||
|
|
@ -451,8 +449,6 @@
|
|||
this.purgeMessageBodyCacheThrottle = _.throttle(this.purgeMessageBodyCache, 1000 * 30);
|
||||
}
|
||||
|
||||
_.extend(DataUserStorage.prototype, AbstractData.prototype);
|
||||
|
||||
DataUserStorage.prototype.purgeMessageBodyCache = function()
|
||||
{
|
||||
var
|
||||
|
|
@ -487,8 +483,6 @@
|
|||
|
||||
DataUserStorage.prototype.populateDataOnStart = function()
|
||||
{
|
||||
AbstractData.prototype.populateDataOnStart.call(this);
|
||||
|
||||
this.accountEmail(Settings.settingsGet('Email'));
|
||||
this.accountIncLogin(Settings.settingsGet('IncLogin'));
|
||||
this.accountOutLogin(Settings.settingsGet('OutLogin'));
|
||||
|
|
@ -519,52 +513,18 @@
|
|||
var
|
||||
iIndex = 0,
|
||||
iLen = aNewMessages.length,
|
||||
fNotificationHelper = function (sImageSrc, sTitle, sText)
|
||||
{
|
||||
var
|
||||
NotificationSettingsStore = require('Stores/NotificationSettings'),
|
||||
NotificationClass = NotificationSettingsStore.notificationClass(),
|
||||
oNotification = null
|
||||
;
|
||||
|
||||
if (NotificationClass && NotificationSettingsStore.enableDesktopNotification())
|
||||
{
|
||||
oNotification = new NotificationClass(sTitle, {
|
||||
'body': sText,
|
||||
'icon': sImageSrc
|
||||
});
|
||||
|
||||
if (oNotification)
|
||||
{
|
||||
if (oNotification.show)
|
||||
{
|
||||
oNotification.show();
|
||||
}
|
||||
|
||||
window.setTimeout((function (oLocalNotifications) {
|
||||
return function () {
|
||||
if (oLocalNotifications.cancel)
|
||||
{
|
||||
oLocalNotifications.cancel();
|
||||
}
|
||||
else if (oLocalNotifications.close)
|
||||
{
|
||||
oLocalNotifications.close();
|
||||
}
|
||||
};
|
||||
}(oNotification)), 7000);
|
||||
}
|
||||
}
|
||||
}
|
||||
NotificationStore = require('Stores/User/Notification')
|
||||
;
|
||||
|
||||
_.each(aNewMessages, function (oItem) {
|
||||
Cache.addNewMessageCache(sFolder, oItem.Uid);
|
||||
});
|
||||
|
||||
NotificationStore.playSoundNotification();
|
||||
|
||||
if (3 < iLen)
|
||||
{
|
||||
fNotificationHelper(
|
||||
NotificationStore.displayDesktopNotification(
|
||||
Links.notificationMailIcon(),
|
||||
this.accountEmail(),
|
||||
Translator.i18n('MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION', {
|
||||
|
|
@ -576,7 +536,7 @@
|
|||
{
|
||||
for (; iIndex < iLen; iIndex++)
|
||||
{
|
||||
fNotificationHelper(
|
||||
NotificationStore.displayDesktopNotification(
|
||||
Links.notificationMailIcon(),
|
||||
MessageModel.emailsToLine(MessageModel.initEmailsFromJson(aNewMessages[iIndex].From), false),
|
||||
aNewMessages[iIndex].Subject
|
||||
|
|
@ -907,7 +867,7 @@
|
|||
oMessage.showInternalImages(true);
|
||||
}
|
||||
|
||||
if (oMessage.hasImages() && this.showImages())
|
||||
if (oMessage.hasImages() && SettingsUserStore.showImages())
|
||||
{
|
||||
oMessage.showExternalImages(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
Consts = require('Common/Consts'),
|
||||
Base64 = require('Common/Base64'),
|
||||
|
||||
SettingsUserStore = require('Stores/User/Settings'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Cache = require('Storage/User/Cache'),
|
||||
Data = require('Storage/User/Data'),
|
||||
|
|
@ -285,7 +287,7 @@
|
|||
Data.projectHash(),
|
||||
sFolderHash,
|
||||
Cache.getFolderInboxName() === sFolderFullNameRaw ? Cache.getFolderUidNext(sFolderFullNameRaw) : '',
|
||||
Data.threading() && Data.useThreads() ? '1' : '0',
|
||||
Data.threading() && SettingsUserStore.useThreads() ? '1' : '0',
|
||||
Data.threading() && sFolderFullNameRaw === Data.messageListThreadFolder() ? Data.messageListThreadUids().join(',') : ''
|
||||
].join(String.fromCharCode(0))), bSilent ? [] : ['MessageList']);
|
||||
}
|
||||
|
|
@ -297,7 +299,7 @@
|
|||
'Limit': iLimit,
|
||||
'Search': sSearch,
|
||||
'UidNext': Cache.getFolderInboxName() === sFolderFullNameRaw ? Cache.getFolderUidNext(sFolderFullNameRaw) : '',
|
||||
'UseThreads': Data.threading() && Data.useThreads() ? '1' : '0',
|
||||
'UseThreads': Data.threading() && SettingsUserStore.useThreads() ? '1' : '0',
|
||||
'ExpandedThreadUid': Data.threading() && sFolderFullNameRaw === Data.messageListThreadFolder() ? Data.messageListThreadUids().join(',') : ''
|
||||
}, '' === sSearch ? Consts.Defaults.DefaultAjaxTimeout : Consts.Defaults.SearchAjaxTimeout, '', bSilent ? [] : ['MessageList']);
|
||||
}
|
||||
|
|
@ -332,7 +334,7 @@
|
|||
sFolderFullNameRaw,
|
||||
iUid,
|
||||
Data.projectHash(),
|
||||
Data.threading() && Data.useThreads() ? '1' : '0'
|
||||
Data.threading() && SettingsUserStore.useThreads() ? '1' : '0'
|
||||
].join(String.fromCharCode(0))), ['Message']);
|
||||
|
||||
return true;
|
||||
|
|
@ -411,7 +413,7 @@
|
|||
'UidNext': Cache.getFolderInboxName() === sFolder ? Cache.getFolderUidNext(sFolder) : ''
|
||||
});
|
||||
}
|
||||
else if (Data.useThreads())
|
||||
else if (SettingsUserStore.useThreads())
|
||||
{
|
||||
require('App/User').reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue