mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 12:39:20 +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
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue