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