snappymail/dev/View/User/AbstractSystemDropDown.js

115 lines
2.8 KiB
JavaScript
Raw Normal View History

import { AppUserStore } from 'Stores/User/App';
import { AccountUserStore } from 'Stores/User/Account';
import { MessageUserStore } from 'Stores/User/Message';
2014-08-21 23:08:34 +08:00
import { Capa, Scope } from 'Common/Enums';
2019-07-05 03:19:24 +08:00
import { settings } from 'Common/Links';
2014-08-25 15:10:51 +08:00
import { showScreenPopup } from 'Knoin/Knoin';
import { AbstractViewRight } from 'Knoin/AbstractViews';
import { KeyboardShortcutsHelpPopupView } from 'View/Popup/KeyboardShortcutsHelp';
import { AccountPopupView } from 'View/Popup/Account';
import { ContactsPopupView } from 'View/Popup/Contacts';
import { doc, Settings, leftPanelDisabled } from 'Common/Globals';
import { ThemeStore } from 'Stores/Theme';
export class AbstractSystemDropDownUserView extends AbstractViewRight {
constructor(name) {
super(name, 'SystemDropDown');
2015-04-10 16:17:49 +08:00
2021-03-23 21:48:34 +08:00
this.allowAccounts = Settings.capa(Capa.AdditionalAccounts);
2021-03-10 18:44:48 +08:00
this.allowSettings = Settings.capa(Capa.Settings);
this.allowHelp = Settings.capa(Capa.Help);
this.accountEmail = AccountUserStore.email;
2015-04-10 16:17:49 +08:00
this.accounts = AccountUserStore.accounts;
this.accountsLoading = AccountUserStore.loading;
this.accountsUnreadCount = AccountUserStore.accountsUnreadCount;
2015-04-10 16:17:49 +08:00
2020-10-27 18:09:24 +08:00
this.addObservables({
currentAudio: '',
2021-03-23 21:48:34 +08:00
accountMenuDropdownTrigger: false
2020-10-27 18:09:24 +08:00
});
this.allowContacts = AppUserStore.allowContacts();
addEventListener('audio.stop', () => this.currentAudio(''));
addEventListener('audio.start', e => this.currentAudio(e.detail));
2016-06-30 08:02:45 +08:00
}
stopPlay() {
dispatchEvent(new CustomEvent('audio.api.stop'));
}
accountClick(account, event) {
if (account && 0 === event.button) {
AccountUserStore.loading(true);
setTimeout(() => AccountUserStore.loading(false), 1000);
}
return true;
2016-06-30 08:02:45 +08:00
}
emailTitle() {
return AccountUserStore.email();
2016-06-30 08:02:45 +08:00
}
2014-04-29 23:31:49 +08:00
settingsClick() {
2021-03-23 21:48:34 +08:00
this.allowSettings && rl.route.setHash(settings());
2016-06-30 08:02:45 +08:00
}
2019-07-05 03:19:24 +08:00
settingsHelp() {
2021-03-23 21:48:34 +08:00
this.allowHelp && showScreenPopup(KeyboardShortcutsHelpPopupView);
}
addAccountClick() {
2021-03-23 21:48:34 +08:00
this.allowAccounts && showScreenPopup(AccountPopupView);
}
contactsClick() {
2021-03-23 21:48:34 +08:00
this.allowContacts && showScreenPopup(ContactsPopupView);
}
layoutDesktop()
{
doc.cookie = 'rllayout=desktop';
ThemeStore.isMobile(false);
leftPanelDisabled(false);
// location.reload();
}
layoutMobile()
{
doc.cookie = 'rllayout=mobile';
ThemeStore.isMobile(true);
leftPanelDisabled(true);
// location.reload();
}
logoutClick() {
2020-09-15 15:29:25 +08:00
rl.app.logout();
}
onBuild() {
shortcuts.add('m,contextmenu', '', [Scope.MessageList, Scope.MessageView, Scope.Settings], () => {
2020-10-02 18:40:33 +08:00
if (this.viewModelVisible) {
MessageUserStore.messageFullScreenMode(false);
this.accountMenuDropdownTrigger(true);
return false;
}
});
// shortcuts help
shortcuts.add('?,f1,help', '', [Scope.MessageList, Scope.MessageView, Scope.Settings], () => {
2020-10-02 18:40:33 +08:00
if (this.viewModelVisible) {
showScreenPopup(KeyboardShortcutsHelpPopupView);
return false;
}
});
}
}