mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Changed: StorageResultType to error result code
This commit is contained in:
parent
be3ef15f8e
commit
4a8d516123
33 changed files with 257 additions and 302 deletions
230
dev/App/User.js
230
dev/App/User.js
|
|
@ -5,7 +5,6 @@ import { isPosNumeric, delegateRunOnDestroy, mailToHelper } from 'Common/UtilsUs
|
|||
|
||||
import {
|
||||
Capa,
|
||||
StorageResultType,
|
||||
Notification,
|
||||
KeyState
|
||||
} from 'Common/Enums';
|
||||
|
|
@ -104,8 +103,8 @@ class AppUser extends AbstractApp {
|
|||
if (rl.hash.check()) {
|
||||
this.reload();
|
||||
}
|
||||
Remote.jsVersion((sResult, oData) => {
|
||||
if (StorageResultType.Success === sResult && oData && !oData.Result) {
|
||||
Remote.jsVersion((iError, oData) => {
|
||||
if (!iError && oData && !oData.Result) {
|
||||
this.reload();
|
||||
}
|
||||
}, Settings.app('version'));
|
||||
|
|
@ -182,23 +181,18 @@ class AppUser extends AbstractApp {
|
|||
}
|
||||
|
||||
MessageUserStore.listLoading(true);
|
||||
MessageUserStore.listError('');
|
||||
Remote.messageList(
|
||||
(sResult, oData, bCached) => {
|
||||
if (StorageResultType.Success === sResult && oData && oData.Result) {
|
||||
MessageUserStore.listError('');
|
||||
MessageUserStore.listLoading(false);
|
||||
|
||||
(iError, oData, bCached) => {
|
||||
if (!iError && oData && oData.Result) {
|
||||
MessageUserStore.setMessageList(oData, bCached);
|
||||
} else if (StorageResultType.Unload === sResult) {
|
||||
MessageUserStore.listError('');
|
||||
MessageUserStore.listLoading(false);
|
||||
} else if (StorageResultType.Abort !== sResult) {
|
||||
} else if (Remote.ABORT !== iError) {
|
||||
MessageUserStore.list([]);
|
||||
MessageUserStore.listLoading(false);
|
||||
MessageUserStore.listError(
|
||||
getNotification((oData && oData.ErrorCode) || Notification.CantGetMessageList)
|
||||
);
|
||||
}
|
||||
MessageUserStore.listLoading(false);
|
||||
},
|
||||
FolderUserStore.currentFolderFullNameRaw(),
|
||||
iOffset,
|
||||
|
|
@ -283,8 +277,8 @@ class AppUser extends AbstractApp {
|
|||
Remote.messagesDelete(this.moveOrDeleteResponseHelper, sFromFolderFullNameRaw, aUidForRemove);
|
||||
}
|
||||
|
||||
moveOrDeleteResponseHelper(sResult, oData) {
|
||||
if (StorageResultType.Success === sResult && FolderUserStore.currentFolder()) {
|
||||
moveOrDeleteResponseHelper(iError, oData) {
|
||||
if (!iError && FolderUserStore.currentFolder()) {
|
||||
if (oData && Array.isArray(oData.Result) && 2 === oData.Result.length) {
|
||||
setFolderHash(oData.Result[0], oData.Result[1]);
|
||||
} else {
|
||||
|
|
@ -480,11 +474,11 @@ class AppUser extends AbstractApp {
|
|||
AccountUserStore.loading(true);
|
||||
IdentityUserStore.loading(true);
|
||||
|
||||
Remote.accountsAndIdentities((sResult, oData) => {
|
||||
Remote.accountsAndIdentities((iError, oData) => {
|
||||
AccountUserStore.loading(false);
|
||||
IdentityUserStore.loading(false);
|
||||
|
||||
if (StorageResultType.Success === sResult && oData.Result) {
|
||||
if (!iError && oData.Result) {
|
||||
const counts = {},
|
||||
sAccountEmail = AccountUserStore.email();
|
||||
let parentEmail = SettingsGet('ParentEmail') || sAccountEmail;
|
||||
|
|
@ -529,10 +523,10 @@ class AppUser extends AbstractApp {
|
|||
templates() {
|
||||
TemplateUserStore.templates.loading(true);
|
||||
|
||||
Remote.templates((result, data) => {
|
||||
Remote.templates((iError, data) => {
|
||||
TemplateUserStore.templates.loading(false);
|
||||
|
||||
if (StorageResultType.Success === result && data.Result && Array.isArray(data.Result.Templates)) {
|
||||
if (!iError && data.Result && Array.isArray(data.Result.Templates)) {
|
||||
delegateRunOnDestroy(TemplateUserStore.templates());
|
||||
|
||||
TemplateUserStore.templates(
|
||||
|
|
@ -545,9 +539,9 @@ class AppUser extends AbstractApp {
|
|||
}
|
||||
|
||||
quota() {
|
||||
Remote.quota((result, data) => {
|
||||
Remote.quota((iError, data) => {
|
||||
if (
|
||||
StorageResultType.Success === result &&
|
||||
!iError &&
|
||||
data &&
|
||||
data.Result &&
|
||||
Array.isArray(data.Result) &&
|
||||
|
|
@ -567,70 +561,68 @@ class AppUser extends AbstractApp {
|
|||
folderInformation(folder, list) {
|
||||
if (folder && folder.trim()) {
|
||||
Remote.folderInformation(
|
||||
(result, data) => {
|
||||
if (StorageResultType.Success === result) {
|
||||
if (data && data.Result && data.Result.Hash && data.Result.Folder) {
|
||||
let uid = '',
|
||||
check = false,
|
||||
unreadCountChange = false;
|
||||
(iError, data) => {
|
||||
if (!iError && data && data.Result && data.Result.Hash && data.Result.Folder) {
|
||||
let uid = '',
|
||||
check = false,
|
||||
unreadCountChange = false;
|
||||
|
||||
const folderFromCache = getFolderFromCacheList(data.Result.Folder);
|
||||
if (folderFromCache) {
|
||||
folderFromCache.interval = Date.now();
|
||||
const folderFromCache = getFolderFromCacheList(data.Result.Folder);
|
||||
if (folderFromCache) {
|
||||
folderFromCache.interval = Date.now();
|
||||
|
||||
if (data.Result.Hash) {
|
||||
setFolderHash(data.Result.Folder, data.Result.Hash);
|
||||
if (data.Result.Hash) {
|
||||
setFolderHash(data.Result.Folder, data.Result.Hash);
|
||||
}
|
||||
|
||||
if (null != data.Result.MessageCount) {
|
||||
folderFromCache.messageCountAll(data.Result.MessageCount);
|
||||
}
|
||||
|
||||
if (null != data.Result.MessageUnseenCount) {
|
||||
if (pInt(folderFromCache.messageCountUnread()) !== pInt(data.Result.MessageUnseenCount)) {
|
||||
unreadCountChange = true;
|
||||
}
|
||||
|
||||
if (null != data.Result.MessageCount) {
|
||||
folderFromCache.messageCountAll(data.Result.MessageCount);
|
||||
}
|
||||
folderFromCache.messageCountUnread(data.Result.MessageUnseenCount);
|
||||
}
|
||||
|
||||
if (null != data.Result.MessageUnseenCount) {
|
||||
if (pInt(folderFromCache.messageCountUnread()) !== pInt(data.Result.MessageUnseenCount)) {
|
||||
unreadCountChange = true;
|
||||
}
|
||||
if (unreadCountChange) {
|
||||
MessageFlagsCache.clearFolder(folderFromCache.fullNameRaw);
|
||||
}
|
||||
|
||||
folderFromCache.messageCountUnread(data.Result.MessageUnseenCount);
|
||||
}
|
||||
|
||||
if (unreadCountChange) {
|
||||
MessageFlagsCache.clearFolder(folderFromCache.fullNameRaw);
|
||||
}
|
||||
|
||||
if (data.Result.Flags) {
|
||||
for (uid in data.Result.Flags) {
|
||||
if (Object.prototype.hasOwnProperty.call(data.Result.Flags, uid)) {
|
||||
check = true;
|
||||
const flags = data.Result.Flags[uid];
|
||||
MessageFlagsCache.storeByFolderAndUid(folderFromCache.fullNameRaw, uid.toString(), [
|
||||
!!flags.IsUnseen,
|
||||
!!flags.IsFlagged,
|
||||
!!flags.IsAnswered,
|
||||
!!flags.IsForwarded,
|
||||
!!flags.IsReadReceipt
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (check) {
|
||||
this.reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||
if (data.Result.Flags) {
|
||||
for (uid in data.Result.Flags) {
|
||||
if (Object.prototype.hasOwnProperty.call(data.Result.Flags, uid)) {
|
||||
check = true;
|
||||
const flags = data.Result.Flags[uid];
|
||||
MessageFlagsCache.storeByFolderAndUid(folderFromCache.fullNameRaw, uid.toString(), [
|
||||
!!flags.IsUnseen,
|
||||
!!flags.IsFlagged,
|
||||
!!flags.IsAnswered,
|
||||
!!flags.IsForwarded,
|
||||
!!flags.IsReadReceipt
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
MessageUserStore.initUidNextAndNewMessages(
|
||||
folderFromCache.fullNameRaw,
|
||||
data.Result.UidNext,
|
||||
data.Result.NewMessages
|
||||
);
|
||||
if (check) {
|
||||
this.reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||
}
|
||||
}
|
||||
|
||||
const hash = getFolderHash(data.Result.Folder);
|
||||
if (!hash || unreadCountChange || data.Result.Hash !== hash) {
|
||||
if (folderFromCache.fullNameRaw === FolderUserStore.currentFolderFullNameRaw()) {
|
||||
this.reloadMessageList();
|
||||
} else if (getFolderInboxName() === folderFromCache.fullNameRaw) {
|
||||
this.recacheInboxMessageList();
|
||||
}
|
||||
MessageUserStore.initUidNextAndNewMessages(
|
||||
folderFromCache.fullNameRaw,
|
||||
data.Result.UidNext,
|
||||
data.Result.NewMessages
|
||||
);
|
||||
|
||||
const hash = getFolderHash(data.Result.Folder);
|
||||
if (!hash || unreadCountChange || data.Result.Hash !== hash) {
|
||||
if (folderFromCache.fullNameRaw === FolderUserStore.currentFolderFullNameRaw()) {
|
||||
this.reloadMessageList();
|
||||
} else if (getFolderInboxName() === folderFromCache.fullNameRaw) {
|
||||
this.recacheInboxMessageList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -648,53 +640,51 @@ class AppUser extends AbstractApp {
|
|||
folderInformationMultiply(boot = false) {
|
||||
const folders = FolderUserStore.getNextFolderNames();
|
||||
if (Array.isNotEmpty(folders)) {
|
||||
Remote.folderInformationMultiply((sResult, oData) => {
|
||||
if (StorageResultType.Success === sResult) {
|
||||
if (oData && oData.Result && oData.Result.List && Array.isNotEmpty(oData.Result.List)) {
|
||||
const utc = Date.now();
|
||||
oData.Result.List.forEach(item => {
|
||||
const hash = getFolderHash(item.Folder),
|
||||
folder = getFolderFromCacheList(item.Folder);
|
||||
let unreadCountChange = false;
|
||||
Remote.folderInformationMultiply((iError, oData) => {
|
||||
if (!iError && oData && oData.Result && oData.Result.List && Array.isNotEmpty(oData.Result.List)) {
|
||||
const utc = Date.now();
|
||||
oData.Result.List.forEach(item => {
|
||||
const hash = getFolderHash(item.Folder),
|
||||
folder = getFolderFromCacheList(item.Folder);
|
||||
let unreadCountChange = false;
|
||||
|
||||
if (folder) {
|
||||
folder.interval = utc;
|
||||
if (folder) {
|
||||
folder.interval = utc;
|
||||
|
||||
if (item.Hash) {
|
||||
setFolderHash(item.Folder, item.Hash);
|
||||
}
|
||||
|
||||
if (null != item.MessageCount) {
|
||||
folder.messageCountAll(item.MessageCount);
|
||||
}
|
||||
|
||||
if (null != item.MessageUnseenCount) {
|
||||
if (pInt(folder.messageCountUnread()) !== pInt(item.MessageUnseenCount)) {
|
||||
unreadCountChange = true;
|
||||
}
|
||||
|
||||
folder.messageCountUnread(item.MessageUnseenCount);
|
||||
}
|
||||
|
||||
if (unreadCountChange) {
|
||||
MessageFlagsCache.clearFolder(folder.fullNameRaw);
|
||||
}
|
||||
|
||||
if (!hash || item.Hash !== hash) {
|
||||
if (folder.fullNameRaw === FolderUserStore.currentFolderFullNameRaw()) {
|
||||
this.reloadMessageList();
|
||||
}
|
||||
} else if (unreadCountChange
|
||||
&& folder.fullNameRaw === FolderUserStore.currentFolderFullNameRaw()
|
||||
&& MessageUserStore.list.length) {
|
||||
this.folderInformation(folder.fullNameRaw, MessageUserStore.list());
|
||||
}
|
||||
if (item.Hash) {
|
||||
setFolderHash(item.Folder, item.Hash);
|
||||
}
|
||||
});
|
||||
|
||||
if (boot) {
|
||||
setTimeout(() => this.folderInformationMultiply(true), 2000);
|
||||
if (null != item.MessageCount) {
|
||||
folder.messageCountAll(item.MessageCount);
|
||||
}
|
||||
|
||||
if (null != item.MessageUnseenCount) {
|
||||
if (pInt(folder.messageCountUnread()) !== pInt(item.MessageUnseenCount)) {
|
||||
unreadCountChange = true;
|
||||
}
|
||||
|
||||
folder.messageCountUnread(item.MessageUnseenCount);
|
||||
}
|
||||
|
||||
if (unreadCountChange) {
|
||||
MessageFlagsCache.clearFolder(folder.fullNameRaw);
|
||||
}
|
||||
|
||||
if (!hash || item.Hash !== hash) {
|
||||
if (folder.fullNameRaw === FolderUserStore.currentFolderFullNameRaw()) {
|
||||
this.reloadMessageList();
|
||||
}
|
||||
} else if (unreadCountChange
|
||||
&& folder.fullNameRaw === FolderUserStore.currentFolderFullNameRaw()
|
||||
&& MessageUserStore.list.length) {
|
||||
this.folderInformation(folder.fullNameRaw, MessageUserStore.list());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (boot) {
|
||||
setTimeout(() => this.folderInformationMultiply(true), 2000);
|
||||
}
|
||||
}
|
||||
}, folders);
|
||||
|
|
@ -773,12 +763,12 @@ class AppUser extends AbstractApp {
|
|||
* @param {Function} autocompleteCallback
|
||||
*/
|
||||
getAutocomplete(query, autocompleteCallback) {
|
||||
Remote.suggestions((result, data) => {
|
||||
if (StorageResultType.Success === result && data && Array.isArray(data.Result)) {
|
||||
Remote.suggestions((iError, data) => {
|
||||
if (!iError && data && Array.isArray(data.Result)) {
|
||||
autocompleteCallback(
|
||||
data.Result.map(item => (item && item[0] ? new EmailModel(item[0], item[1]) : null)).filter(v => v)
|
||||
);
|
||||
} else if (StorageResultType.Abort !== result) {
|
||||
} else if (Remote.ABORT !== iError) {
|
||||
autocompleteCallback([]);
|
||||
}
|
||||
}, query);
|
||||
|
|
|
|||
|
|
@ -1,15 +1,5 @@
|
|||
/* eslint quote-props: 0 */
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
export const StorageResultType = {
|
||||
Success: 'success',
|
||||
Abort: 'abort',
|
||||
Error: 'error',
|
||||
Unload: 'unload'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
|
|
@ -142,7 +132,6 @@ export const Notification = {
|
|||
InvalidInputArgument: 903,
|
||||
|
||||
JsonFalse: 950,
|
||||
JsonAbort: 951,
|
||||
JsonParse: 952,
|
||||
// JsonTimeout: 953,
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { Settings } from 'Common/Globals';
|
||||
import { pInt, pString } from 'Common/Utils';
|
||||
import { serverRequest } from 'Common/Links';
|
||||
|
||||
let iJsonErrorCount = 0,
|
||||
iTokenErrorCount = 0,
|
||||
bUnload = false;
|
||||
iTokenErrorCount = 0;
|
||||
|
||||
const getURL = (add = '') => serverRequest('Json') + add,
|
||||
|
||||
|
|
@ -71,8 +70,6 @@ fetchJSON = (action, sGetAdd, params, timeout, jsonCallback) => {
|
|||
return rl.fetchJSON(getURL(sGetAdd), init, sGetAdd ? null : params).then(jsonCallback);
|
||||
};
|
||||
|
||||
addEventListener('unload', () => bUnload = true);
|
||||
|
||||
export class AbstractFetchRemote
|
||||
{
|
||||
abort(sAction, bClearOnly) {
|
||||
|
|
@ -110,57 +107,34 @@ export class AbstractFetchRemote
|
|||
updateToken(data);
|
||||
}
|
||||
|
||||
let sType = 'success';
|
||||
let iError = 0;
|
||||
if (sAction && oRequests[sAction]) {
|
||||
if (oRequests[sAction].__aborted) {
|
||||
sType = 'abort';
|
||||
iError = 2;
|
||||
}
|
||||
abort(sAction, true);
|
||||
}
|
||||
|
||||
const fCall = () => {
|
||||
if (StorageResultType.Success !== sType && bUnload) {
|
||||
sType = StorageResultType.Unload;
|
||||
if (!iError && data) {
|
||||
if (data.Result) {
|
||||
iJsonErrorCount = iTokenErrorCount = 0;
|
||||
} else {
|
||||
checkResponseError(data);
|
||||
}
|
||||
|
||||
if (StorageResultType.Success === sType && data) {
|
||||
if (data.Result) {
|
||||
iJsonErrorCount = iTokenErrorCount = 0;
|
||||
} else {
|
||||
checkResponseError(data);
|
||||
}
|
||||
}
|
||||
|
||||
if (fCallback) {
|
||||
fCallback(
|
||||
sType,
|
||||
StorageResultType.Success === sType ? data : null,
|
||||
cached,
|
||||
sAction,
|
||||
params
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
switch (sType) {
|
||||
case 'success':
|
||||
sType = StorageResultType.Success;
|
||||
fCall();
|
||||
break;
|
||||
case 'abort':
|
||||
sType = StorageResultType.Abort;
|
||||
fCall();
|
||||
break;
|
||||
default:
|
||||
sType = StorageResultType.Error;
|
||||
setTimeout(fCall, 300);
|
||||
break;
|
||||
}
|
||||
|
||||
fCallback && fCallback(
|
||||
iError,
|
||||
data,
|
||||
cached,
|
||||
sAction,
|
||||
params
|
||||
);
|
||||
}
|
||||
)
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
fCallback && fCallback(err.name == 'AbortError' ? Notification.JsonAbort : StorageResultType.Error);
|
||||
fCallback && fCallback(err.name == 'AbortError' ? 2 : 1);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -220,13 +194,13 @@ export class AbstractFetchRemote
|
|||
// backward capability
|
||||
switch (true) {
|
||||
case 'success' === textStatus && data && data.Result && action === data.Action:
|
||||
type = StorageResultType.Success;
|
||||
type = AbstractFetchRemote.SUCCESS;
|
||||
break;
|
||||
case 'abort' === textStatus && (!data || !data.__aborted__):
|
||||
type = StorageResultType.Abort;
|
||||
type = AbstractFetchRemote.ABORT;
|
||||
break;
|
||||
default:
|
||||
type = StorageResultType.Error;
|
||||
type = AbstractFetchRemote.ERROR;
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
|
@ -234,7 +208,7 @@ export class AbstractFetchRemote
|
|||
|
||||
if (!data.Result || action !== data.Action) {
|
||||
checkResponseError(data);
|
||||
const err = data ? data.ErrorCode : null;
|
||||
const err = data ? data.ErrorCode : 0;
|
||||
return Promise.reject(err || Notification.JsonFalse);
|
||||
}
|
||||
|
||||
|
|
@ -243,3 +217,9 @@ export class AbstractFetchRemote
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
Object.assign(AbstractFetchRemote.prototype, {
|
||||
SUCCESS : 0,
|
||||
ERROR : 1,
|
||||
ABORT : 2
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { SaveSettingsStep, StorageResultType } from 'Common/Enums';
|
||||
import { SaveSettingsStep } from 'Common/Enums';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
import { settingsSaveHelperSimpleFunction, defaultOptionsAfterRender } from 'Common/Utils';
|
||||
|
||||
|
|
@ -93,12 +93,12 @@ export class ContactsAdminSettings {
|
|||
});
|
||||
}
|
||||
|
||||
onTestContactsResponse(result, data) {
|
||||
onTestContactsResponse(iError, data) {
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
this.testContactsErrorMessage('');
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result && data.Result.Result) {
|
||||
if (!iError && data && data.Result && data.Result.Result) {
|
||||
this.testContactsSuccess(true);
|
||||
} else {
|
||||
this.testContactsError(true);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { StorageResultType } from 'Common/Enums';
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
|
||||
import { DomainAdminStore } from 'Stores/Admin/Domain';
|
||||
|
|
@ -46,8 +45,8 @@ export class DomainsAdminSettings {
|
|||
DomainAdminStore.fetch();
|
||||
}
|
||||
|
||||
onDomainLoadRequest(sResult, oData) {
|
||||
if (StorageResultType.Success === sResult && oData && oData.Result) {
|
||||
onDomainLoadRequest(iError, oData) {
|
||||
if (!iError && oData && oData.Result) {
|
||||
showScreenPopup(DomainPopupView, [oData.Result]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
import { PackageAdminStore } from 'Stores/Admin/Package';
|
||||
|
|
@ -34,8 +34,8 @@ export class PackagesAdminSettings {
|
|||
}
|
||||
|
||||
requestHelper(packageToRequest, install) {
|
||||
return (result, data) => {
|
||||
if (StorageResultType.Success !== result || !data || !data.Result) {
|
||||
return (iError, data) => {
|
||||
if (iError || !data || !data.Result) {
|
||||
if (data && data.ErrorCode) {
|
||||
this.packagesError(getNotification(data.ErrorCode));
|
||||
} else {
|
||||
|
|
@ -52,7 +52,7 @@ export class PackagesAdminSettings {
|
|||
}
|
||||
});
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result && data.Result.Reload) {
|
||||
if (!iError && data && data.Result && data.Result.Reload) {
|
||||
location.reload();
|
||||
} else {
|
||||
PackageAdminStore.fetch();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
|
|
@ -53,14 +53,14 @@ export class PluginsAdminSettings {
|
|||
PluginAdminStore.fetch();
|
||||
}
|
||||
|
||||
onPluginLoadRequest(result, data) {
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
onPluginLoadRequest(iError, data) {
|
||||
if (!iError && data && data.Result) {
|
||||
showScreenPopup(PluginPopupView, [data.Result]);
|
||||
}
|
||||
}
|
||||
|
||||
onPluginDisableRequest(result, data) {
|
||||
if (StorageResultType.Success === result && data) {
|
||||
onPluginDisableRequest(iError, data) {
|
||||
if (!iError && data) {
|
||||
if (!data.Result && data.ErrorCode) {
|
||||
if (Notification.UnsupportedPluginPackage === data.ErrorCode && data.ErrorMessage && data.ErrorMessage) {
|
||||
PluginAdminStore.error(data.ErrorMessage);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { StorageResultType } from 'Common/Enums';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
|
||||
import { AppAdminStore } from 'Stores/Admin/App';
|
||||
|
|
@ -112,8 +111,8 @@ export class SecurityAdminSettings {
|
|||
}, 50);
|
||||
}
|
||||
|
||||
onNewAdminPasswordResponse(result, data) {
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
onNewAdminPasswordResponse(iError, data) {
|
||||
if (!iError && data && data.Result) {
|
||||
this.adminPassword('');
|
||||
this.adminPasswordNew('');
|
||||
this.adminPasswordNew2('');
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { Capa, StorageResultType } from 'Common/Enums';
|
||||
import { Capa } from 'Common/Enums';
|
||||
import { Settings } from 'Common/Globals';
|
||||
|
||||
import { AccountUserStore } from 'Stores/User/Account';
|
||||
|
|
@ -53,8 +53,8 @@ export class AccountsUserSettings {
|
|||
if (accountToRemove) {
|
||||
this.accounts.remove((account) => accountToRemove === account);
|
||||
|
||||
Remote.accountDelete((result, data) => {
|
||||
if (StorageResultType.Success === result && data && data.Result && data.Reload) {
|
||||
Remote.accountDelete((iError, data) => {
|
||||
if (!iError && data && data.Result && data.Reload) {
|
||||
rl.route.root();
|
||||
setTimeout(() => location.reload(), 1);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { delegateRunOnDestroy } from 'Common/UtilsUser';
|
||||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
import { SieveUserStore } from 'Stores/User/Sieve';
|
||||
|
|
@ -36,11 +36,11 @@ export class FiltersUserSettings {
|
|||
this.loading(true);
|
||||
this.serverError(false);
|
||||
|
||||
Remote.filtersGet((result, data) => {
|
||||
Remote.filtersGet((iError, data) => {
|
||||
this.loading(false);
|
||||
this.scripts([]);
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
if (!iError && data && data.Result) {
|
||||
SieveUserStore.capa(data.Result.Capa);
|
||||
/*
|
||||
this.scripts(
|
||||
|
|
@ -73,7 +73,7 @@ export class FiltersUserSettings {
|
|||
this.serverError(false);
|
||||
Remote.filtersScriptDelete(
|
||||
(result, data) => {
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
if (Remote.SUCCESS === result && data && data.Result) {
|
||||
this.scripts.remove(script);
|
||||
delegateRunOnDestroy(script);
|
||||
} else {
|
||||
|
|
@ -92,7 +92,7 @@ export class FiltersUserSettings {
|
|||
this.serverError(false);
|
||||
Remote.filtersScriptActivate(
|
||||
(result, data) => {
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
if (Remote.SUCCESS === result && data && data.Result) {
|
||||
this.scripts.forEach(script => script.active(script.name() === name));
|
||||
} else {
|
||||
this.setError((data && data.ErrorCode)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import ko from 'ko';
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
import { StorageResultType } from 'Common/Enums';
|
||||
|
||||
export const DomainAdminStore = ko.observableArray();
|
||||
|
||||
|
|
@ -8,9 +7,9 @@ DomainAdminStore.loading = ko.observable(false);
|
|||
|
||||
DomainAdminStore.fetch = () => {
|
||||
DomainAdminStore.loading(true);
|
||||
Remote.domainList((result, data) => {
|
||||
Remote.domainList((iError, data) => {
|
||||
DomainAdminStore.loading(false);
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
if (!iError && data && data.Result) {
|
||||
DomainAdminStore(
|
||||
Object.entries(data.Result).map(([name, [enabled, alias]]) => ({
|
||||
name: name,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import ko from 'ko';
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
import { StorageResultType } from 'Common/Enums';
|
||||
|
||||
export const PackageAdminStore = ko.observableArray();
|
||||
|
||||
|
|
@ -10,9 +9,9 @@ PackageAdminStore.loading = ko.observable(false);
|
|||
|
||||
PackageAdminStore.fetch = () => {
|
||||
PackageAdminStore.loading(true);
|
||||
Remote.packagesList((result, data) => {
|
||||
Remote.packagesList((iError, data) => {
|
||||
PackageAdminStore.loading(false);
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
if (!iError && data && data.Result) {
|
||||
PackageAdminStore.real(!!data.Result.Real);
|
||||
|
||||
let list = [];
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import ko from 'ko';
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
import { StorageResultType } from 'Common/Enums';
|
||||
|
||||
export const PluginAdminStore = ko.observableArray();
|
||||
|
||||
|
|
@ -10,9 +9,9 @@ PluginAdminStore.error = ko.observable('');
|
|||
|
||||
PluginAdminStore.fetch = () => {
|
||||
PluginAdminStore.loading(true);
|
||||
Remote.pluginList((result, data) => {
|
||||
Remote.pluginList((iError, data) => {
|
||||
PluginAdminStore.loading(false);
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
if (!iError && data && data.Result) {
|
||||
PluginAdminStore(
|
||||
data.Result.map(item => ({
|
||||
name: item.Name,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { Focused, MessageSetAction } from 'Common/EnumsUser';
|
||||
import { doc, elementById } from 'Common/Globals';
|
||||
import { pInt, pString } from 'Common/Utils';
|
||||
|
|
@ -638,13 +638,10 @@ export const MessageUserStore = new class {
|
|||
* @param {FetchJsonDefaultResponse} oData
|
||||
* @param {boolean} bCached
|
||||
*/
|
||||
onMessageResponse(sResult, oData, bCached) {
|
||||
if (StorageResultType.Success === sResult && oData && oData.Result) {
|
||||
onMessageResponse(iError, oData, bCached) {
|
||||
if (!iError && oData && oData.Result) {
|
||||
this.setMessage(oData, bCached);
|
||||
} else if (StorageResultType.Unload === sResult) {
|
||||
this.message(null);
|
||||
this.messageError('');
|
||||
} else if (StorageResultType.Abort !== sResult) {
|
||||
} else if (Remote.ABORT !== iError) {
|
||||
this.message(null);
|
||||
this.messageError(
|
||||
oData && oData.ErrorCode ? getNotification(oData.ErrorCode) : getNotification(Notification.UnknownError)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { Settings } from 'Common/Globals';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
|
|
@ -59,8 +59,8 @@ class LoginAdminView extends AbstractViewCenter {
|
|||
this.submitRequest(true);
|
||||
|
||||
Remote.adminLogin(
|
||||
(sResult, oData) => {
|
||||
if (StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action) {
|
||||
(iError, oData) => {
|
||||
if (!iError && oData && 'AdminLogin' === oData.Action) {
|
||||
if (oData.Result) {
|
||||
rl.route.reload();
|
||||
} else if (oData.ErrorCode) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
|
|
@ -46,9 +46,9 @@ class AccountPopupView extends AbstractViewPopup {
|
|||
this.submitRequest(true);
|
||||
|
||||
Remote.accountSetup(
|
||||
(result, data) => {
|
||||
(iError, data) => {
|
||||
this.submitRequest(false);
|
||||
if (StorageResultType.Success === result && data) {
|
||||
if (!iError && data) {
|
||||
if (data.Result) {
|
||||
rl.app.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import ko from 'ko';
|
|||
|
||||
import {
|
||||
KeyState,
|
||||
StorageResultType,
|
||||
Notification,
|
||||
UploadErrorCode
|
||||
} from 'Common/Enums';
|
||||
|
|
@ -602,13 +601,13 @@ class ComposePopupView extends AbstractViewPopup {
|
|||
}
|
||||
}
|
||||
|
||||
sendMessageResponse(statusResult, data) {
|
||||
sendMessageResponse(iError, data) {
|
||||
let result = false,
|
||||
message = '';
|
||||
|
||||
this.sending(false);
|
||||
|
||||
if (StorageResultType.Success === statusResult && data && data.Result) {
|
||||
if (!iError && data && data.Result) {
|
||||
result = true;
|
||||
this.modalVisibility() && this.closeCommand && this.closeCommand();
|
||||
}
|
||||
|
|
@ -631,12 +630,12 @@ class ComposePopupView extends AbstractViewPopup {
|
|||
this.reloadDraftFolder();
|
||||
}
|
||||
|
||||
saveMessageResponse(statusResult, oData) {
|
||||
saveMessageResponse(iError, oData) {
|
||||
let result = false;
|
||||
|
||||
this.saving(false);
|
||||
|
||||
if (StorageResultType.Success === statusResult && oData && oData.Result) {
|
||||
if (!iError && oData && oData.Result) {
|
||||
if (oData.Result.NewFolder && oData.Result.NewUid) {
|
||||
result = true;
|
||||
|
||||
|
|
@ -1064,8 +1063,8 @@ class ComposePopupView extends AbstractViewPopup {
|
|||
|
||||
const downloads = this.getAttachmentsDownloadsForUpload();
|
||||
if (isNonEmptyArray(downloads)) {
|
||||
Remote.messageUploadAttachments((sResult, oData) => {
|
||||
if (StorageResultType.Success === sResult && oData && oData.Result) {
|
||||
Remote.messageUploadAttachments((iError, oData) => {
|
||||
if (!iError && oData && oData.Result) {
|
||||
Object.entries(oData.Result).forEach(([tempName, id]) => {
|
||||
const attachment = this.getAttachmentById(id);
|
||||
if (attachment) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import ko from 'ko';
|
|||
|
||||
import {
|
||||
SaveSettingsStep,
|
||||
StorageResultType,
|
||||
Notification,
|
||||
KeyState
|
||||
} from 'Common/Enums';
|
||||
|
|
@ -224,12 +223,12 @@ class ContactsPopupView extends AbstractViewPopup {
|
|||
const requestUid = Jua.randomId();
|
||||
|
||||
Remote.contactSave(
|
||||
(sResult, oData) => {
|
||||
(iError, oData) => {
|
||||
let res = false;
|
||||
this.viewSaving(false);
|
||||
|
||||
if (
|
||||
StorageResultType.Success === sResult &&
|
||||
!iError &&
|
||||
oData &&
|
||||
oData.Result &&
|
||||
oData.Result.RequestUid === requestUid &&
|
||||
|
|
@ -259,8 +258,8 @@ class ContactsPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
syncCommand() {
|
||||
rl.app.contactsSync((result, data) => {
|
||||
if (StorageResultType.Success !== result || !data || !data.Result) {
|
||||
rl.app.contactsSync((iError, data) => {
|
||||
if (iError || !data || !data.Result) {
|
||||
alert(getNotification(data && data.ErrorCode ? data.ErrorCode : Notification.ContactsSyncError));
|
||||
}
|
||||
|
||||
|
|
@ -398,11 +397,11 @@ class ContactsPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {string} sResult
|
||||
* @param {int} iError
|
||||
* @param {FetchJsonDefaultResponse} oData
|
||||
*/
|
||||
deleteResponse(sResult, oData) {
|
||||
if (500 < (StorageResultType.Success === sResult && oData && oData.Time ? pInt(oData.Time) : 0)) {
|
||||
deleteResponse(iError, oData) {
|
||||
if (500 < (!iError && oData && oData.Time ? pInt(oData.Time) : 0)) {
|
||||
this.reloadContactList(this.bDropPageAfterDelete);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
|
|
@ -460,11 +459,11 @@ class ContactsPopupView extends AbstractViewPopup {
|
|||
|
||||
ContactUserStore.loading(true);
|
||||
Remote.contacts(
|
||||
(result, data) => {
|
||||
(iError, data) => {
|
||||
let count = 0,
|
||||
list = [];
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result && data.Result.List) {
|
||||
if (!iError && data && data.Result && data.Result.List) {
|
||||
if (Array.isNotEmpty(data.Result.List)) {
|
||||
data.Result.List.forEach(item => {
|
||||
item = ContactModel.reviveFromJson(item);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { pInt, pString } from 'Common/Utils';
|
||||
import { i18n } from 'Common/Translator';
|
||||
|
||||
|
|
@ -205,9 +205,9 @@ class DomainPopupView extends AbstractViewPopup {
|
|||
this.clearTesting();
|
||||
}
|
||||
|
||||
onTestConnectionResponse(sResult, oData) {
|
||||
onTestConnectionResponse(iError, oData) {
|
||||
this.testing(false);
|
||||
if (StorageResultType.Success === sResult && oData.Result) {
|
||||
if (!iError && oData.Result) {
|
||||
let bImap = false,
|
||||
bSieve = false;
|
||||
|
||||
|
|
@ -248,9 +248,9 @@ class DomainPopupView extends AbstractViewPopup {
|
|||
}
|
||||
}
|
||||
|
||||
onDomainCreateOrSaveResponse(sResult, oData) {
|
||||
onDomainCreateOrSaveResponse(iError, oData) {
|
||||
this.saving(false);
|
||||
if (StorageResultType.Success === sResult && oData) {
|
||||
if (!iError && oData) {
|
||||
if (oData.Result) {
|
||||
DomainAdminStore.fetch();
|
||||
this.closeCommand();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { i18n } from 'Common/Translator';
|
||||
|
||||
import { DomainAdminStore } from 'Stores/Admin/Domain';
|
||||
|
|
@ -41,9 +41,9 @@ class DomainAliasPopupView extends AbstractViewPopup {
|
|||
Remote.createDomainAlias(this.onDomainAliasCreateOrSaveResponse, this.name(), this.alias());
|
||||
}
|
||||
|
||||
onDomainAliasCreateOrSaveResponse(result, data) {
|
||||
onDomainAliasCreateOrSaveResponse(iError, data) {
|
||||
this.saving(false);
|
||||
if (StorageResultType.Success === result && data) {
|
||||
if (!iError && data) {
|
||||
if (data.Result) {
|
||||
DomainAdminStore.fetch();
|
||||
this.closeCommand();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { i18n, getNotification } from 'Common/Translator';
|
||||
import { setFolderHash } from 'Common/Cache';
|
||||
|
||||
|
|
@ -54,9 +54,9 @@ class FolderClearPopupView extends AbstractViewPopup {
|
|||
|
||||
setFolderHash(folderToClear.fullNameRaw, '');
|
||||
|
||||
Remote.folderClear((result, data) => {
|
||||
Remote.folderClear((iError, data) => {
|
||||
this.clearingProcess(false);
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
if (!iError && data && data.Result) {
|
||||
rl.app.reloadMessageList(true);
|
||||
this.cancelCommand();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
|
|
@ -96,9 +96,9 @@ class IdentityPopupView extends AbstractViewPopup {
|
|||
this.submitRequest(true);
|
||||
|
||||
Remote.identityUpdate(
|
||||
(result, data) => {
|
||||
(iError, data) => {
|
||||
this.submitRequest(false);
|
||||
if (StorageResultType.Success === result && data) {
|
||||
if (!iError && data) {
|
||||
if (data.Result) {
|
||||
rl.app.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { KeyState, StorageResultType, Notification } from 'Common/Enums';
|
||||
import { KeyState, Notification } from 'Common/Enums';
|
||||
import { getNotification, i18n } from 'Common/Translator';
|
||||
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
|
|
@ -52,8 +52,8 @@ class PluginPopupView extends AbstractViewPopup {
|
|||
Remote.pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, list);
|
||||
}
|
||||
|
||||
onPluginSettingsUpdateResponse(result, data) {
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
onPluginSettingsUpdateResponse(iError, data) {
|
||||
if (!iError && data && data.Result) {
|
||||
this.cancelCommand();
|
||||
} else {
|
||||
this.saveError('');
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { delegateRunOnDestroy } from 'Common/UtilsUser';
|
||||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
import { i18nToNodes } from 'Common/Translator';
|
||||
|
||||
|
|
@ -58,10 +58,10 @@ class SieveScriptPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
Remote.filtersScriptSave(
|
||||
(result, data) => {
|
||||
(iError, data) => {
|
||||
self.saving = false;
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
if (!iError && data && data.Result) {
|
||||
script.exists() || SieveUserStore.scripts.push(script);
|
||||
script.exists(true);
|
||||
script.hasChanges(false);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
import { HtmlEditor } from 'Common/Html';
|
||||
|
||||
|
|
@ -53,9 +53,9 @@ class TemplatePopupView extends AbstractViewPopup {
|
|||
this.submitRequest(true);
|
||||
|
||||
Remote.templateSetup(
|
||||
(result, data) => {
|
||||
(iError, data) => {
|
||||
this.submitRequest(false);
|
||||
if (StorageResultType.Success === result && data) {
|
||||
if (!iError && data) {
|
||||
if (data.Result) {
|
||||
rl.app.templates();
|
||||
this.cancelCommand();
|
||||
|
|
@ -124,11 +124,11 @@ class TemplatePopupView extends AbstractViewPopup {
|
|||
this.bodyLoading(true);
|
||||
this.bodyError(false);
|
||||
|
||||
Remote.templateGetById((result, data) => {
|
||||
Remote.templateGetById((iError, data) => {
|
||||
this.bodyLoading(false);
|
||||
|
||||
if (
|
||||
StorageResultType.Success === result &&
|
||||
!iError &&
|
||||
data &&
|
||||
TemplateModel.validJson(data.Result) &&
|
||||
null != data.Result.Body
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Capa, StorageResultType } from 'Common/Enums';
|
||||
import { Capa } from 'Common/Enums';
|
||||
import { Settings } from 'Common/Globals';
|
||||
import { pString } from 'Common/Utils';
|
||||
import { i18n, trigger as translatorTrigger } from 'Common/Translator';
|
||||
|
|
@ -43,8 +43,8 @@ class TwoFactorConfigurationPopupView extends AbstractViewPopup {
|
|||
value = !!value;
|
||||
if (value && this.twoFactorTested()) {
|
||||
this.viewEnable_(value);
|
||||
Remote.enableTwoFactor((result, data) => {
|
||||
if (StorageResultType.Success !== result || !data || !data.Result) {
|
||||
Remote.enableTwoFactor((iError, data) => {
|
||||
if (iError || !data || !data.Result) {
|
||||
this.viewEnable_(false);
|
||||
}
|
||||
}, true);
|
||||
|
|
@ -53,8 +53,8 @@ class TwoFactorConfigurationPopupView extends AbstractViewPopup {
|
|||
this.viewEnable_(value);
|
||||
}
|
||||
|
||||
Remote.enableTwoFactor((result, data) => {
|
||||
if (StorageResultType.Success !== result || !data || !data.Result) {
|
||||
Remote.enableTwoFactor((iError, data) => {
|
||||
if (iError || !data || !data.Result) {
|
||||
this.viewEnable_(false);
|
||||
}
|
||||
}, false);
|
||||
|
|
@ -148,11 +148,11 @@ class TwoFactorConfigurationPopupView extends AbstractViewPopup {
|
|||
);
|
||||
}
|
||||
|
||||
onResult(sResult, oData) {
|
||||
onResult(iError, oData) {
|
||||
this.processing(false);
|
||||
this.clearing(false);
|
||||
|
||||
if (StorageResultType.Success === sResult && oData && oData.Result) {
|
||||
if (!iError && oData && oData.Result) {
|
||||
this.viewUser(pString(oData.Result.User));
|
||||
this.viewEnable_(!!oData.Result.Enable);
|
||||
this.twoFactorStatus(!!oData.Result.IsSet);
|
||||
|
|
@ -176,10 +176,10 @@ class TwoFactorConfigurationPopupView extends AbstractViewPopup {
|
|||
}
|
||||
}
|
||||
|
||||
onShowSecretResult(result, data) {
|
||||
onShowSecretResult(iError, data) {
|
||||
this.secreting(false);
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
if (!iError && data && data.Result) {
|
||||
this.viewSecret(pString(data.Result.Secret));
|
||||
this.viewUrlTitle(pString(data.Result.UrlTitle));
|
||||
this.viewUrl(qr.toDataURL({ level: 'M', size: 6, value: this.getQr() }));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import { StorageResultType } from 'Common/Enums';
|
||||
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
|
||||
import { decorateKoCommands } from 'Knoin/Knoin';
|
||||
|
|
@ -26,9 +24,9 @@ class TwoFactorTestPopupView extends AbstractViewPopup {
|
|||
|
||||
testCodeCommand() {
|
||||
this.testing(true);
|
||||
Remote.testTwoFactor((result, data) => {
|
||||
Remote.testTwoFactor((iError, data) => {
|
||||
this.testing(false);
|
||||
this.codeStatus(StorageResultType.Success === result && data && !!data.Result);
|
||||
this.codeStatus(!iError && data && !!data.Result);
|
||||
|
||||
if (this.koTestedTrigger && this.codeStatus()) {
|
||||
this.koTestedTrigger(true);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import {
|
||||
StorageResultType,
|
||||
Notification
|
||||
} from 'Common/Enums';
|
||||
|
||||
|
|
@ -151,8 +150,8 @@ class LoginUserView extends AbstractViewCenter {
|
|||
|
||||
const fLoginRequest = (sLoginPassword) => {
|
||||
Remote.login(
|
||||
(sResult, oData) => {
|
||||
if (StorageResultType.Success === sResult && oData && 'Login' === oData.Action) {
|
||||
(iError, oData) => {
|
||||
if (!iError && oData && 'Login' === oData.Action) {
|
||||
if (oData.Result) {
|
||||
if (oData.TwoFactorAuth) {
|
||||
this.additionalCode('');
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ import ko from 'ko';
|
|||
|
||||
import {
|
||||
Capa,
|
||||
KeyState,
|
||||
StorageResultType
|
||||
KeyState
|
||||
} from 'Common/Enums';
|
||||
|
||||
import {
|
||||
|
|
@ -853,8 +852,8 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
addRequestedMessage(message.folder, message.uid);
|
||||
|
||||
Remote.message(
|
||||
(result, data) => {
|
||||
const next = !!(StorageResultType.Success === result && data && data.Result);
|
||||
(iError, data) => {
|
||||
const next = !!(!iError && data && data.Result);
|
||||
setTimeout(() => {
|
||||
this.bPrefetch = false;
|
||||
next && this.prefetchNextTick();
|
||||
|
|
|
|||
8
dev/bootstrap.js
vendored
8
dev/bootstrap.js
vendored
|
|
@ -1,5 +1,4 @@
|
|||
import { doc, elementById, dropdownVisibility, Settings } from 'Common/Globals';
|
||||
import { StorageResultType } from 'Common/Enums';
|
||||
import { i18n } from 'Common/Translator';
|
||||
|
||||
import { root } from 'Common/Links';
|
||||
|
|
@ -35,7 +34,12 @@ export default (App) => {
|
|||
rl.i18n = i18n;
|
||||
|
||||
rl.Enums = {
|
||||
StorageResultType: StorageResultType
|
||||
StorageResultType: {
|
||||
Success: 0,
|
||||
Error: 1,
|
||||
Abort: 2,
|
||||
Unload: 3
|
||||
}
|
||||
};
|
||||
|
||||
rl.Dropdowns = [];
|
||||
|
|
|
|||
|
|
@ -106,9 +106,9 @@
|
|||
this.newPassword2('');
|
||||
}
|
||||
|
||||
onChangePasswordResponse(result, data) {
|
||||
onChangePasswordResponse(iError, data) {
|
||||
this.reset(false);
|
||||
if (rl.Enums.StorageResultType.Success === result && data && data.Result) {
|
||||
if (!iError && data && data.Result) {
|
||||
this.currentPassword('');
|
||||
this.newPassword('');
|
||||
this.newPassword2('');
|
||||
|
|
|
|||
|
|
@ -22,20 +22,23 @@
|
|||
|
||||
this.loading(true);
|
||||
|
||||
window.rl.pluginRemoteRequest(function (sResult, oData) {
|
||||
rl.pluginRemoteRequest(function (iError, oData) {
|
||||
|
||||
self.loading(false);
|
||||
|
||||
if (window.rl.Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
if (!iError && oData && oData.Result) {
|
||||
self.php(oData.Result.PHP || '');
|
||||
}
|
||||
|
||||
if (rl.Enums.StorageResultType.Abort === iError) {
|
||||
// show abort
|
||||
}
|
||||
|
||||
}, 'JsonAdminGetData');
|
||||
|
||||
};
|
||||
|
||||
window.rl.addSettingsViewModelForAdmin(CustomAdminSettings, 'PluginCustomAdminSettingsTab',
|
||||
rl.addSettingsViewModelForAdmin(CustomAdminSettings, 'PluginCustomAdminSettingsTab',
|
||||
'SETTINGS_CUSTOM_ADMIN_CUSTOM_TAB_PLUGIN/TAB_NAME', 'custom');
|
||||
|
||||
}());
|
||||
|
|
|
|||
|
|
@ -33,14 +33,17 @@
|
|||
|
||||
this.saving(true);
|
||||
|
||||
window.rl.pluginRemoteRequest(function (sResult, oData) {
|
||||
rl.pluginRemoteRequest(function (iError, oData) {
|
||||
|
||||
self.saving(false);
|
||||
|
||||
if (window.rl.Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
if (!iError && oData && oData.Result)
|
||||
{
|
||||
// true
|
||||
}
|
||||
else if (rl.Enums.StorageResultType.Abort === iError) {
|
||||
// show abort
|
||||
}
|
||||
else
|
||||
{
|
||||
// false
|
||||
|
|
@ -58,11 +61,11 @@
|
|||
|
||||
this.loading(true);
|
||||
|
||||
window.rl.pluginRemoteRequest(function (sResult, oData) {
|
||||
rl.pluginRemoteRequest(function (iError, oData) {
|
||||
|
||||
self.loading(false);
|
||||
|
||||
if (window.rl.Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
if (!iError && oData && oData.Result)
|
||||
{
|
||||
self.userSkype(oData.Result.UserSkype || '');
|
||||
self.userFacebook(oData.Result.UserFacebook || '');
|
||||
|
|
@ -72,7 +75,7 @@
|
|||
|
||||
};
|
||||
|
||||
window.rl.addSettingsViewModel(CustomUserSettings, 'PluginCustomSettingsTab',
|
||||
rl.addSettingsViewModel(CustomUserSettings, 'PluginCustomSettingsTab',
|
||||
'SETTINGS_CUSTOM_PLUGIN/TAB_NAME', 'custom');
|
||||
|
||||
}());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue