mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Code refactoring (Q -> Promise)
This commit is contained in:
parent
7e4479d655
commit
1323a9ce52
10 changed files with 164 additions and 139 deletions
|
|
@ -409,7 +409,7 @@ class AppUser extends AbstractApp
|
|||
{
|
||||
callback(!!value);
|
||||
}
|
||||
}).fail(() => {
|
||||
}).catch(() => {
|
||||
if (callback)
|
||||
{
|
||||
_.delay(() => callback(false), 1);
|
||||
|
|
@ -423,7 +423,7 @@ class AppUser extends AbstractApp
|
|||
.abort('Folders')
|
||||
.fastResolve(true)
|
||||
.then(() => promise)
|
||||
.fail((errorCode) => {
|
||||
.catch((errorCode) => {
|
||||
FolderStore.folderList.error(Translator.getNotification(errorCode, '', errorDefCode));
|
||||
}).fin(() => {
|
||||
Promises.foldersReloadWithTimeout(FolderStore.foldersLoading);
|
||||
|
|
@ -453,8 +453,11 @@ class AppUser extends AbstractApp
|
|||
: (oItem.users && oItem.users[0] ? oItem.users[0].userId.userid : '')
|
||||
;
|
||||
|
||||
if (oItem.users) {
|
||||
if (oItem.users)
|
||||
{
|
||||
_.each(oItem.users, (item) => {
|
||||
if (item.userId)
|
||||
{
|
||||
oEmail.clear();
|
||||
oEmail.mailsoParse(item.userId.userid);
|
||||
if (oEmail.validate())
|
||||
|
|
@ -462,6 +465,7 @@ class AppUser extends AbstractApp
|
|||
aEmails.push(oEmail.email);
|
||||
aUsers.push(item.userId.userid);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
var
|
||||
$ = require('$'),
|
||||
_ = require('_'),
|
||||
Q = require('Q'),
|
||||
Promise = require('Promise'),
|
||||
|
||||
Consts = require('Common/Consts'),
|
||||
Enums = require('Common/Enums'),
|
||||
|
|
@ -58,11 +58,12 @@
|
|||
|
||||
AbstractAjaxPromises.prototype.ajaxRequest = function (sAction, bPost, iTimeOut, oParameters, sAdditionalGetString, fTrigger)
|
||||
{
|
||||
var self = this;
|
||||
return new Promise(function(resolve, reject) {
|
||||
|
||||
var
|
||||
oH = null,
|
||||
self = this,
|
||||
iStart = Utils.microtime(),
|
||||
oDeferred = Q.defer()
|
||||
iStart = Utils.microtime()
|
||||
;
|
||||
|
||||
iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : Consts.DEFAULT_AJAX_TIMEOUT;
|
||||
|
|
@ -75,7 +76,7 @@
|
|||
|
||||
Plugins.runHook('ajax-default-request', [sAction, oParameters, sAdditionalGetString]);
|
||||
|
||||
this.setTrigger(fTrigger, true);
|
||||
self.setTrigger(fTrigger, true);
|
||||
|
||||
oH = $.ajax({
|
||||
'type': bPost ? 'POST' : 'GET',
|
||||
|
|
@ -112,35 +113,35 @@
|
|||
if (oData && oData.Result && sAction === oData.Action)
|
||||
{
|
||||
oData.__cached__ = bCached;
|
||||
oDeferred.resolve(oData);
|
||||
resolve(oData);
|
||||
}
|
||||
else if (oData && oData.Action)
|
||||
{
|
||||
oErrorData = oData;
|
||||
oDeferred.reject(oData.ErrorCode ? oData.ErrorCode : Enums.Notification.AjaxFalse);
|
||||
reject(oData.ErrorCode ? oData.ErrorCode : Enums.Notification.AjaxFalse);
|
||||
}
|
||||
else
|
||||
{
|
||||
oErrorData = oData;
|
||||
oDeferred.reject(Enums.Notification.AjaxParse);
|
||||
reject(Enums.Notification.AjaxParse);
|
||||
}
|
||||
}
|
||||
else if ('timeout' === sTextStatus)
|
||||
{
|
||||
oErrorData = oData;
|
||||
oDeferred.reject(Enums.Notification.AjaxTimeout);
|
||||
reject(Enums.Notification.AjaxTimeout);
|
||||
}
|
||||
else if ('abort' === sTextStatus)
|
||||
{
|
||||
if (!oData || !oData.__aborted__)
|
||||
{
|
||||
oDeferred.reject(Enums.Notification.AjaxAbort);
|
||||
reject(Enums.Notification.AjaxAbort);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
oErrorData = oData;
|
||||
oDeferred.reject(Enums.Notification.AjaxParse);
|
||||
reject(Enums.Notification.AjaxParse);
|
||||
}
|
||||
|
||||
if (self.oRequests[sAction])
|
||||
|
|
@ -193,16 +194,15 @@
|
|||
|
||||
if (oH)
|
||||
{
|
||||
if (this.oRequests[sAction])
|
||||
if (self.oRequests[sAction])
|
||||
{
|
||||
this.oRequests[sAction] = null;
|
||||
delete this.oRequests[sAction];
|
||||
self.oRequests[sAction] = null;
|
||||
delete self.oRequests[sAction];
|
||||
}
|
||||
|
||||
this.oRequests[sAction] = oH;
|
||||
self.oRequests[sAction] = oH;
|
||||
}
|
||||
|
||||
return oDeferred.promise;
|
||||
});
|
||||
};
|
||||
|
||||
AbstractAjaxPromises.prototype.getRequest = function (sAction, fTrigger, sAdditionalGetString, iTimeOut)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
Q = require('Q'),
|
||||
Promise = require('Promise'),
|
||||
|
||||
Utils = require('Common/Utils')
|
||||
;
|
||||
|
|
@ -26,16 +26,12 @@
|
|||
|
||||
AbstractBasicPromises.prototype.fastResolve = function (mData)
|
||||
{
|
||||
var oDeferred = Q.defer();
|
||||
oDeferred.resolve(mData);
|
||||
return oDeferred.promise;
|
||||
return Promise.resolve(mData);
|
||||
};
|
||||
|
||||
AbstractBasicPromises.prototype.fastReject = function (mData)
|
||||
{
|
||||
var oDeferred = Q.defer();
|
||||
oDeferred.reject(mData);
|
||||
return oDeferred.promise;
|
||||
return Promise.reject(mData);
|
||||
};
|
||||
|
||||
AbstractBasicPromises.prototype.setTrigger = function (mTrigger, bValue)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
kn = require('Knoin/Knoin'),
|
||||
|
||||
Translator = require('Common/Translator'),
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
Utils = require('Common/Utils')
|
||||
;
|
||||
|
|
@ -237,6 +238,23 @@
|
|||
return false;
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findKeyExternal = function (sEmail, fCallback)
|
||||
{
|
||||
if (this.openpgp.HKP && Settings.appSettingsGet('openpgpPublicKeyServer'))
|
||||
{
|
||||
var oHkp = new this.openpgp.HKP(Settings.appSettingsGet('openpgpPublicKeyServer').replace(/\/$/, ''));
|
||||
oHkp.lookup({query: sEmail}).then(function(sKey) {
|
||||
fCallback(sKey);
|
||||
}, function() {
|
||||
fCallback(null);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
fCallback(null);
|
||||
}
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.verifyMessage = function (oMessage, fCallback)
|
||||
{
|
||||
var oValid = null, aResult = [], aPublicKeys = [], aSigningKeyIds = [];
|
||||
|
|
@ -245,6 +263,10 @@
|
|||
aSigningKeyIds = oMessage.getSigningKeyIds();
|
||||
if (aSigningKeyIds && 0 < aSigningKeyIds.length)
|
||||
{
|
||||
// this.findKeyExternal('support@rainloop.net', function(key) {
|
||||
// console.log(key);
|
||||
// });
|
||||
|
||||
aPublicKeys = this.findPublicKeysBySigningKeyIds(aSigningKeyIds);
|
||||
if (aPublicKeys && 0 < aPublicKeys.length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1078,7 +1078,7 @@
|
|||
{
|
||||
self.downloadAsZipError(true);
|
||||
}
|
||||
}).fail(function () {
|
||||
}).catch(function () {
|
||||
self.downloadAsZipError(true);
|
||||
});
|
||||
}
|
||||
|
|
@ -1102,7 +1102,7 @@
|
|||
{
|
||||
self.saveToOwnCloudError(true);
|
||||
}
|
||||
}).fail(function () {
|
||||
}).catch(function () {
|
||||
self.saveToOwnCloudError(true);
|
||||
});
|
||||
}
|
||||
|
|
@ -1159,7 +1159,7 @@
|
|||
self.saveToDropboxError(true);
|
||||
}
|
||||
}
|
||||
}).fail(function () {
|
||||
}).catch(function () {
|
||||
self.saveToDropboxError(true);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,7 +193,6 @@ cfg.paths.js = {
|
|||
'vendors/knockout-sortable/knockout-sortable.min.js',
|
||||
'vendors/ssm/ssm.min.js',
|
||||
'vendors/jua/jua.min.js',
|
||||
'vendors/Q/q.min.js',
|
||||
'vendors/opentip/opentip-jquery.min.js',
|
||||
'vendors/Autolinker/Autolinker.min.js',
|
||||
'vendors/lightGallery/dist/js/lightgallery.min.js',
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "RainLoop",
|
||||
"title": "RainLoop Webmail",
|
||||
"version": "1.10.1",
|
||||
"release": "117",
|
||||
"release": "118",
|
||||
"ownCloudPackageVersion": "4.17",
|
||||
"description": "Simple, modern & fast web-based email client",
|
||||
"homepage": "http://rainloop.net",
|
||||
|
|
|
|||
|
|
@ -1478,7 +1478,8 @@ class Actions
|
|||
'languages' => $this->GetLanguages(false),
|
||||
'languagesAdmin' => $this->GetLanguages(true),
|
||||
'attachmentsActions' => $aAttachmentsActions,
|
||||
'rsaPublicKey' => $sRsaPublicKey
|
||||
'rsaPublicKey' => $sRsaPublicKey,
|
||||
'openpgpPublicKeyServer' => $oConfig->Get('security', 'openpgp_public_key_server', '')
|
||||
), $bAdmin ? array(
|
||||
'adminPath' => \strtolower($oConfig->Get('security', 'admin_panel_key', 'admin')),
|
||||
'allowAdminPanel' => (bool) $oConfig->Get('security', 'allow_admin_panel', true),
|
||||
|
|
|
|||
|
|
@ -197,7 +197,10 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
|
||||
'custom_server_signature' => array('RainLoop'),
|
||||
'x_frame_options_header' => array(''),
|
||||
|
||||
'openpgp' => array(false),
|
||||
'openpgp_public_key_server' => array(''),
|
||||
|
||||
'use_rsa_encryption' => array(false),
|
||||
'admin_login' => array('admin', 'Login and password for web admin panel'),
|
||||
'admin_password' => array('12345'),
|
||||
|
|
@ -357,7 +360,7 @@ Enables caching in the system'),
|
|||
|
||||
'index' => array('v1', 'Additional caching key. If changed, cache is purged'),
|
||||
|
||||
'fast_cache_driver' => array('files', 'Can be: files, APC, memcache, redis'),
|
||||
'fast_cache_driver' => array('files', 'Can be: files, APC, memcache, redis (beta)'),
|
||||
'fast_cache_index' => array('v1', 'Additional caching key. If changed, fast cache is purged'),
|
||||
|
||||
'http' => array(true, 'Browser-level cache. If enabled, caching is maintainted without using files'),
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ module.exports = {
|
|||
'ssm': 'window.ssm',
|
||||
'key': 'window.key',
|
||||
'_': 'window._',
|
||||
'Q': 'window.Q',
|
||||
'Promise': 'window.Promise',
|
||||
'$': 'window.jQuery'
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue