mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Set response ErrorCode as iError for easier fetch error handling
This commit is contained in:
parent
a46c0c3b21
commit
11fd6736bb
|
@ -5,7 +5,6 @@ import { isPosNumeric, delegateRunOnDestroy, mailToHelper } from 'Common/UtilsUs
|
|||
|
||||
import {
|
||||
Capa,
|
||||
Notification,
|
||||
Scope
|
||||
} from 'Common/Enums';
|
||||
|
||||
|
@ -179,13 +178,13 @@ class AppUser extends AbstractApp {
|
|||
MessageUserStore.listError('');
|
||||
Remote.messageList(
|
||||
(iError, oData, bCached) => {
|
||||
if (!iError && oData && oData.Result) {
|
||||
if (iError) {
|
||||
if (Notification.RequestAborted !== iError) {
|
||||
MessageUserStore.list([]);
|
||||
MessageUserStore.listError(getNotification(iError));
|
||||
}
|
||||
} else {
|
||||
MessageUserStore.setMessageList(oData, bCached);
|
||||
} else if (Remote.ABORT !== iError) {
|
||||
MessageUserStore.list([]);
|
||||
MessageUserStore.listError(
|
||||
getNotification((oData && oData.ErrorCode) || Notification.CantGetMessageList)
|
||||
);
|
||||
}
|
||||
MessageUserStore.listLoading(false);
|
||||
},
|
||||
|
@ -273,17 +272,15 @@ class AppUser extends AbstractApp {
|
|||
}
|
||||
|
||||
moveOrDeleteResponseHelper(iError, oData) {
|
||||
if (!iError && FolderUserStore.currentFolder()) {
|
||||
if (oData && isArray(oData.Result) && 2 === oData.Result.length) {
|
||||
if (iError) {
|
||||
setFolderHash(FolderUserStore.currentFolderFullNameRaw(), '');
|
||||
alert(getNotification(iError));
|
||||
} else if (FolderUserStore.currentFolder()) {
|
||||
if (isArray(oData.Result) && 2 === oData.Result.length) {
|
||||
setFolderHash(oData.Result[0], oData.Result[1]);
|
||||
} else {
|
||||
setFolderHash(FolderUserStore.currentFolderFullNameRaw(), '');
|
||||
|
||||
if (oData && [Notification.CantMoveMessage, Notification.CantCopyMessage].includes(oData.ErrorCode)) {
|
||||
alert(getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
|
||||
this.reloadMessageList(!MessageUserStore.list.length);
|
||||
this.quotaDebounce();
|
||||
}
|
||||
|
@ -763,7 +760,7 @@ class AppUser extends AbstractApp {
|
|||
autocompleteCallback(
|
||||
data.Result.map(item => (item && item[0] ? new EmailModel(item[0], item[1]) : null)).filter(v => v)
|
||||
);
|
||||
} else if (Remote.ABORT !== iError) {
|
||||
} else if (Notification.RequestAborted !== iError) {
|
||||
autocompleteCallback([]);
|
||||
}
|
||||
}, query);
|
||||
|
|
|
@ -77,6 +77,9 @@ export const SaveSettingsStep = {
|
|||
* @enum {number}
|
||||
*/
|
||||
export const Notification = {
|
||||
RequestError: 1,
|
||||
RequestAborted: 2,
|
||||
|
||||
InvalidToken: 101,
|
||||
AuthError: 102,
|
||||
ConnectionError: 104,
|
||||
|
|
|
@ -92,29 +92,17 @@ function getNotificationMessage(code) {
|
|||
* @param {*=} defCode = null
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getNotification(code, message = '', defCode = null) {
|
||||
export function getNotification(code, message = '', defCode = 0) {
|
||||
code = parseInt(code, 10) || 0;
|
||||
if (Notification.ClientViewError === code && message) {
|
||||
return message;
|
||||
}
|
||||
|
||||
defCode = defCode ? parseInt(defCode, 10) || 0 : 0;
|
||||
return getNotificationMessage(code)
|
||||
|| getNotificationMessage(defCode)
|
||||
|| getNotificationMessage(parseInt(defCode, 10))
|
||||
|| '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} response
|
||||
* @param {number} defCode = Notification.UnknownNotification
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getNotificationFromResponse(response, defCode = Notification.UnknownNotification) {
|
||||
return response && response.ErrorCode
|
||||
? getNotification(parseInt(response.ErrorCode, 10) || defCode, response.ErrorMessage || '')
|
||||
: getNotification(defCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} code
|
||||
* @returns {string}
|
||||
|
|
|
@ -32,11 +32,9 @@ checkResponseError = data => {
|
|||
) {
|
||||
++iJsonErrorCount;
|
||||
}
|
||||
if (window.rl && (data.ClearAuth || data.Logout || 7 < iJsonErrorCount)) {
|
||||
if (data.ClearAuth || data.Logout || 7 < iJsonErrorCount) {
|
||||
rl.hash.clear();
|
||||
if (!data.ClearAuth) {
|
||||
rl.logoutReload();
|
||||
}
|
||||
data.ClearAuth || rl.logoutReload();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -116,10 +114,16 @@ export class AbstractFetchRemote
|
|||
}
|
||||
|
||||
if (!iError && data) {
|
||||
/*
|
||||
if (sAction !== data.Action) {
|
||||
console.log(sAction + ' !== ' + data.Action);
|
||||
}
|
||||
*/
|
||||
if (data.Result) {
|
||||
iJsonErrorCount = iTokenErrorCount = 0;
|
||||
} else {
|
||||
checkResponseError(data);
|
||||
iError = data.ErrorCode || Notification.UnknownError
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,14 +35,11 @@ export class PackagesAdminSettings {
|
|||
|
||||
requestHelper(packageToRequest, install) {
|
||||
return (iError, data) => {
|
||||
if (iError || !data || !data.Result) {
|
||||
if (data && data.ErrorCode) {
|
||||
this.packagesError(getNotification(data.ErrorCode));
|
||||
} else {
|
||||
this.packagesError(
|
||||
getNotification(install ? Notification.CantInstallPackage : Notification.CantDeletePackage)
|
||||
);
|
||||
}
|
||||
if (iError) {
|
||||
this.packagesError(
|
||||
getNotification(install ? Notification.CantInstallPackage : Notification.CantDeletePackage)
|
||||
// ':\n' + getNotification(iError);
|
||||
);
|
||||
}
|
||||
|
||||
PackageAdminStore.forEach(item => {
|
||||
|
@ -52,7 +49,7 @@ export class PackagesAdminSettings {
|
|||
}
|
||||
});
|
||||
|
||||
if (!iError && data && data.Result && data.Result.Reload) {
|
||||
if (!iError && data.Result.Reload) {
|
||||
location.reload();
|
||||
} else {
|
||||
PackageAdminStore.fetch();
|
||||
|
|
|
@ -60,13 +60,11 @@ export class PluginsAdminSettings {
|
|||
}
|
||||
|
||||
onPluginDisableRequest(iError, data) {
|
||||
if (!iError && data) {
|
||||
if (!data.Result && data.ErrorCode) {
|
||||
if (Notification.UnsupportedPluginPackage === data.ErrorCode && data.ErrorMessage && data.ErrorMessage) {
|
||||
PluginAdminStore.error(data.ErrorMessage);
|
||||
} else {
|
||||
PluginAdminStore.error(getNotification(data.ErrorCode));
|
||||
}
|
||||
if (iError) {
|
||||
if (Notification.UnsupportedPluginPackage === iError && data && data.ErrorMessage) {
|
||||
PluginAdminStore.error(data.ErrorMessage);
|
||||
} else {
|
||||
PluginAdminStore.error(getNotification(iError));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
import { addObservablesTo } from 'Common/Utils';
|
||||
import { delegateRunOnDestroy } from 'Common/UtilsUser';
|
||||
|
@ -41,7 +40,10 @@ export class FiltersUserSettings {
|
|||
this.loading(false);
|
||||
this.scripts([]);
|
||||
|
||||
if (!iError && data && data.Result) {
|
||||
if (iError) {
|
||||
SieveUserStore.capa([]);
|
||||
this.setError(getNotification(iError));
|
||||
} else {
|
||||
SieveUserStore.capa(data.Result.Capa);
|
||||
/*
|
||||
this.scripts(
|
||||
|
@ -52,11 +54,6 @@ export class FiltersUserSettings {
|
|||
value = SieveScriptModel.reviveFromJson(value);
|
||||
value && this.scripts.push(value)
|
||||
});
|
||||
} else {
|
||||
SieveUserStore.capa([]);
|
||||
this.setError(
|
||||
data && data.ErrorCode ? getNotification(data.ErrorCode) : getNotification(Notification.CantGetFilters)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -73,15 +70,12 @@ export class FiltersUserSettings {
|
|||
deleteScript(script) {
|
||||
this.serverError(false);
|
||||
Remote.filtersScriptDelete(
|
||||
(result, data) => {
|
||||
if (Remote.SUCCESS === result && data && data.Result) {
|
||||
(iError, data) => {
|
||||
if (iError) {
|
||||
this.setError((data && data.ErrorMessageAdditional) || getNotification(iError));
|
||||
} else {
|
||||
this.scripts.remove(script);
|
||||
delegateRunOnDestroy(script);
|
||||
} else {
|
||||
this.setError((data && data.ErrorCode)
|
||||
? (data.ErrorMessageAdditional || getNotification(data.ErrorCode))
|
||||
: getNotification(Notification.CantActivateFiltersScript)
|
||||
);
|
||||
}
|
||||
},
|
||||
script.name()
|
||||
|
@ -92,14 +86,11 @@ export class FiltersUserSettings {
|
|||
let name = script.active() ? '' : script.name();
|
||||
this.serverError(false);
|
||||
Remote.filtersScriptActivate(
|
||||
(result, data) => {
|
||||
if (Remote.SUCCESS === result && data && data.Result) {
|
||||
this.scripts.forEach(script => script.active(script.name() === name));
|
||||
(iError, data) => {
|
||||
if (iError) {
|
||||
this.setError((data && data.ErrorMessageAdditional) || iError)
|
||||
} else {
|
||||
this.setError((data && data.ErrorCode)
|
||||
? (data.ErrorMessageAdditional || getNotification(data.ErrorCode))
|
||||
: getNotification(Notification.CantActivateFiltersScript)
|
||||
);
|
||||
this.scripts.forEach(script => script.active(script.name() === name));
|
||||
}
|
||||
},
|
||||
name
|
||||
|
|
|
@ -640,15 +640,14 @@ export const MessageUserStore = new class {
|
|||
* @param {boolean} bCached
|
||||
*/
|
||||
onMessageResponse(iError, oData, bCached) {
|
||||
if (!iError && oData && oData.Result) {
|
||||
if (iError) {
|
||||
if (Notification.RequestAborted !== iError) {
|
||||
this.message(null);
|
||||
this.messageError(getNotification(iError));
|
||||
}
|
||||
} else {
|
||||
this.setMessage(oData, bCached);
|
||||
} else if (Remote.ABORT !== iError) {
|
||||
this.message(null);
|
||||
this.messageError(
|
||||
oData && oData.ErrorCode ? getNotification(oData.ErrorCode) : getNotification(Notification.UnknownError)
|
||||
);
|
||||
}
|
||||
|
||||
this.messageLoading(false);
|
||||
}
|
||||
|
||||
|
@ -663,7 +662,7 @@ export const MessageUserStore = new class {
|
|||
}
|
||||
|
||||
setMessageList(data, cached) {
|
||||
const collection = data && MessageCollectionModel.reviveFromJson(data.Result, cached);
|
||||
const collection = MessageCollectionModel.reviveFromJson(data.Result, cached);
|
||||
if (collection) {
|
||||
let unreadCountChange = false;
|
||||
|
||||
|
@ -715,7 +714,7 @@ export const MessageUserStore = new class {
|
|||
} else {
|
||||
this.listCount(0);
|
||||
this.list([]);
|
||||
this.listError(getNotification(data && data.ErrorCode ? data.ErrorCode : Notification.CantGetMessageList));
|
||||
this.listError(getNotification(Notification.CantGetMessageList));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { Settings } from 'Common/Globals';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
|
@ -59,17 +58,12 @@ class LoginAdminView extends AbstractViewCenter {
|
|||
this.submitRequest(true);
|
||||
|
||||
Remote.adminLogin(
|
||||
(iError, oData) => {
|
||||
if (!iError && oData && 'AdminLogin' === oData.Action) {
|
||||
if (oData.Result) {
|
||||
rl.route.reload();
|
||||
} else if (oData.ErrorCode) {
|
||||
this.submitRequest(false);
|
||||
this.submitError(getNotification(oData.ErrorCode));
|
||||
}
|
||||
(iError) => {
|
||||
this.submitRequest(false);
|
||||
if (iError) {
|
||||
this.submitError(getNotification(iError));
|
||||
} else {
|
||||
this.submitRequest(false);
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
rl.route.reload();
|
||||
}
|
||||
},
|
||||
this.login(),
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Notification } from 'Common/Enums';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
|
@ -48,22 +47,12 @@ class AccountPopupView extends AbstractViewPopup {
|
|||
Remote.accountSetup(
|
||||
(iError, data) => {
|
||||
this.submitRequest(false);
|
||||
if (!iError && data) {
|
||||
if (data.Result) {
|
||||
rl.app.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
} else {
|
||||
this.submitError(
|
||||
data.ErrorCode ? getNotification(data.ErrorCode) : getNotification(Notification.UnknownError)
|
||||
);
|
||||
|
||||
if (data.ErrorMessageAdditional) {
|
||||
this.submitErrorAdditional(data.ErrorMessageAdditional);
|
||||
}
|
||||
}
|
||||
if (iError) {
|
||||
this.submitError(getNotification(iError));
|
||||
this.submitErrorAdditional((data && data.ErrorMessageAdditional) || '');
|
||||
} else {
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
this.submitErrorAdditional('');
|
||||
rl.app.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
},
|
||||
this.email(),
|
||||
|
|
|
@ -579,28 +579,21 @@ class ComposePopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
sendMessageResponse(iError, data) {
|
||||
let result = false,
|
||||
message = '';
|
||||
|
||||
this.sending(false);
|
||||
|
||||
if (!iError && data && data.Result) {
|
||||
result = true;
|
||||
this.modalVisibility() && this.closeCommand && this.closeCommand();
|
||||
}
|
||||
|
||||
if (this.modalVisibility() && !result) {
|
||||
if (data && Notification.CantSaveMessage === data.ErrorCode) {
|
||||
this.sendSuccessButSaveError(true);
|
||||
this.savedErrorDesc(i18n('COMPOSE/SAVED_ERROR_ON_SEND').trim());
|
||||
if (this.modalVisibility()) {
|
||||
if (iError) {
|
||||
if (Notification.CantSaveMessage === iError) {
|
||||
this.sendSuccessButSaveError(true);
|
||||
this.savedErrorDesc(i18n('COMPOSE/SAVED_ERROR_ON_SEND').trim());
|
||||
} else {
|
||||
this.sendError(true);
|
||||
this.sendErrorDesc(getNotification(iError, data && data.ErrorMessage)
|
||||
|| getNotification(Notification.CantSendMessage));
|
||||
}
|
||||
} else {
|
||||
message = getNotification(
|
||||
data && data.ErrorCode ? data.ErrorCode : Notification.CantSendMessage,
|
||||
data && data.ErrorMessage ? data.ErrorMessage : ''
|
||||
);
|
||||
|
||||
this.sendError(true);
|
||||
this.sendErrorDesc(message || getNotification(Notification.CantSendMessage));
|
||||
this.closeCommand && this.closeCommand();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ import ko from 'ko';
|
|||
|
||||
import {
|
||||
SaveSettingsStep,
|
||||
Notification,
|
||||
Scope
|
||||
} from 'Common/Enums';
|
||||
|
||||
|
@ -255,10 +254,8 @@ class ContactsPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
syncCommand() {
|
||||
rl.app.contactsSync((iError, data) => {
|
||||
if (iError || !data || !data.Result) {
|
||||
alert(getNotification(data && data.ErrorCode ? data.ErrorCode : Notification.ContactsSyncError));
|
||||
}
|
||||
rl.app.contactsSync(iError => {
|
||||
iError && alert(getNotification(iError));
|
||||
|
||||
this.reloadContactList(true);
|
||||
});
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { Notification } from 'Common/Enums';
|
||||
import { pInt, pString } from 'Common/Utils';
|
||||
import { i18n } from 'Common/Translator';
|
||||
import { i18n, getNotification } from 'Common/Translator';
|
||||
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
|
||||
|
@ -248,17 +247,13 @@ class DomainPopupView extends AbstractViewPopup {
|
|||
}
|
||||
}
|
||||
|
||||
onDomainCreateOrSaveResponse(iError, oData) {
|
||||
onDomainCreateOrSaveResponse(iError) {
|
||||
this.saving(false);
|
||||
if (!iError && oData) {
|
||||
if (oData.Result) {
|
||||
DomainAdminStore.fetch();
|
||||
this.closeCommand();
|
||||
} else if (Notification.DomainAlreadyExists === oData.ErrorCode) {
|
||||
this.savingError(i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
||||
}
|
||||
if (iError) {
|
||||
this.savingError(getNotification(iError));
|
||||
} else {
|
||||
this.savingError(i18n('ERRORS/UNKNOWN_ERROR'));
|
||||
DomainAdminStore.fetch();
|
||||
this.closeCommand();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { i18n } from 'Common/Translator';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
import { DomainAdminStore } from 'Stores/Admin/Domain';
|
||||
|
||||
|
@ -29,8 +28,6 @@ class DomainAliasPopupView extends AbstractViewPopup {
|
|||
|
||||
this.canBeSaved = ko.computed(() => !this.saving() && this.name() && this.alias());
|
||||
|
||||
this.onDomainAliasCreateOrSaveResponse = this.onDomainAliasCreateOrSaveResponse.bind(this);
|
||||
|
||||
decorateKoCommands(this, {
|
||||
createCommand: self => self.canBeSaved()
|
||||
});
|
||||
|
@ -38,21 +35,15 @@ class DomainAliasPopupView extends AbstractViewPopup {
|
|||
|
||||
createCommand() {
|
||||
this.saving(true);
|
||||
Remote.createDomainAlias(this.onDomainAliasCreateOrSaveResponse, this.name(), this.alias());
|
||||
}
|
||||
|
||||
onDomainAliasCreateOrSaveResponse(iError, data) {
|
||||
this.saving(false);
|
||||
if (!iError && data) {
|
||||
if (data.Result) {
|
||||
Remote.createDomainAlias(iError => {
|
||||
this.saving(false);
|
||||
if (iError) {
|
||||
this.savingError(getNotification(iError));
|
||||
} else {
|
||||
DomainAdminStore.fetch();
|
||||
this.closeCommand();
|
||||
} else if (Notification.DomainAlreadyExists === data.ErrorCode) {
|
||||
this.savingError(i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
||||
}
|
||||
} else {
|
||||
this.savingError(i18n('ERRORS/UNKNOWN_ERROR'));
|
||||
}
|
||||
}, this.name(), this.alias());
|
||||
}
|
||||
|
||||
onShow() {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Notification } from 'Common/Enums';
|
||||
import { i18n, getNotification } from 'Common/Translator';
|
||||
import { setFolderHash } from 'Common/Cache';
|
||||
|
||||
|
@ -54,17 +53,13 @@ class FolderClearPopupView extends AbstractViewPopup {
|
|||
|
||||
setFolderHash(folderToClear.fullNameRaw, '');
|
||||
|
||||
Remote.folderClear((iError, data) => {
|
||||
Remote.folderClear(iError => {
|
||||
this.clearingProcess(false);
|
||||
if (!iError && data && data.Result) {
|
||||
if (iError) {
|
||||
this.clearingError(getNotification(iError));
|
||||
} else {
|
||||
rl.app.reloadMessageList(true);
|
||||
this.cancelCommand();
|
||||
} else {
|
||||
if (data && data.ErrorCode) {
|
||||
this.clearingError(getNotification(data.ErrorCode));
|
||||
} else {
|
||||
this.clearingError(getNotification(Notification.MailServerError));
|
||||
}
|
||||
}
|
||||
}, folderToClear.fullNameRaw);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Notification } from 'Common/Enums';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
|
@ -96,17 +95,13 @@ class IdentityPopupView extends AbstractViewPopup {
|
|||
this.submitRequest(true);
|
||||
|
||||
Remote.identityUpdate(
|
||||
(iError, data) => {
|
||||
iError => {
|
||||
this.submitRequest(false);
|
||||
if (!iError && data) {
|
||||
if (data.Result) {
|
||||
rl.app.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
} else if (data.ErrorCode) {
|
||||
this.submitError(getNotification(data.ErrorCode));
|
||||
}
|
||||
if (iError) {
|
||||
this.submitError(getNotification(iError));
|
||||
} else {
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
rl.app.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
},
|
||||
this.id,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { Scope, Notification } from 'Common/Enums';
|
||||
import { Scope } from 'Common/Enums';
|
||||
import { getNotification, i18n } from 'Common/Translator';
|
||||
import { isNonEmptyArray } from 'Common/Utils';
|
||||
|
||||
|
@ -53,16 +53,11 @@ class PluginPopupView extends AbstractViewPopup {
|
|||
Remote.pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, list);
|
||||
}
|
||||
|
||||
onPluginSettingsUpdateResponse(iError, data) {
|
||||
if (!iError && data && data.Result) {
|
||||
this.cancelCommand();
|
||||
onPluginSettingsUpdateResponse(iError) {
|
||||
if (iError) {
|
||||
this.saveError(getNotification(iError));
|
||||
} else {
|
||||
this.saveError('');
|
||||
if (data && data.ErrorCode) {
|
||||
this.saveError(getNotification(data.ErrorCode));
|
||||
} else {
|
||||
this.saveError(getNotification(Notification.CantSavePluginSettings));
|
||||
}
|
||||
this.cancelCommand();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { getNotification, i18nToNodes } from 'Common/Translator';
|
||||
import { addObservablesTo } from 'Common/Utils';
|
||||
import { delegateRunOnDestroy } from 'Common/UtilsUser';
|
||||
|
@ -61,16 +60,13 @@ class SieveScriptPopupView extends AbstractViewPopup {
|
|||
(iError, data) => {
|
||||
self.saving = false;
|
||||
|
||||
if (!iError && data && data.Result) {
|
||||
if (iError) {
|
||||
self.saveError(true);
|
||||
self.saveErrorText((data && data.ErrorMessageAdditional) || getNotification(iError));
|
||||
} else {
|
||||
script.exists() || SieveUserStore.scripts.push(script);
|
||||
script.exists(true);
|
||||
script.hasChanges(false);
|
||||
} else {
|
||||
self.saveError(true);
|
||||
self.saveErrorText((data && data.ErrorCode)
|
||||
? (data.ErrorMessageAdditional || getNotification(data.ErrorCode))
|
||||
: getNotification(Notification.CantSaveFilters)
|
||||
);
|
||||
}
|
||||
},
|
||||
script
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Notification } from 'Common/Enums';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
import { HtmlEditor } from 'Common/Html';
|
||||
|
||||
|
@ -53,17 +52,13 @@ class TemplatePopupView extends AbstractViewPopup {
|
|||
this.submitRequest(true);
|
||||
|
||||
Remote.templateSetup(
|
||||
(iError, data) => {
|
||||
iError => {
|
||||
this.submitRequest(false);
|
||||
if (!iError && data) {
|
||||
if (data.Result) {
|
||||
rl.app.templates();
|
||||
this.cancelCommand();
|
||||
} else if (data.ErrorCode) {
|
||||
this.submitError(getNotification(data.ErrorCode));
|
||||
}
|
||||
if (iError) {
|
||||
this.submitError(getNotification(iError));
|
||||
} else {
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
rl.app.templates();
|
||||
this.cancelCommand();
|
||||
}
|
||||
},
|
||||
this.id(),
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
|
||||
import { ClientSideKeyName } from 'Common/EnumsUser';
|
||||
|
||||
import { getNotification, getNotificationFromResponse, reload as translatorReload, convertLangName } from 'Common/Translator';
|
||||
import { getNotification, reload as translatorReload, convertLangName } from 'Common/Translator';
|
||||
|
||||
import { LanguageStore } from 'Stores/Language';
|
||||
|
||||
|
@ -150,36 +150,21 @@ class LoginUserView extends AbstractViewCenter {
|
|||
const fLoginRequest = (sLoginPassword) => {
|
||||
Remote.login(
|
||||
(iError, oData) => {
|
||||
if (!iError && oData && 'Login' === oData.Action) {
|
||||
if (oData.Result) {
|
||||
if (oData.TwoFactorAuth) {
|
||||
this.additionalCode('');
|
||||
this.additionalCodeVisibility(true);
|
||||
this.submitRequest(false);
|
||||
|
||||
setTimeout(() => this.querySelector('.inputAdditionalCode').focus(), 100);
|
||||
} else {
|
||||
rl.route.reload();
|
||||
}
|
||||
} else if (oData.ErrorCode) {
|
||||
this.submitRequest(false);
|
||||
if ([Notification.InvalidInputArgument].includes(oData.ErrorCode)) {
|
||||
oData.ErrorCode = Notification.AuthError;
|
||||
}
|
||||
|
||||
this.submitError(getNotificationFromResponse(oData));
|
||||
|
||||
if (!this.submitError()) {
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
} else if (oData.ErrorMessageAdditional) {
|
||||
this.submitErrorAddidional(oData.ErrorMessageAdditional);
|
||||
}
|
||||
} else {
|
||||
this.submitRequest(false);
|
||||
this.submitRequest(false);
|
||||
if (iError) {
|
||||
if (Notification.InvalidInputArgument == iError) {
|
||||
iError = Notification.AuthError;
|
||||
}
|
||||
this.submitError(getNotification(iError, oData.ErrorMessage, Notification.UnknownNotification));
|
||||
this.submitErrorAddidional((oData && oData.ErrorMessageAdditional) || '');
|
||||
} else {
|
||||
this.submitRequest(false);
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
if (oData.TwoFactorAuth) {
|
||||
this.additionalCode('');
|
||||
this.additionalCodeVisibility(true);
|
||||
setTimeout(() => this.querySelector('.inputAdditionalCode').focus(), 100);
|
||||
} else {
|
||||
rl.route.reload();
|
||||
}
|
||||
}
|
||||
},
|
||||
this.email(),
|
||||
|
|
3
dev/bootstrap.js
vendored
3
dev/bootstrap.js
vendored
|
@ -37,8 +37,7 @@ export default (App) => {
|
|||
StorageResultType: {
|
||||
Success: 0,
|
||||
Error: 1,
|
||||
Abort: 2,
|
||||
Unload: 3
|
||||
Abort: 2
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -108,25 +108,21 @@
|
|||
|
||||
onChangePasswordResponse(iError, data) {
|
||||
this.reset(false);
|
||||
if (!iError && data && data.Result) {
|
||||
if (iError) {
|
||||
this.passwordUpdateError(true);
|
||||
if (131 === iError) {
|
||||
// Notification.CurrentPasswordIncorrect
|
||||
this.currentPasswordError(true);
|
||||
}
|
||||
this.errorDescription((data && data.ErrorMessageAdditional)
|
||||
|| rl.i18n('NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD'));
|
||||
} else {
|
||||
this.currentPassword('');
|
||||
this.newPassword('');
|
||||
this.newPassword2('');
|
||||
this.passwordUpdateSuccess(true);
|
||||
rl.hash.set();
|
||||
rl.settings.set('AuthAccountHash', data.Result);
|
||||
} else {
|
||||
this.passwordUpdateError(true);
|
||||
this.errorDescription(rl.i18n('NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD'));
|
||||
if (data) {
|
||||
if (131 === data.ErrorCode) {
|
||||
// Notification.CurrentPasswordIncorrect
|
||||
this.currentPasswordError(true);
|
||||
}
|
||||
if (data.ErrorMessageAdditional) {
|
||||
this.errorDescription(data.ErrorMessageAdditional);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
|
||||
this.loading(true);
|
||||
|
||||
rl.pluginRemoteRequest(function (iError, oData) {
|
||||
rl.pluginRemoteRequest((iError, oData) => {
|
||||
|
||||
self.loading(false);
|
||||
|
||||
if (!iError && oData && oData.Result) {
|
||||
if (!iError) {
|
||||
self.php(oData.Result.PHP || '');
|
||||
}
|
||||
|
||||
|
|
|
@ -33,11 +33,11 @@
|
|||
|
||||
this.saving(true);
|
||||
|
||||
rl.pluginRemoteRequest(function (iError, oData) {
|
||||
rl.pluginRemoteRequest((iError, oData) => {
|
||||
|
||||
self.saving(false);
|
||||
|
||||
if (!iError && oData && oData.Result)
|
||||
if (!iError)
|
||||
{
|
||||
// true
|
||||
}
|
||||
|
@ -61,11 +61,11 @@
|
|||
|
||||
this.loading(true);
|
||||
|
||||
rl.pluginRemoteRequest(function (iError, oData) {
|
||||
rl.pluginRemoteRequest((iError, oData) => {
|
||||
|
||||
self.loading(false);
|
||||
|
||||
if (!iError && oData && oData.Result)
|
||||
if (!iError)
|
||||
{
|
||||
self.userSkype(oData.Result.UserSkype || '');
|
||||
self.userFacebook(oData.Result.UserFacebook || '');
|
||||
|
|
Loading…
Reference in a new issue