2019-07-05 03:19:24 +08:00
|
|
|
import { Capa, KeyState } from 'Common/Enums';
|
2021-02-15 22:20:22 +08:00
|
|
|
import { keyScope, leftPanelType, leftPanelDisabled, Settings, isMobile } from 'Common/Globals';
|
2019-07-05 03:19:24 +08:00
|
|
|
import { runSettingsViewModelHooks } from 'Common/Plugins';
|
|
|
|
import { initOnStartOrLangChange, i18n } from 'Common/Translator';
|
2016-07-07 07:11:13 +08:00
|
|
|
|
|
|
|
import AppStore from 'Stores/User/App';
|
|
|
|
import AccountStore from 'Stores/User/Account';
|
|
|
|
|
2021-01-26 18:46:30 +08:00
|
|
|
import { AbstractSettingsScreen, settingsAddViewModel } from 'Screen/AbstractSettings';
|
2019-07-05 03:19:24 +08:00
|
|
|
|
|
|
|
import { GeneralUserSettings } from 'Settings/User/General';
|
|
|
|
import { ContactsUserSettings } from 'Settings/User/Contacts';
|
|
|
|
import { AccountsUserSettings } from 'Settings/User/Accounts';
|
|
|
|
import { FiltersUserSettings } from 'Settings/User/Filters';
|
|
|
|
import { SecurityUserSettings } from 'Settings/User/Security';
|
|
|
|
import { TemplatesUserSettings } from 'Settings/User/Templates';
|
|
|
|
import { FoldersUserSettings } from 'Settings/User/Folders';
|
|
|
|
import { ThemesUserSettings } from 'Settings/User/Themes';
|
|
|
|
import { OpenPgpUserSettings } from 'Settings/User/OpenPgp';
|
|
|
|
|
|
|
|
import { SystemDropDownSettingsUserView } from 'View/User/Settings/SystemDropDown';
|
|
|
|
import { MenuSettingsUserView } from 'View/User/Settings/Menu';
|
|
|
|
import { PaneSettingsUserView } from 'View/User/Settings/Pane';
|
|
|
|
|
2021-01-22 23:32:08 +08:00
|
|
|
export class SettingsUserScreen extends AbstractSettingsScreen {
|
2016-07-16 05:29:42 +08:00
|
|
|
constructor() {
|
2019-07-05 03:19:24 +08:00
|
|
|
super([SystemDropDownSettingsUserView, MenuSettingsUserView, PaneSettingsUserView]);
|
|
|
|
|
|
|
|
initOnStartOrLangChange(
|
2020-10-15 06:26:40 +08:00
|
|
|
() => this.sSettingsTitle = i18n('TITLES/SETTINGS'),
|
|
|
|
() => this.setSettingsTitle()
|
2019-07-05 03:19:24 +08:00
|
|
|
);
|
2016-07-07 07:11:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Function=} fCallback
|
|
|
|
*/
|
|
|
|
setupSettings(fCallback = null) {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (!Settings.capa(Capa.Settings)) {
|
|
|
|
if (fCallback) {
|
2016-07-07 07:11:13 +08:00
|
|
|
fCallback();
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-01-26 05:00:13 +08:00
|
|
|
settingsAddViewModel(GeneralUserSettings, 'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true);
|
2016-07-07 07:11:13 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (AppStore.contactsIsAllowed()) {
|
2021-01-26 05:00:13 +08:00
|
|
|
settingsAddViewModel(ContactsUserSettings, 'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts');
|
2016-07-07 07:11:13 +08:00
|
|
|
}
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.AdditionalAccounts) || Settings.capa(Capa.Identities)) {
|
2021-01-26 05:00:13 +08:00
|
|
|
settingsAddViewModel(
|
2019-07-05 03:19:24 +08:00
|
|
|
AccountsUserSettings,
|
|
|
|
'SettingsAccounts',
|
|
|
|
Settings.capa(Capa.AdditionalAccounts)
|
|
|
|
? 'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME'
|
|
|
|
: 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME',
|
|
|
|
'accounts'
|
|
|
|
);
|
2016-07-07 07:11:13 +08:00
|
|
|
}
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.Sieve)) {
|
2021-01-26 05:00:13 +08:00
|
|
|
settingsAddViewModel(FiltersUserSettings, 'SettingsFilters', 'SETTINGS_LABELS/LABEL_FILTERS_NAME', 'filters');
|
2016-07-07 07:11:13 +08:00
|
|
|
}
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.AutoLogout) || Settings.capa(Capa.TwoFactor)) {
|
2021-01-26 05:00:13 +08:00
|
|
|
settingsAddViewModel(SecurityUserSettings, 'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security');
|
2016-07-07 07:11:13 +08:00
|
|
|
}
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.Templates)) {
|
2021-01-26 05:00:13 +08:00
|
|
|
settingsAddViewModel(
|
2019-07-05 03:19:24 +08:00
|
|
|
TemplatesUserSettings,
|
|
|
|
'SettingsTemplates',
|
|
|
|
'SETTINGS_LABELS/LABEL_TEMPLATES_NAME',
|
|
|
|
'templates'
|
|
|
|
);
|
2016-07-07 07:11:13 +08:00
|
|
|
}
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.Folders)) {
|
2021-01-26 05:00:13 +08:00
|
|
|
settingsAddViewModel(FoldersUserSettings, 'SettingsFolders', 'SETTINGS_LABELS/LABEL_FOLDERS_NAME', 'folders');
|
2016-07-07 07:11:13 +08:00
|
|
|
}
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.Themes)) {
|
2021-01-26 05:00:13 +08:00
|
|
|
settingsAddViewModel(ThemesUserSettings, 'SettingsThemes', 'SETTINGS_LABELS/LABEL_THEMES_NAME', 'themes');
|
2016-07-07 07:11:13 +08:00
|
|
|
}
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.OpenPGP)) {
|
2021-01-26 05:00:13 +08:00
|
|
|
settingsAddViewModel(OpenPgpUserSettings, 'SettingsOpenPGP', 'OpenPGP', 'openpgp');
|
2016-07-07 07:11:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
runSettingsViewModelHooks(false);
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (fCallback) {
|
2016-07-07 07:11:13 +08:00
|
|
|
fCallback();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
onShow() {
|
|
|
|
this.setSettingsTitle();
|
|
|
|
keyScope(KeyState.Settings);
|
|
|
|
leftPanelType('');
|
|
|
|
|
2021-02-15 23:05:38 +08:00
|
|
|
isMobile() && leftPanelDisabled(true);
|
2016-07-07 07:11:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
setSettingsTitle() {
|
|
|
|
const sEmail = AccountStore.email();
|
2020-09-04 18:05:17 +08:00
|
|
|
rl.setWindowTitle((sEmail ? sEmail + ' - ' : '') + this.sSettingsTitle);
|
2016-07-07 07:11:13 +08:00
|
|
|
}
|
|
|
|
}
|