mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 14:07:04 +03:00
Rename 'ajax' to 'json' because we don't use XML
We use json as response
This commit is contained in:
parent
76cf24f426
commit
950579c7f5
18 changed files with 83 additions and 91 deletions
|
|
@ -411,10 +411,10 @@ export const Notification = {
|
|||
ClientViewError: 902,
|
||||
InvalidInputArgument: 903,
|
||||
|
||||
AjaxFalse: 950,
|
||||
AjaxAbort: 951,
|
||||
AjaxParse: 952,
|
||||
AjaxTimeout: 953,
|
||||
JsonFalse: 950,
|
||||
JsonAbort: 951,
|
||||
JsonParse: 952,
|
||||
// JsonTimeout: 953,
|
||||
|
||||
UnknownNotification: 999,
|
||||
UnknownError: 999
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ export function settingsSaveHelperSimpleFunction(koTrigger, context) {
|
|||
}
|
||||
|
||||
let __themeTimer = 0,
|
||||
__themeAjax = null;
|
||||
__themeJson = null;
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
|
|
@ -98,7 +98,7 @@ export function changeTheme(value, themeTrigger = ()=>{}) {
|
|||
const themeLink = doc.getElementById('app-theme-link'),
|
||||
clearTimer = () => {
|
||||
__themeTimer = setTimeout(() => themeTrigger(SaveSettingsStep.Idle), 1000);
|
||||
__themeAjax = null;
|
||||
__themeJson = null;
|
||||
};
|
||||
|
||||
let themeStyle = doc.getElementById('app-theme-style'),
|
||||
|
|
@ -118,13 +118,13 @@ export function changeTheme(value, themeTrigger = ()=>{}) {
|
|||
|
||||
themeTrigger(SaveSettingsStep.Animate);
|
||||
|
||||
if (__themeAjax) {
|
||||
__themeAjax.abort();
|
||||
if (__themeJson) {
|
||||
__themeJson.abort();
|
||||
}
|
||||
let init = {};
|
||||
if (window.AbortController) {
|
||||
__themeAjax = new AbortController();
|
||||
init.signal = __themeAjax.signal;
|
||||
__themeJson = new AbortController();
|
||||
init.signal = __themeJson.signal;
|
||||
}
|
||||
rl.fetchJSON(url, init)
|
||||
.then(data => {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ import { StorageResultType, Notification } from 'Common/Enums';
|
|||
import { pInt, pString } from 'Common/Utils';
|
||||
import { serverRequest } from 'Common/Links';
|
||||
|
||||
let iAjaxErrorCount = 0,
|
||||
let iJsonErrorCount = 0,
|
||||
iTokenErrorCount = 0,
|
||||
bUnload = false;
|
||||
|
||||
const getURL = (add = '') => serverRequest('Ajax') + add,
|
||||
const getURL = (add = '') => serverRequest('Json') + add,
|
||||
|
||||
updateToken = data => {
|
||||
if (data.UpdateToken) {
|
||||
|
|
@ -28,7 +28,7 @@ checkResponseError = data => {
|
|||
Notification.UnknownError
|
||||
].includes(err)
|
||||
) {
|
||||
++iAjaxErrorCount;
|
||||
++iJsonErrorCount;
|
||||
}
|
||||
|
||||
if (Notification.InvalidToken === err) {
|
||||
|
|
@ -39,7 +39,7 @@ checkResponseError = data => {
|
|||
rl.logoutReload();
|
||||
}
|
||||
|
||||
if (window.rl && (data.ClearAuth || data.Logout || 7 < iAjaxErrorCount)) {
|
||||
if (window.rl && (data.ClearAuth || data.Logout || 7 < iJsonErrorCount)) {
|
||||
rl.hash.clear();
|
||||
|
||||
if (!data.ClearAuth) {
|
||||
|
|
@ -118,7 +118,7 @@ class AbstractFetchRemote
|
|||
if (StorageResultType.Success === sType && data && !data.Result) {
|
||||
checkResponseError(data);
|
||||
} else if (StorageResultType.Success === sType && data && data.Result) {
|
||||
iAjaxErrorCount = iTokenErrorCount = 0;
|
||||
iJsonErrorCount = iTokenErrorCount = 0;
|
||||
}
|
||||
|
||||
if (fCallback) {
|
||||
|
|
@ -152,7 +152,7 @@ class AbstractFetchRemote
|
|||
|
||||
}).catch(err => {
|
||||
if (err.name == 'AbortError') { // handle abort()
|
||||
err = Notification.AjaxAbort;
|
||||
err = Notification.JsonAbort;
|
||||
}
|
||||
return Promise.reject(err);
|
||||
});
|
||||
|
|
@ -222,7 +222,7 @@ class AbstractFetchRemote
|
|||
this.abort(action, true);
|
||||
|
||||
if (!data) {
|
||||
return Promise.reject(Notification.AjaxParse);
|
||||
return Promise.reject(Notification.JsonParse);
|
||||
}
|
||||
|
||||
updateToken(data);
|
||||
|
|
@ -249,13 +249,13 @@ class AbstractFetchRemote
|
|||
if (!data.Result || action !== data.Action) {
|
||||
checkResponseError(data);
|
||||
const err = data ? data.ErrorCode : null;
|
||||
return Promise.reject(err || Notification.AjaxFalse);
|
||||
return Promise.reject(err || Notification.JsonFalse);
|
||||
}
|
||||
|
||||
return data;
|
||||
}).catch(err => {
|
||||
if (err.name == 'AbortError') { // handle abort()
|
||||
return Promise.reject(Notification.AjaxAbort);
|
||||
return Promise.reject(Notification.JsonAbort);
|
||||
}
|
||||
return Promise.reject(err);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue