2016-08-17 06:01:20 +08:00
|
|
|
import AppStore from 'Stores/User/App';
|
|
|
|
import AccountStore from 'Stores/User/Account';
|
|
|
|
import MessageStore from 'Stores/User/Message';
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2020-08-14 04:58:41 +08:00
|
|
|
import { Capa, KeyState } from 'Common/Enums';
|
2019-07-05 03:19:24 +08:00
|
|
|
import { settings } from 'Common/Links';
|
2014-08-25 15:10:51 +08:00
|
|
|
|
2020-09-17 02:35:29 +08:00
|
|
|
import { showScreenPopup } from 'Knoin/Knoin';
|
2021-01-24 17:25:23 +08:00
|
|
|
import { AbstractViewRight } from 'Knoin/AbstractViews';
|
2015-05-20 06:05:54 +08:00
|
|
|
|
2021-01-26 05:00:13 +08:00
|
|
|
import { KeyboardShortcutsHelpPopupView } from 'View/Popup/KeyboardShortcutsHelp';
|
|
|
|
import { AccountPopupView } from 'View/Popup/Account';
|
2021-02-09 04:19:58 +08:00
|
|
|
import { ContactsPopupView } from 'View/Popup/Contacts';
|
2021-01-26 05:00:13 +08:00
|
|
|
|
2021-01-27 07:26:31 +08:00
|
|
|
import { Settings } from 'Common/Globals';
|
2020-09-04 18:05:17 +08:00
|
|
|
|
2021-01-24 17:25:23 +08:00
|
|
|
export class AbstractSystemDropDownUserView extends AbstractViewRight {
|
|
|
|
constructor(name) {
|
|
|
|
super(name, 'SystemDropDown');
|
2015-04-10 16:17:49 +08:00
|
|
|
|
2020-09-04 18:05:17 +08:00
|
|
|
this.mobile = !!Settings.app('mobile');
|
|
|
|
this.mobileDevice = !!Settings.app('mobileDevice');
|
2014-04-12 09:05:57 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.allowSettings = !!Settings.capa(Capa.Settings);
|
|
|
|
this.allowHelp = !!Settings.capa(Capa.Help);
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.currentAudio = AppStore.currentAudio;
|
2015-04-10 16:17:49 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.accountEmail = AccountStore.email;
|
2015-04-10 16:17:49 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.accounts = AccountStore.accounts;
|
|
|
|
this.accountsUnreadCount = AccountStore.accountsUnreadCount;
|
2015-04-10 16:17:49 +08:00
|
|
|
|
2020-10-27 18:09:24 +08:00
|
|
|
this.addObservables({
|
|
|
|
accountMenuDropdownTrigger: false,
|
|
|
|
capaAdditionalAccounts: Settings.capa(Capa.AdditionalAccounts)
|
|
|
|
});
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2021-02-09 04:19:58 +08:00
|
|
|
this.allowContacts = !!AppStore.contactsIsAllowed();
|
|
|
|
|
2020-07-20 21:47:33 +08:00
|
|
|
this.addAccountClick = this.addAccountClick.bind(this);
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2020-08-15 02:35:39 +08:00
|
|
|
addEventListener('audio.stop', () => AppStore.currentAudio(''));
|
|
|
|
addEventListener('audio.start', e => AppStore.currentAudio(e.detail));
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2015-02-02 04:46:23 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
stopPlay() {
|
2020-08-15 02:35:39 +08:00
|
|
|
dispatchEvent(new CustomEvent('audio.api.stop'));
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-09-03 07:19:37 +08:00
|
|
|
accountClick(account, event) {
|
2020-07-30 03:49:41 +08:00
|
|
|
if (account && event && undefined !== event.which && 1 === event.which) {
|
2016-08-17 06:01:20 +08:00
|
|
|
AccountStore.accounts.loading(true);
|
2020-08-14 04:58:41 +08:00
|
|
|
setTimeout(() => AccountStore.accounts.loading(false), 1000);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
return true;
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
emailTitle() {
|
|
|
|
return AccountStore.email();
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2014-04-29 23:31:49 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
settingsClick() {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.Settings)) {
|
2020-09-17 02:35:29 +08:00
|
|
|
rl.route.setHash(settings());
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
settingsHelp() {
|
|
|
|
if (Settings.capa(Capa.Help)) {
|
2021-01-26 05:00:13 +08:00
|
|
|
showScreenPopup(KeyboardShortcutsHelpPopupView);
|
2015-05-20 06:05:54 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
addAccountClick() {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (this.capaAdditionalAccounts()) {
|
2021-01-26 05:00:13 +08:00
|
|
|
showScreenPopup(AccountPopupView);
|
2013-11-16 06:21:12 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
|
2021-02-09 04:19:58 +08:00
|
|
|
contactsClick() {
|
|
|
|
if (this.allowContacts) {
|
|
|
|
showScreenPopup(ContactsPopupView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
logoutClick() {
|
2020-09-15 15:29:25 +08:00
|
|
|
rl.app.logout();
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
onBuild() {
|
2020-10-09 21:00:26 +08:00
|
|
|
shortcuts.add('m,contextmenu', '', [KeyState.MessageList, KeyState.MessageView, KeyState.Settings], () => {
|
2020-10-02 18:40:33 +08:00
|
|
|
if (this.viewModelVisible) {
|
2016-08-17 06:01:20 +08:00
|
|
|
MessageStore.messageFullScreenMode(false);
|
|
|
|
this.accountMenuDropdownTrigger(true);
|
2020-10-09 21:00:26 +08:00
|
|
|
return false;
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// shortcuts help
|
2020-10-09 16:31:44 +08:00
|
|
|
shortcuts.add('?,f1,help', '', [KeyState.MessageList, KeyState.MessageView, KeyState.Settings], () => {
|
2020-10-02 18:40:33 +08:00
|
|
|
if (this.viewModelVisible) {
|
2021-01-26 05:00:13 +08:00
|
|
|
showScreenPopup(KeyboardShortcutsHelpPopupView);
|
2016-08-17 06:01:20 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|