mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 16:07:03 +03:00
Replace missed $.ajax with window.fetch
This commit is contained in:
parent
dca0ff02ed
commit
134cb7d52a
2 changed files with 28 additions and 22 deletions
|
|
@ -263,13 +263,23 @@ export function reload(admin, language) {
|
||||||
|
|
||||||
$htmlCL.add('rl-changing-language');
|
$htmlCL.add('rl-changing-language');
|
||||||
|
|
||||||
return new window.Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
$.ajax({
|
return window.fetch(langLink(language, admin), {cache: 'reload'})
|
||||||
url: langLink(language, admin),
|
.then(response => {
|
||||||
dataType: 'script',
|
if (response.ok) {
|
||||||
cache: true
|
const type = response.headers.get('Content-Type');
|
||||||
}).then(
|
if (type.includes('application/javascript')) {
|
||||||
() => {
|
return response.text();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reject(new Error('Invalid response'))
|
||||||
|
}, error => {
|
||||||
|
reject(new Error(error.message))
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
var doc = window.document, script = doc.createElement('script');
|
||||||
|
script.text = data;
|
||||||
|
doc.head.appendChild(script).parentNode.removeChild(script);
|
||||||
setTimeout(
|
setTimeout(
|
||||||
() => {
|
() => {
|
||||||
reloadData();
|
reloadData();
|
||||||
|
|
@ -277,20 +287,14 @@ export function reload(admin, language) {
|
||||||
const isRtl = ['ar', 'ar_sa', 'he', 'he_he', 'ur', 'ur_ir'].includes((language || '').toLowerCase());
|
const isRtl = ['ar', 'ar_sa', 'he', 'he_he', 'ur', 'ur_ir'].includes((language || '').toLowerCase());
|
||||||
|
|
||||||
$htmlCL.remove('rl-changing-language', 'rl-rtl', 'rl-ltr');
|
$htmlCL.remove('rl-changing-language', 'rl-rtl', 'rl-ltr');
|
||||||
// $html.attr('dir', isRtl ? 'rtl' : 'ltr')
|
// $html.attr('dir', isRtl ? 'rtl' : 'ltr')
|
||||||
$htmlCL.add(isRtl ? 'rl-rtl' : 'rl-ltr');
|
$htmlCL.add(isRtl ? 'rl-rtl' : 'rl-ltr');
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
},
|
},
|
||||||
500 < microtime() - start ? 1 : 500
|
500 < microtime() - start ? 1 : 500
|
||||||
);
|
);
|
||||||
},
|
});
|
||||||
() => {
|
|
||||||
$htmlCL.remove('rl-changing-language');
|
|
||||||
window.rainloopI18N = null;
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1161,15 +1161,17 @@ export function changeTheme(value, themeTrigger = noop) {
|
||||||
|
|
||||||
themeTrigger(SaveSettingsStep.Animate);
|
themeTrigger(SaveSettingsStep.Animate);
|
||||||
|
|
||||||
if (__themeAjax && __themeAjax.abort) {
|
if (__themeAjax) {
|
||||||
__themeAjax.abort();
|
__themeAjax.abort();
|
||||||
}
|
}
|
||||||
|
let init = {};
|
||||||
__themeAjax = $.ajax({
|
if (window.AbortController) {
|
||||||
url: url,
|
__themeAjax = new window.AbortController();
|
||||||
dataType: 'json'
|
init.signal = __themeAjax.signal;
|
||||||
})
|
}
|
||||||
.then((data) => {
|
window.fetch(url, init)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
if (data && isArray(data) && 2 === data.length) {
|
if (data && isArray(data) && 2 === data.length) {
|
||||||
if (themeLink && themeLink[0] && (!themeStyle || !themeStyle[0])) {
|
if (themeLink && themeLink[0] && (!themeStyle || !themeStyle[0])) {
|
||||||
themeStyle = $('<style id="app-theme-style"></style>');
|
themeStyle = $('<style id="app-theme-style"></style>');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue