Simplify AppUserStore.contactsIsAllowed

This commit is contained in:
djmaze 2021-03-17 10:05:22 +01:00
parent 8157692a29
commit 676de1ed23
6 changed files with 6 additions and 12 deletions

View file

@ -47,7 +47,6 @@ import {
import { getNotification, i18n } from 'Common/Translator'; import { getNotification, i18n } from 'Common/Translator';
import { AppUserStore } from 'Stores/User/App';
import { SettingsUserStore } from 'Stores/User/Settings'; import { SettingsUserStore } from 'Stores/User/Settings';
import { NotificationUserStore } from 'Stores/User/Notification'; import { NotificationUserStore } from 'Stores/User/Notification';
import { AccountUserStore } from 'Stores/User/Account'; import { AccountUserStore } from 'Stores/User/Account';
@ -887,7 +886,6 @@ class AppUser extends AbstractApp {
addEventListener('resize', () => leftPanelDisabled(ThemeStore.isMobile() || 1000 > innerWidth)); addEventListener('resize', () => leftPanelDisabled(ThemeStore.isMobile() || 1000 > innerWidth));
AppUserStore.populate();
SettingsUserStore.populate(); SettingsUserStore.populate();
NotificationUserStore.populate(); NotificationUserStore.populate();
AccountUserStore.populate(); AccountUserStore.populate();

View file

@ -45,7 +45,7 @@ export class SettingsUserScreen extends AbstractSettingsScreen {
settingsAddViewModel(GeneralUserSettings, 'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true); settingsAddViewModel(GeneralUserSettings, 'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true);
if (AppUserStore.contactsIsAllowed()) { if (AppUserStore.allowContacts()) {
settingsAddViewModel(ContactsUserSettings, 'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts'); settingsAddViewModel(ContactsUserSettings, 'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts');
} }

View file

@ -4,9 +4,7 @@ import { addObservablesTo } from 'Common/Utils';
import { ThemeStore } from 'Stores/Theme'; import { ThemeStore } from 'Stores/Theme';
export const AppUserStore = { export const AppUserStore = {
populate: () => { allowContacts: () => !!SettingsGet('ContactsIsAllowed')
AppUserStore.contactsIsAllowed(!!SettingsGet('ContactsIsAllowed'));
}
}; };
addObservablesTo(AppUserStore, { addObservablesTo(AppUserStore, {
@ -16,9 +14,7 @@ addObservablesTo(AppUserStore, {
threadsAllowed: false, threadsAllowed: false,
composeInEdit: false, composeInEdit: false
contactsIsAllowed: false
}); });
AppUserStore.focusedState.subscribe(value => { AppUserStore.focusedState.subscribe(value => {

View file

@ -125,7 +125,7 @@ class ComposePopupView extends AbstractViewPopup {
this.sLastFocusedField = 'to'; this.sLastFocusedField = 'to';
this.allowContacts = AppUserStore.contactsIsAllowed(); this.allowContacts = AppUserStore.allowContacts();
this.bSkipNextHide = false; this.bSkipNextHide = false;
this.editorDefaultType = SettingsUserStore.editorDefaultType; this.editorDefaultType = SettingsUserStore.editorDefaultType;

View file

@ -36,7 +36,7 @@ export class AbstractSystemDropDownUserView extends AbstractViewRight {
capaAdditionalAccounts: Settings.capa(Capa.AdditionalAccounts) capaAdditionalAccounts: Settings.capa(Capa.AdditionalAccounts)
}); });
this.allowContacts = AppUserStore.contactsIsAllowed(); this.allowContacts = AppUserStore.allowContacts();
this.addAccountClick = this.addAccountClick.bind(this); this.addAccountClick = this.addAccountClick.bind(this);

View file

@ -38,7 +38,7 @@ export class FolderListMailBoxUserView extends AbstractViewLeft {
this.leftPanelDisabled = leftPanelDisabled; this.leftPanelDisabled = leftPanelDisabled;
this.allowComposer = Settings.capa(Capa.Composer); this.allowComposer = Settings.capa(Capa.Composer);
this.allowContacts = AppUserStore.contactsIsAllowed(); this.allowContacts = AppUserStore.allowContacts();
this.folderListFocused = ko.computed(() => Scope.FolderList === AppUserStore.focusedState()); this.folderListFocused = ko.computed(() => Scope.FolderList === AppUserStore.focusedState());