mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-09-08 22:24:14 +08:00
Bugfix: invalid settingsGet in dev/Stores/Admin/App.js
Cleanup login/logout location reloading
This commit is contained in:
parent
aeb5275648
commit
097fb4896d
13 changed files with 51 additions and 92 deletions
18
README.md
18
README.md
|
@ -86,23 +86,23 @@ Things might work in Edge 18, Firefox 50-62 and Chrome 54-68 due to one polyfill
|
|||
|
||||
|js/* |1.14.0 |native |
|
||||
|----------- |--------: |--------: |
|
||||
|admin.js |2.130.942 | 942.565 |
|
||||
|app.js |4.184.455 |2.563.204 |
|
||||
|admin.js |2.130.942 | 939.722 |
|
||||
|app.js |4.184.455 |2.559.620 |
|
||||
|boot.js | 671.522 | 7.265 |
|
||||
|libs.js | 647.614 | 312.269 |
|
||||
|polyfills.js | 325.834 | 0 |
|
||||
|TOTAL |7.960.367 |3.825.303 |
|
||||
|TOTAL |7.960.367 |3.818.876 |
|
||||
|
||||
|js/min/* |1.14.0 |native |gzip 1.14 |gzip |brotli |
|
||||
|--------------- |--------: |--------: |--------: |--------: |--------: |
|
||||
|admin.min.js | 252.147 | 129.058 | 73.657 | 37.631 | 32.250 |
|
||||
|app.min.js | 511.202 | 350.074 |140.462 | 91.841 | 73.757 |
|
||||
|boot.min.js | 66.007 | 4.274 | 22.567 | 1.934 | 1.635 |
|
||||
|libs.min.js | 572.545 | 295.776 |176.720 | 91.524 | 80.746 |
|
||||
|admin.min.js | 252.147 | 128.874 | 73.657 | 37.574 | 32.236 |
|
||||
|app.min.js | 511.202 | 349.777 |140.462 | 91.836 | 73.775 |
|
||||
|boot.min.js | 66.007 | 4.258 | 22.567 | 1.946 | 1.648 |
|
||||
|libs.min.js | 572.545 | 295.716 |176.720 | 91.532 | 80.863 |
|
||||
|polyfills.min.js | 32.452 | 0 | 11.312 | 0 | 0 |
|
||||
|TOTAL |1.434.353 | 779.182 |424.718 |222.930 |188.388 |
|
||||
|TOTAL |1.434.353 | 778.625 |424.718 |222.888 |188.522 |
|
||||
|
||||
655.171 bytes (201.788 gzip) is not much, but it feels faster.
|
||||
655.728 bytes (201.830 gzip) is not much, but it feels faster.
|
||||
|
||||
### CSS changes
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@ import {
|
|||
} from 'Common/Globals';
|
||||
|
||||
import { KeyState } from 'Common/Enums';
|
||||
import { root, rootAdmin, rootUser } from 'Common/Links';
|
||||
import { rootAdmin, rootUser } from 'Common/Links';
|
||||
import { initOnStartOrLangChange, initNotificationLanguage } from 'Common/Translator';
|
||||
|
||||
import LanguageStore from 'Stores/Language';
|
||||
import ThemeStore from 'Stores/Theme';
|
||||
|
||||
import { routeOff, setHash } from 'Knoin/Knoin';
|
||||
import { routeReload } from 'Knoin/Knoin';
|
||||
import { AbstractBoot } from 'Knoin/AbstractBoot';
|
||||
|
||||
const Settings = rl.settings;
|
||||
|
@ -76,10 +76,6 @@ class AbstractApp extends AbstractBoot {
|
|||
return true;
|
||||
}
|
||||
|
||||
redirectToAdminPanel() {
|
||||
setTimeout(() => location.href = rootAdmin(), 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} token
|
||||
*/
|
||||
|
@ -88,43 +84,16 @@ class AbstractApp extends AbstractBoot {
|
|||
Settings.set('AuthAccountHash', token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean=} admin = false
|
||||
* @param {boolean=} logout = false
|
||||
* @param {boolean=} close = false
|
||||
*/
|
||||
loginAndLogoutReload(admin = false, logout = false, close = false) {
|
||||
const inIframe = !!Settings.app('inIframe'),
|
||||
logoutLink = admin ? rootAdmin() : rootUser();
|
||||
logoutReload(close = false) {
|
||||
const logoutLink = rl.adminArea() ? rootAdmin() : rootUser();
|
||||
|
||||
if (logout) {
|
||||
rl.hash.clear();
|
||||
}
|
||||
rl.hash.clear();
|
||||
close && window.close && window.close();
|
||||
|
||||
if (logout && close && window.close) {
|
||||
window.close();
|
||||
}
|
||||
|
||||
if (logout && location.href !== logoutLink) {
|
||||
setTimeout(() => {
|
||||
if (inIframe && parent) {
|
||||
parent.location.href = logoutLink;
|
||||
} else {
|
||||
location.href = logoutLink;
|
||||
}
|
||||
}, 100);
|
||||
if (location.href !== logoutLink) {
|
||||
setTimeout(() => (Settings.app('inIframe') ? parent : window).location.href = logoutLink, 100);
|
||||
} else {
|
||||
routeOff();
|
||||
setHash(root(), true);
|
||||
routeOff();
|
||||
|
||||
setTimeout(() => {
|
||||
if (inIframe && parent) {
|
||||
parent.location.reload();
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
}, 100);
|
||||
routeReload();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,11 +125,7 @@ class AppUser extends AbstractApp {
|
|||
}
|
||||
|
||||
reload() {
|
||||
if (parent && !!Settings.app('inIframe')) {
|
||||
parent.location.reload();
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
(Settings.app('inIframe') ? parent : window).location.reload();
|
||||
}
|
||||
|
||||
reloadFlagsCurrentMessageListAndMessageFromCache() {
|
||||
|
@ -896,13 +892,7 @@ class AppUser extends AbstractApp {
|
|||
}
|
||||
|
||||
logout() {
|
||||
Remote.logout(() => {
|
||||
this.loginAndLogoutReload(
|
||||
false,
|
||||
true,
|
||||
0 < (Settings.get('ParentEmail')||{length:0}).length
|
||||
);
|
||||
});
|
||||
Remote.logout(() => this.logoutReload(0 < (Settings.get('ParentEmail')||{length:0}).length));
|
||||
}
|
||||
|
||||
bootstartTwoFactorScreen() {
|
||||
|
|
|
@ -2,6 +2,8 @@ import ko from 'ko';
|
|||
|
||||
import { $htmlCL, VIEW_MODELS } from 'Common/Globals';
|
||||
|
||||
import { root } from 'Common/Links';
|
||||
|
||||
//import { bMobileDevice } from 'Common/Globals';
|
||||
|
||||
let currentScreen = null,
|
||||
|
@ -80,6 +82,16 @@ export function addSettingsViewModel(SettingsViewModelClass, template, labelName
|
|||
VIEW_MODELS.settings.push(SettingsViewModelClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
export function routeReload() {
|
||||
routeOff();
|
||||
setHash(root(), true);
|
||||
routeOff();
|
||||
setTimeout(() => (rl.settings.app('inIframe') ? parent : window).location.reload(), 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
|
|
|
@ -130,17 +130,15 @@ class AbstractAjaxPromises extends AbstractBasicPromises {
|
|||
}
|
||||
|
||||
if (TOKEN_ERROR_LIMIT < GlobalsData.iTokenErrorCount) {
|
||||
if (GlobalsData.__APP__ && GlobalsData.__APP__.loginAndLogoutReload) {
|
||||
GlobalsData.__APP__.loginAndLogoutReload(false, true);
|
||||
}
|
||||
rl.logoutReload();
|
||||
}
|
||||
|
||||
if (data.ClearAuth || data.Logout || AJAX_ERROR_LIMIT < GlobalsData.iAjaxErrorCount) {
|
||||
if (GlobalsData.__APP__) {
|
||||
rl.hash.clear();
|
||||
|
||||
if (!data.ClearAuth && GlobalsData.__APP__.loginAndLogoutReload) {
|
||||
GlobalsData.__APP__.loginAndLogoutReload(false, true);
|
||||
if (!data.ClearAuth) {
|
||||
rl.logoutReload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,17 +60,15 @@ class AbstractAjaxRemote {
|
|||
}
|
||||
|
||||
if (TOKEN_ERROR_LIMIT < GlobalsData.iTokenErrorCount) {
|
||||
if (GlobalsData.__APP__ && GlobalsData.__APP__.loginAndLogoutReload) {
|
||||
GlobalsData.__APP__.loginAndLogoutReload(false, true);
|
||||
}
|
||||
rl.logoutReload();
|
||||
}
|
||||
|
||||
if (oData.ClearAuth || oData.Logout || AJAX_ERROR_LIMIT < GlobalsData.iAjaxErrorCount) {
|
||||
if (GlobalsData.__APP__) {
|
||||
rl.hash.clear();
|
||||
|
||||
if (!oData.ClearAuth && GlobalsData.__APP__.loginAndLogoutReload) {
|
||||
GlobalsData.__APP__.loginAndLogoutReload(false, true);
|
||||
if (!oData.ClearAuth) {
|
||||
rl.logoutReload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class AppAdminStore extends AbstractAppStore {
|
|||
populate() {
|
||||
super.populate();
|
||||
|
||||
const settingsGet = rl.settings
|
||||
const settingsGet = rl.settings.get;
|
||||
this.determineUserLanguage(!!settingsGet('DetermineUserLanguage'));
|
||||
this.determineUserDomain(!!settingsGet('DetermineUserDomain'));
|
||||
|
||||
|
|
|
@ -5,9 +5,7 @@ import { getNotification } from 'Common/Translator';
|
|||
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
||||
import { getApp } from 'Helper/Apps/Admin';
|
||||
|
||||
import { view, command, ViewType, routeOff } from 'Knoin/Knoin';
|
||||
import { view, command, ViewType, routeOff, routeReload } from 'Knoin/Knoin';
|
||||
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
|
@ -70,7 +68,7 @@ class LoginAdminView extends AbstractViewNext {
|
|||
(sResult, oData) => {
|
||||
if (StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action) {
|
||||
if (oData.Result) {
|
||||
getApp().loginAndLogoutReload(true);
|
||||
routeReload();
|
||||
} else if (oData.ErrorCode) {
|
||||
this.submitRequest(false);
|
||||
this.submitError(getNotification(oData.ErrorCode));
|
||||
|
|
|
@ -6,8 +6,6 @@ import DomainStore from 'Stores/Admin/Domain';
|
|||
import PluginStore from 'Stores/Admin/Plugin';
|
||||
import PackageStore from 'Stores/Admin/Package';
|
||||
|
||||
import { getApp } from 'Helper/Apps/Admin';
|
||||
|
||||
import { view, ViewType } from 'Knoin/Knoin';
|
||||
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
|
||||
|
||||
|
@ -38,9 +36,7 @@ class PaneSettingsAdminView extends AbstractViewNext {
|
|||
}
|
||||
|
||||
logoutClick() {
|
||||
Remote.adminLogout(() => {
|
||||
getApp().loginAndLogoutReload(true, true);
|
||||
});
|
||||
Remote.adminLogout(() => rl.logoutReload());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@ import * as Local from 'Storage/Client';
|
|||
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import { getApp } from 'Helper/Apps/User';
|
||||
|
||||
import { view, command, ViewType, routeOff, showScreenPopup } from 'Knoin/Knoin';
|
||||
import { view, command, ViewType, routeOff, showScreenPopup, routeReload } from 'Knoin/Knoin';
|
||||
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
|
||||
|
||||
import { rootAdmin } from 'Common/Links';
|
||||
|
||||
const Settings = rl.settings;
|
||||
|
||||
@view({
|
||||
|
@ -180,9 +180,9 @@ class LoginUserView extends AbstractViewNext {
|
|||
|
||||
setTimeout(() => this.querySelector('.inputAdditionalCode').focus(), 100);
|
||||
} else if (oData.Admin) {
|
||||
getApp().redirectToAdminPanel();
|
||||
setTimeout(() => location.href = rootAdmin(), 100);
|
||||
} else {
|
||||
getApp().loginAndLogoutReload(false);
|
||||
routeReload();
|
||||
}
|
||||
} else if (oData.ErrorCode) {
|
||||
this.submitRequest(false);
|
||||
|
|
5
dev/bootstrap.js
vendored
5
dev/bootstrap.js
vendored
|
@ -34,7 +34,8 @@ export default (App) => {
|
|||
$htmlCL.add(bMobileDevice ? 'mobile' : 'no-mobile');
|
||||
addEventListener('click', ()=>rl.Dropdowns.detectVisibility());
|
||||
|
||||
const rl = window.rl || {};
|
||||
rl.app = App;
|
||||
rl.logoutReload = () => App && App.logoutReload && App.logoutReload();
|
||||
|
||||
rl.i18n = i18n;
|
||||
|
||||
|
@ -57,8 +58,6 @@ export default (App) => {
|
|||
dropdownVisibility(!!rl.Dropdowns.find(item => item.classList.contains('open')))
|
||||
).debounce(50);
|
||||
|
||||
window.rl = rl;
|
||||
|
||||
window.__APP_BOOT = fErrorCallback => {
|
||||
const doc = document,
|
||||
cb = () => setTimeout(() => {
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
"gulp-size": "3.0.0",
|
||||
"gulp-sourcemaps": "2.6.5",
|
||||
"gulp-stripbom": "1.0.5",
|
||||
"gulp-terser": "^1.2.0",
|
||||
"gulp-terser": "^1.4.0",
|
||||
"gulp-through": "0.4.0",
|
||||
"gulp-util": "3.0.8",
|
||||
"gulp-zip": "5.0.1",
|
||||
|
@ -97,7 +97,6 @@
|
|||
"style-loader": "1.1.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"gulp-terser": "^1.2.0",
|
||||
"webpack": "4.42.0",
|
||||
"webpack-cli": "3.3.11"
|
||||
}
|
||||
|
|
|
@ -3381,7 +3381,7 @@ gulp-stripbom@1.0.5:
|
|||
strip-bom "^1.0.0"
|
||||
through2 "^0.5.1"
|
||||
|
||||
gulp-terser@^1.2.0:
|
||||
gulp-terser@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/gulp-terser/-/gulp-terser-1.4.0.tgz#0ac4dfdbed4ab46906007c5b358810c1642b9764"
|
||||
integrity sha512-7df9leJna3WOmj76tYHxjpn7BSU+vmKVjVSd6bz3uLEyrzCfZI97KPhRcIabrSNzs0UY/UXTt+JwkxPw3sF85w==
|
||||
|
|
Loading…
Add table
Reference in a new issue