snappymail/dev/App/Abstract.js

57 lines
1.3 KiB
JavaScript
Raw Normal View History

import ko from 'ko';
2016-06-07 05:57:52 +08:00
2021-01-27 19:02:37 +08:00
import { logoutLink } from 'Common/Links';
import { i18nToNodes, initOnStartOrLangChange } from 'Common/Translator';
2015-11-19 01:32:29 +08:00
2024-03-11 02:09:17 +08:00
import { arePopupsVisible } from 'Knoin/Knoin';
import { LanguageStore } from 'Stores/Language';
2023-03-18 06:20:42 +08:00
import { initThemes } from 'Stores/Theme';
import { SelectComponent } from 'Component/Select';
import { CheckboxComponent } from 'Component/Checkbox';
2021-01-22 23:32:08 +08:00
export class AbstractApp {
2014-08-20 23:03:12 +08:00
/**
* @param {RemoteStorage|AdminRemoteStorage} Remote
2014-08-20 23:03:12 +08:00
*/
constructor(Remote) {
this.Remote = Remote;
}
2022-10-19 05:32:47 +08:00
logoutReload(url) {
2024-03-11 02:09:17 +08:00
arePopupsVisible(false);
2022-10-19 05:32:47 +08:00
url = url || logoutLink();
2021-01-27 19:02:37 +08:00
if (location.href !== url) {
setTimeout(() => location.href = url, 100);
2019-07-05 03:19:24 +08:00
} else {
rl.route.reload();
2014-08-20 23:03:12 +08:00
}
2022-10-19 05:32:47 +08:00
// this does not work due to ViewModelClass.__builded = true;
// rl.settings.set('Auth', false);
// rl.app.start();
2015-11-19 01:32:29 +08:00
}
2015-11-19 01:32:29 +08:00
bootstart() {
2022-10-10 19:52:56 +08:00
const register = (name, ClassObject) => ko.components.register(name, {
template: { element: ClassObject.name },
viewModel: {
createViewModel: (params, componentInfo) => {
params = params || {};
2022-02-17 16:36:29 +08:00
i18nToNodes(componentInfo.element);
return new ClassObject(params);
}
}
});
register('Select', SelectComponent);
register('Checkbox', CheckboxComponent);
2014-08-20 23:03:12 +08:00
initOnStartOrLangChange();
LanguageStore.populate();
2023-03-18 06:20:42 +08:00
initThemes();
2020-09-17 05:19:34 +08:00
this.start();
2020-09-17 05:19:34 +08:00
}
2015-11-19 01:32:29 +08:00
}