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