mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-06-29 15:26:09 +00:00
Bugfix: Notification enum conflicts with window.Notification
This commit is contained in:
@@ -39,7 +39,7 @@ SaveSettingStatus = {
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Notification = {
|
||||
Notifications = {
|
||||
RequestError: 1,
|
||||
RequestAborted: 2,
|
||||
RequestTimeout: 3,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import ko from 'ko';
|
||||
import { Notification, UploadErrorCode } from 'Common/Enums';
|
||||
import { Notifications, UploadErrorCode } from 'Common/Enums';
|
||||
import { langLink } from 'Common/Links';
|
||||
import { doc, createElement } from 'Common/Globals';
|
||||
import { getKeyByValue, forEachObjectEntry } from 'Common/Utils';
|
||||
@@ -20,7 +20,7 @@ const
|
||||
i18nKey = key => key.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase(),
|
||||
|
||||
getNotificationMessage = code => {
|
||||
let key = getKeyByValue(Notification, code);
|
||||
let key = getKeyByValue(Notifications, code);
|
||||
return key ? I18N_DATA.NOTIFICATIONS[i18nKey(key).replace('_NOTIFICATION', '_ERROR')] : '';
|
||||
},
|
||||
|
||||
@@ -176,7 +176,7 @@ export const
|
||||
*/
|
||||
getNotification = (code, message = '', defCode = 0) => {
|
||||
code = pInt(code);
|
||||
if (Notification.ClientViewError === code && message) {
|
||||
if (Notifications.ClientViewError === code && message) {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { MessageFlagsCache } from 'Common/Cache';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { Notifications } from 'Common/Enums';
|
||||
import { MessageSetAction, ComposeType/*, FolderType*/ } from 'Common/EnumsUser';
|
||||
import { doc, createElement, elementById, dropdowns, dropdownVisibility, SettingsGet, leftPanelDisabled } from 'Common/Globals';
|
||||
import { plainToHtml } from 'Common/Html';
|
||||
@@ -293,7 +293,7 @@ populateMessageBody = (oMessage, popup) => {
|
||||
popup || MessageUserStore.loading(true);
|
||||
Remote.message((iError, oData/*, bCached*/) => {
|
||||
if (iError) {
|
||||
if (Notification.RequestAborted !== iError && !popup) {
|
||||
if (Notifications.RequestAborted !== iError && !popup) {
|
||||
MessageUserStore.message(null);
|
||||
MessageUserStore.error(getNotification(iError));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { Notifications } from 'Common/Enums';
|
||||
import { isArray, pInt, pString } from 'Common/Utils';
|
||||
import { serverRequest } from 'Common/Links';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
@@ -9,18 +9,18 @@ const getURL = (add = '') => serverRequest('Json') + pString(add),
|
||||
|
||||
checkResponseError = data => {
|
||||
const err = data ? data.ErrorCode : null;
|
||||
if (Notification.InvalidToken === err) {
|
||||
if (Notifications.InvalidToken === err) {
|
||||
console.error(getNotification(err));
|
||||
// alert(getNotification(err));
|
||||
rl.logoutReload();
|
||||
} else if ([
|
||||
Notification.AuthError,
|
||||
Notification.ConnectionError,
|
||||
Notification.DomainNotAllowed,
|
||||
Notification.AccountNotAllowed,
|
||||
Notification.MailServerError,
|
||||
Notification.UnknownNotification,
|
||||
Notification.UnknownError
|
||||
Notifications.AuthError,
|
||||
Notifications.ConnectionError,
|
||||
Notifications.DomainNotAllowed,
|
||||
Notifications.AccountNotAllowed,
|
||||
Notifications.MailServerError,
|
||||
Notifications.UnknownNotification,
|
||||
Notifications.UnknownError
|
||||
].includes(err)
|
||||
) {
|
||||
if (7 < ++iJsonErrorCount) {
|
||||
@@ -65,7 +65,7 @@ class FetchError extends Error
|
||||
{
|
||||
constructor(code, message) {
|
||||
super(message);
|
||||
this.code = code || Notification.JsonFalse;
|
||||
this.code = code || Notifications.JsonFalse;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ export class AbstractFetchRemote
|
||||
iJsonErrorCount = 0;
|
||||
} else {
|
||||
checkResponseError(data);
|
||||
iError = data.ErrorCode || Notification.UnknownError
|
||||
iError = data.ErrorCode || Notifications.UnknownError
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ export class AbstractFetchRemote
|
||||
abort(action, 0, 1);
|
||||
|
||||
if (!data) {
|
||||
return Promise.reject(new FetchError(Notification.JsonParse));
|
||||
return Promise.reject(new FetchError(Notifications.JsonParse));
|
||||
}
|
||||
/*
|
||||
let isCached = false, type = '';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import ko from 'ko';
|
||||
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { Notifications } from 'Common/Enums';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
import { PackageAdminStore } from 'Stores/Admin/Package';
|
||||
@@ -67,7 +67,7 @@ export class AdminSettingsPackages extends AbstractViewSettings {
|
||||
|
||||
if (iError) {
|
||||
this.packagesError(
|
||||
getNotification(install ? Notification.CantInstallPackage : Notification.CantDeletePackage)
|
||||
getNotification(install ? Notifications.CantInstallPackage : Notifications.CantDeletePackage)
|
||||
+ (data.ErrorMessage ? ':\n' + data.ErrorMessage : '')
|
||||
);
|
||||
} else if (data.Result.Reload) {
|
||||
@@ -113,7 +113,7 @@ export class AdminSettingsPackages extends AbstractViewSettings {
|
||||
if (iError) {
|
||||
plugin.enabled(disable);
|
||||
this.packagesError(
|
||||
(Notification.UnsupportedPluginPackage === iError && data?.ErrorMessage)
|
||||
(Notifications.UnsupportedPluginPackage === iError && data?.ErrorMessage)
|
||||
? data.ErrorMessage
|
||||
: getNotification(iError)
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import ko from 'ko';
|
||||
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { Notifications } from 'Common/Enums';
|
||||
import { FolderMetadataKeys } from 'Common/EnumsUser';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
@@ -84,7 +84,7 @@ export class UserSettingsFolders /*extends AbstractViewSettings*/ {
|
||||
})
|
||||
.catch(error => {
|
||||
FolderUserStore.folderListError(
|
||||
getNotification(error.code, '', Notification.CantRenameFolder)
|
||||
getNotification(error.code, '', Notifications.CantRenameFolder)
|
||||
+ '.\n' + error.message);
|
||||
});
|
||||
}
|
||||
@@ -119,8 +119,8 @@ export class UserSettingsFolders /*extends AbstractViewSettings*/ {
|
||||
&& folderToRemove.askDelete()
|
||||
) {
|
||||
if (0 < folderToRemove.totalEmails()) {
|
||||
// FolderUserStore.folderListError(getNotification(Notification.CantDeleteNonEmptyFolder));
|
||||
folderToRemove.errorMsg(getNotification(Notification.CantDeleteNonEmptyFolder));
|
||||
// FolderUserStore.folderListError(getNotification(Notifications.CantDeleteNonEmptyFolder));
|
||||
folderToRemove.errorMsg(getNotification(Notifications.CantDeleteNonEmptyFolder));
|
||||
} else {
|
||||
folderForDeletion(null);
|
||||
|
||||
@@ -141,7 +141,7 @@ export class UserSettingsFolders /*extends AbstractViewSettings*/ {
|
||||
},
|
||||
error => {
|
||||
FolderUserStore.folderListError(
|
||||
getNotification(error.code, '', Notification.CantDeleteFolder)
|
||||
getNotification(error.code, '', Notifications.CantDeleteFolder)
|
||||
+ '.\n' + error.message
|
||||
);
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@ export const
|
||||
arr.map(item => item.toString?.() || item).join(separator),
|
||||
/*
|
||||
getNotificationMessage = code => {
|
||||
let key = getKeyByValue(Notification, code);
|
||||
let key = getKeyByValue(Notifications, code);
|
||||
return key ? I18N_DATA.NOTIFICATIONS[i18nKey(key).replace('_NOTIFICATION', '_ERROR')] : '';
|
||||
rl.i18n('NOTIFICATIONS/')
|
||||
},
|
||||
getNotification = (code, message = '', defCode = 0) => {
|
||||
code = parseInt(code, 10) || 0;
|
||||
if (Notification.ClientViewError === code && message) {
|
||||
if (Notifications.ClientViewError === code && message) {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import ko from 'ko';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
import { koComputable, addObservablesTo, koArrayWithDestroy } from 'External/ko';
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
import { Notifications } from 'Common/Enums';
|
||||
|
||||
export const ContactUserStore = koArrayWithDestroy();
|
||||
|
||||
@@ -43,7 +44,7 @@ ContactUserStore.sync = fResultFunc => {
|
||||
} catch (e) {
|
||||
ContactUserStore.syncing(false);
|
||||
console.error(e);
|
||||
fResultFunc?.(Notification.UnknownError);
|
||||
fResultFunc?.(Notifications.UnknownError);
|
||||
}
|
||||
}, 'ContactsSync');
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { koComputable, addObservablesTo, addComputablesTo } from 'External/ko';
|
||||
|
||||
import { SMAudio } from 'Common/Audio';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { Notifications } from 'Common/Enums';
|
||||
import { MessageSetAction } from 'Common/EnumsUser';
|
||||
import { $htmlCL } from 'Common/Globals';
|
||||
import { arrayLength, pInt, pString } from 'Common/Utils';
|
||||
@@ -198,7 +198,7 @@ MessagelistUserStore.reload = (bDropPagePosition = false, bDropCurrentFolderCach
|
||||
let error = '';
|
||||
if (iError) {
|
||||
error = getNotification(iError);
|
||||
if (Notification.RequestAborted !== iError) {
|
||||
if (Notifications.RequestAborted !== iError) {
|
||||
MessagelistUserStore([]);
|
||||
}
|
||||
} else {
|
||||
@@ -281,7 +281,7 @@ MessagelistUserStore.reload = (bDropPagePosition = false, bDropCurrentFolderCach
|
||||
} else {
|
||||
MessagelistUserStore.count(0);
|
||||
MessagelistUserStore([]);
|
||||
error = getNotification(Notification.CantGetMessageList);
|
||||
error = getNotification(Notifications.CantGetMessageList);
|
||||
}
|
||||
MessagelistUserStore.error(error);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import ko from 'ko';
|
||||
|
||||
import {
|
||||
Notification,
|
||||
Notifications,
|
||||
UploadErrorCode
|
||||
} from 'Common/Enums';
|
||||
|
||||
@@ -458,13 +458,13 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||
(iError, data) => {
|
||||
this.sending(false);
|
||||
if (iError) {
|
||||
if (Notification.CantSaveMessage === iError) {
|
||||
if (Notifications.CantSaveMessage === iError) {
|
||||
this.sendSuccessButSaveError(true);
|
||||
this.savedErrorDesc(i18n('COMPOSE/SAVED_ERROR_ON_SEND').trim());
|
||||
} else {
|
||||
this.sendError(true);
|
||||
this.sendErrorDesc(getNotification(iError, data?.ErrorMessage)
|
||||
|| getNotification(Notification.CantSendMessage));
|
||||
|| getNotification(Notifications.CantSendMessage));
|
||||
}
|
||||
} else {
|
||||
this.close();
|
||||
@@ -531,7 +531,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||
|
||||
if (!result) {
|
||||
this.savedError(true);
|
||||
this.savedErrorDesc(getNotification(Notification.CantSaveMessage));
|
||||
this.savedErrorDesc(getNotification(Notifications.CantSaveMessage));
|
||||
}
|
||||
|
||||
reloadDraftFolder();
|
||||
@@ -542,7 +542,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||
}).catch(e => {
|
||||
this.saving(false);
|
||||
this.savedError(true);
|
||||
this.savedErrorDesc(getNotification(Notification.CantSaveMessage) + ': ' + e);
|
||||
this.savedErrorDesc(getNotification(Notifications.CantSaveMessage) + ': ' + e);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -612,7 +612,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||
data.Result.map(item => (item?.[0] ? (new EmailModel(item[0], item[1])).toLine() : null))
|
||||
.filter(v => v)
|
||||
);
|
||||
} else if (Notification.RequestAborted !== iError) {
|
||||
} else if (Notifications.RequestAborted !== iError) {
|
||||
fResponse([]);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { koComputable, addObservablesTo } from 'External/ko';
|
||||
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { Notifications } from 'Common/Enums';
|
||||
import { defaultOptionsAfterRender } from 'Common/Utils';
|
||||
import { folderListOptionsBuilder, sortFolders } from 'Common/Folders';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
@@ -65,7 +65,7 @@ export class FolderCreatePopupView extends AbstractViewPopup {
|
||||
},
|
||||
error => {
|
||||
FolderUserStore.folderListError(
|
||||
getNotification(error.code, '', Notification.CantCreateFolder)
|
||||
getNotification(error.code, '', Notifications.CantCreateFolder)
|
||||
+ '.\n' + error.message);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { Notifications } from 'Common/Enums';
|
||||
import { ClientSideKeyNameLastSignMe } from 'Common/EnumsUser';
|
||||
import { SettingsGet, fireEvent } from 'Common/Globals';
|
||||
import { getNotification, translatorReload, convertLangName } from 'Common/Translator';
|
||||
@@ -120,11 +120,11 @@ export class LoginUserView extends AbstractViewLogin {
|
||||
});
|
||||
if (iError) {
|
||||
this.submitRequest(false);
|
||||
if (Notification.InvalidInputArgument == iError) {
|
||||
iError = Notification.AuthError;
|
||||
if (Notifications.InvalidInputArgument == iError) {
|
||||
iError = Notifications.AuthError;
|
||||
}
|
||||
this.submitError(getNotification(iError, oData?.ErrorMessage,
|
||||
Notification.UnknownNotification));
|
||||
Notifications.UnknownNotification));
|
||||
this.submitErrorAdditional(oData?.ErrorMessageAdditional);
|
||||
} else {
|
||||
rl.setData(oData.Result);
|
||||
|
||||
4
dev/bootstrap.js
vendored
4
dev/bootstrap.js
vendored
@@ -90,10 +90,10 @@ export default App => {
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
// console.log(data);
|
||||
return Promise.reject(Notification.JsonParse);
|
||||
return Promise.reject(Notifications.JsonParse);
|
||||
return {
|
||||
Result: false,
|
||||
ErrorCode: 952, // Notification.JsonParse
|
||||
ErrorCode: 952, // Notifications.JsonParse
|
||||
ErrorMessage: e.message,
|
||||
ErrorMessageAdditional: data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user