mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 04:59:21 +03:00
Reduce JavaScript footprint
This commit is contained in:
parent
689126c57d
commit
b12852bd08
42 changed files with 240 additions and 426 deletions
|
|
@ -3,7 +3,7 @@ import { Settings } from 'Common/Globals';
|
|||
import { addObservablesTo } from 'External/ko';
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
|
||||
import { i18n, trigger as translatorTrigger } from 'Common/Translator';
|
||||
import { i18n, translateTrigger } from 'Common/Translator';
|
||||
|
||||
export class AdminSettingsAbout /*extends AbstractViewSettings*/ {
|
||||
constructor() {
|
||||
|
|
@ -22,7 +22,7 @@ export class AdminSettingsAbout /*extends AbstractViewSettings*/ {
|
|||
this.coreUpdating = ko.observable(false).extend({ throttle: 100 });
|
||||
|
||||
this.coreVersionHtmlDesc = ko.computed(() => {
|
||||
translatorTrigger();
|
||||
translateTrigger();
|
||||
return i18n('TAB_ABOUT/HTML_NEW_VERSION', { 'VERSION': this.coreVersion() });
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -85,11 +85,7 @@ export class AdminSettingsContacts extends AbstractViewSettings {
|
|||
this.testContactsSuccess(true);
|
||||
} else {
|
||||
this.testContactsError(true);
|
||||
if (data?.Result) {
|
||||
this.testContactsErrorMessage(data.Result.Message || '');
|
||||
} else {
|
||||
this.testContactsErrorMessage('');
|
||||
}
|
||||
this.testContactsErrorMessage(data?.Result?.Message || '');
|
||||
}
|
||||
|
||||
this.testing(false);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export class AdminSettingsPackages extends AbstractViewSettings {
|
|||
oDom.addEventListener('click', event => {
|
||||
// configurePlugin
|
||||
let el = event.target.closestWithin('.package-configure', oDom),
|
||||
data = el ? ko.dataFor(el) : 0;
|
||||
data = el && ko.dataFor(el);
|
||||
data && Remote.request('AdminPluginLoad',
|
||||
(iError, data) => iError || showScreenPopup(PluginPopupView, [data.Result]),
|
||||
{
|
||||
|
|
@ -51,7 +51,7 @@ export class AdminSettingsPackages extends AbstractViewSettings {
|
|||
);
|
||||
// disablePlugin
|
||||
el = event.target.closestWithin('.package-active', oDom);
|
||||
data = el ? ko.dataFor(el) : 0;
|
||||
data = el && ko.dataFor(el);
|
||||
data && this.disablePlugin(data);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,20 +50,18 @@ export class UserSettingsAccounts /*extends AbstractViewSettings*/ {
|
|||
deleteAccount(accountToRemove) {
|
||||
if (accountToRemove?.askDelete()) {
|
||||
this.accountForDeletion(null);
|
||||
if (accountToRemove) {
|
||||
this.accounts.remove((account) => accountToRemove === account);
|
||||
this.accounts.remove(account => accountToRemove === account);
|
||||
|
||||
Remote.request('AccountDelete', (iError, data) => {
|
||||
if (!iError && data.Reload) {
|
||||
rl.route.root();
|
||||
setTimeout(() => location.reload(), 1);
|
||||
} else {
|
||||
rl.app.accountsAndIdentities();
|
||||
}
|
||||
}, {
|
||||
EmailToDelete: accountToRemove.email
|
||||
});
|
||||
}
|
||||
Remote.request('AccountDelete', (iError, data) => {
|
||||
if (!iError && data.Reload) {
|
||||
rl.route.root();
|
||||
setTimeout(() => location.reload(), 1);
|
||||
} else {
|
||||
rl.app.accountsAndIdentities();
|
||||
}
|
||||
}, {
|
||||
EmailToDelete: accountToRemove.email
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -74,13 +72,10 @@ export class UserSettingsAccounts /*extends AbstractViewSettings*/ {
|
|||
deleteIdentity(identityToRemove) {
|
||||
if (identityToRemove?.askDelete()) {
|
||||
this.identityForDeletion(null);
|
||||
|
||||
if (identityToRemove) {
|
||||
IdentityUserStore.remove(oIdentity => identityToRemove === oIdentity);
|
||||
Remote.request('IdentityDelete', () => rl.app.accountsAndIdentities(), {
|
||||
IdToDelete: identityToRemove.id()
|
||||
});
|
||||
}
|
||||
IdentityUserStore.remove(oIdentity => identityToRemove === oIdentity);
|
||||
Remote.request('IdentityDelete', () => rl.app.accountsAndIdentities(), {
|
||||
IdToDelete: identityToRemove.id()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import ko from 'ko';
|
|||
import { koComputable } from 'External/ko';
|
||||
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
import { i18n, trigger as translatorTrigger } from 'Common/Translator';
|
||||
import { i18n, translateTrigger } from 'Common/Translator';
|
||||
import { ContactUserStore } from 'Stores/User/Contact';
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ export class UserSettingsContacts /*extends AbstractViewSettings*/ {
|
|||
this.syncPass = ContactUserStore.syncPass;
|
||||
|
||||
this.syncModeOptions = koComputable(() => {
|
||||
translatorTrigger();
|
||||
translateTrigger();
|
||||
return [
|
||||
{ id: 0, name: i18n('GLOBAL/NO') },
|
||||
{ id: 1, name: i18n('GLOBAL/YES') },
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { EditorDefaultType, Layout } from 'Common/EnumsUser';
|
|||
import { Settings, SettingsGet } from 'Common/Globals';
|
||||
import { isArray } from 'Common/Utils';
|
||||
import { addSubscribablesTo, addComputablesTo } from 'External/ko';
|
||||
import { i18n, trigger as translatorTrigger, translatorReload, convertLangName } from 'Common/Translator';
|
||||
import { i18n, translateTrigger, translatorReload, convertLangName } from 'Common/Translator';
|
||||
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
|
|
@ -66,7 +66,7 @@ export class UserSettingsGeneral extends AbstractViewSettings {
|
|||
},
|
||||
|
||||
editorDefaultTypes: () => {
|
||||
translatorTrigger();
|
||||
translateTrigger();
|
||||
return [
|
||||
{ id: EditorDefaultType.Html, name: i18n('SETTINGS_GENERAL/EDITOR_HTML') },
|
||||
{ id: EditorDefaultType.Plain, name: i18n('SETTINGS_GENERAL/EDITOR_PLAIN') }
|
||||
|
|
@ -74,7 +74,7 @@ export class UserSettingsGeneral extends AbstractViewSettings {
|
|||
},
|
||||
|
||||
msgDefaultActions: () => {
|
||||
translatorTrigger();
|
||||
translateTrigger();
|
||||
return [
|
||||
{ id: 1, name: i18n('MESSAGE/BUTTON_REPLY') }, // ComposeType.Reply,
|
||||
{ id: 2, name: i18n('MESSAGE/BUTTON_REPLY_ALL') } // ComposeType.ReplyAll
|
||||
|
|
@ -82,7 +82,7 @@ export class UserSettingsGeneral extends AbstractViewSettings {
|
|||
},
|
||||
|
||||
layoutTypes: () => {
|
||||
translatorTrigger();
|
||||
translateTrigger();
|
||||
return [
|
||||
{ id: Layout.NoPreview, name: i18n('SETTINGS_GENERAL/LAYOUT_NO_SPLIT') },
|
||||
{ id: Layout.SidePreview, name: i18n('SETTINGS_GENERAL/LAYOUT_VERTICAL_SPLIT') },
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { koComputable } from 'External/ko';
|
||||
|
||||
import { SettingsCapa } from 'Common/Globals';
|
||||
import { i18n, trigger as translatorTrigger } from 'Common/Translator';
|
||||
import { i18n, translateTrigger } from 'Common/Translator';
|
||||
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ export class UserSettingsSecurity extends AbstractViewSettings {
|
|||
|
||||
let i18nLogout = (key, params) => i18n('SETTINGS_SECURITY/AUTOLOGIN_' + key, params);
|
||||
this.autoLogoutOptions = koComputable(() => {
|
||||
translatorTrigger();
|
||||
translateTrigger();
|
||||
return [
|
||||
{ id: 0, name: i18nLogout('NEVER_OPTION_NAME') },
|
||||
{ id: 5, name: i18nLogout('MINUTES_OPTION_NAME', { MINUTES: 5 }) },
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ export class UserSettingsThemes /*extends AbstractViewSettings*/ {
|
|||
this.themeTrigger = ko.observable(SaveSettingStatus.Idle).extend({ debounce: 100 });
|
||||
|
||||
ThemeStore.theme.subscribe(value => {
|
||||
this.themesObjects.forEach(theme => {
|
||||
theme.selected(value === theme.name);
|
||||
});
|
||||
this.themesObjects.forEach(theme => theme.selected(value === theme.name));
|
||||
|
||||
changeTheme(value, this.themeTrigger);
|
||||
|
||||
|
|
@ -69,18 +67,12 @@ export class UserSettingsThemes /*extends AbstractViewSettings*/ {
|
|||
.on('onStart', () => {
|
||||
themeBackground.loading(true);
|
||||
themeBackground.error('');
|
||||
return true;
|
||||
})
|
||||
.on('onComplete', (id, result, data) => {
|
||||
themeBackground.loading(false);
|
||||
|
||||
if (result && id && data?.Result?.Name && data?.Result?.Hash) {
|
||||
themeBackground.name(data.Result.Name);
|
||||
themeBackground.hash(data.Result.Hash);
|
||||
} else {
|
||||
themeBackground.name('');
|
||||
themeBackground.hash('');
|
||||
|
||||
themeBackground.name(data?.Result?.Name || '');
|
||||
themeBackground.hash(data?.Result?.Hash || '');
|
||||
if (!themeBackground.name() || !themeBackground.hash()) {
|
||||
let errorMsg = '';
|
||||
if (data.ErrorCode) {
|
||||
switch (data.ErrorCode) {
|
||||
|
|
@ -96,8 +88,6 @@ export class UserSettingsThemes /*extends AbstractViewSettings*/ {
|
|||
|
||||
themeBackground.error(errorMsg || data.ErrorMessage || i18n('SETTINGS_THEMES/ERROR_UNKNOWN'));
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue