2021-03-11 05:41:35 +08:00
|
|
|
import { AppUserStore } from 'Stores/User/App';
|
|
|
|
import { AccountUserStore } from 'Stores/User/Account';
|
2021-11-13 16:46:59 +08:00
|
|
|
//import { FolderUserStore } from 'Stores/User/Folder';
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2022-03-06 05:25:32 +08:00
|
|
|
import { Scope } from 'Common/Enums';
|
2022-03-03 23:28:05 +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
|
|
|
|
2022-03-04 21:43:58 +08:00
|
|
|
import { doc, leftPanelDisabled, fireEvent, SettingsCapa, registerShortcut } from 'Common/Globals';
|
2021-02-17 03:12:23 +08:00
|
|
|
|
|
|
|
import { ThemeStore } from 'Stores/Theme';
|
2020-09-04 18:05:17 +08:00
|
|
|
|
2021-11-12 04:01:39 +08:00
|
|
|
import Remote from 'Remote/User/Fetch';
|
|
|
|
import { getNotification } from 'Common/Translator';
|
2021-11-13 16:46:59 +08:00
|
|
|
//import { clearCache } from 'Common/Cache';
|
2021-12-31 20:30:05 +08:00
|
|
|
//import { koComputable } from 'External/ko';
|
2021-11-12 00:14:06 +08:00
|
|
|
|
2021-09-23 16:40:10 +08:00
|
|
|
export class SystemDropDownUserView extends AbstractViewRight {
|
2021-09-23 15:41:02 +08:00
|
|
|
constructor() {
|
2022-03-08 19:28:16 +08:00
|
|
|
super();
|
2015-04-10 16:17:49 +08:00
|
|
|
|
2022-03-06 05:25:32 +08:00
|
|
|
this.allowAccounts = SettingsCapa('AdditionalAccounts');
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
this.accountEmail = AccountUserStore.email;
|
2015-04-10 16:17:49 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
this.accounts = AccountUserStore.accounts;
|
|
|
|
this.accountsLoading = AccountUserStore.loading;
|
2021-12-02 18:12:21 +08:00
|
|
|
/*
|
2021-12-31 20:30:05 +08:00
|
|
|
this.accountsUnreadCount = : koComputable(() => 0);
|
|
|
|
this.accountsUnreadCount = : koComputable(() => AccountUserStore.accounts().reduce((result, item) => result + item.count(), 0));
|
2021-12-02 18:12:21 +08:00
|
|
|
*/
|
2015-04-10 16:17:49 +08:00
|
|
|
|
2020-10-27 18:09:24 +08:00
|
|
|
this.addObservables({
|
2021-03-17 17:09:10 +08:00
|
|
|
currentAudio: '',
|
2021-03-23 21:48:34 +08:00
|
|
|
accountMenuDropdownTrigger: false
|
2020-10-27 18:09:24 +08:00
|
|
|
});
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2021-03-17 17:05:22 +08:00
|
|
|
this.allowContacts = AppUserStore.allowContacts();
|
2021-02-09 04:19:58 +08:00
|
|
|
|
2021-03-17 17:09:10 +08:00
|
|
|
addEventListener('audio.stop', () => this.currentAudio(''));
|
|
|
|
addEventListener('audio.start', e => this.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() {
|
2022-02-11 19:21:16 +08:00
|
|
|
fireEvent('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) {
|
2022-03-07 20:47:18 +08:00
|
|
|
let email = account && account.email;
|
|
|
|
if (email && 0 === event.button && AccountUserStore.email() != email) {
|
2021-03-11 05:41:35 +08:00
|
|
|
AccountUserStore.loading(true);
|
2021-11-12 04:01:39 +08:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2021-12-03 06:15:24 +08:00
|
|
|
Remote.request('AccountSwitch',
|
2021-11-12 04:01:39 +08:00
|
|
|
(iError/*, oData*/) => {
|
|
|
|
if (iError) {
|
|
|
|
AccountUserStore.loading(false);
|
2022-03-07 20:47:18 +08:00
|
|
|
alert(getNotification(iError).replace('%EMAIL%', email));
|
2021-11-15 17:56:52 +08:00
|
|
|
if (account.isAdditional()) {
|
2021-11-12 06:22:04 +08:00
|
|
|
showScreenPopup(AccountPopupView, [account]);
|
|
|
|
}
|
2021-11-12 04:01:39 +08:00
|
|
|
} else {
|
2021-11-13 16:46:59 +08:00
|
|
|
/* // Not working yet
|
2021-12-01 21:23:37 +08:00
|
|
|
forEachObjectEntry(oData.Result, (key, value) => rl.settings.set(key, value));
|
2021-11-13 16:46:59 +08:00
|
|
|
clearCache();
|
|
|
|
// MessageUserStore.setMessage();
|
|
|
|
// MessageUserStore.purgeMessageBodyCache();
|
|
|
|
// MessageUserStore.hideMessageBodies();
|
2022-02-24 02:26:52 +08:00
|
|
|
MessagelistUserStore([]);
|
2021-11-13 16:46:59 +08:00
|
|
|
// FolderUserStore.folderList([]);
|
2022-02-24 02:26:52 +08:00
|
|
|
loadFolders(value => {
|
2021-11-13 16:46:59 +08:00
|
|
|
if (value) {
|
|
|
|
// 4. Change to INBOX = reload MessageList
|
2022-02-24 02:26:52 +08:00
|
|
|
// MessagelistUserStore.setMessageList();
|
2021-11-13 16:46:59 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
AccountUserStore.loading(false);
|
2021-11-12 16:36:08 +08:00
|
|
|
*/
|
2022-03-03 23:28:05 +08:00
|
|
|
rl.route.reload();
|
2021-11-12 04:01:39 +08:00
|
|
|
}
|
2022-03-07 20:47:18 +08:00
|
|
|
}, {Email:email}
|
2021-11-12 04:01:39 +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() {
|
2021-03-11 05:41:35 +08:00
|
|
|
return AccountUserStore.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() {
|
2022-03-03 23:28:05 +08:00
|
|
|
hasher.setHash(settings());
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
settingsHelp() {
|
2021-09-17 20:37:18 +08:00
|
|
|
showScreenPopup(KeyboardShortcutsHelpPopupView);
|
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() {
|
2021-03-23 21:48:34 +08:00
|
|
|
this.allowAccounts && showScreenPopup(AccountPopupView);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
|
2021-02-09 04:19:58 +08:00
|
|
|
contactsClick() {
|
2021-03-23 21:48:34 +08:00
|
|
|
this.allowContacts && showScreenPopup(ContactsPopupView);
|
2021-02-09 04:19:58 +08:00
|
|
|
}
|
|
|
|
|
2021-09-14 16:06:38 +08:00
|
|
|
toggleLayout()
|
2021-02-17 03:12:23 +08:00
|
|
|
{
|
2021-09-14 16:06:38 +08:00
|
|
|
const mobile = !ThemeStore.isMobile();
|
2022-02-08 21:15:22 +08:00
|
|
|
doc.cookie = 'rllayout=' + (mobile ? 'mobile' : 'desktop') + '; samesite=strict';
|
2021-09-14 16:06:38 +08:00
|
|
|
ThemeStore.isMobile(mobile);
|
|
|
|
leftPanelDisabled(mobile);
|
2021-02-17 03:12:23 +08:00
|
|
|
}
|
|
|
|
|
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() {
|
2022-03-04 21:43:58 +08:00
|
|
|
registerShortcut('m', '', [Scope.MessageList, Scope.MessageView, Scope.Settings], () => {
|
2021-09-23 02:17:44 +08:00
|
|
|
if (!this.viewModelDom.hidden) {
|
2022-03-22 18:47:17 +08:00
|
|
|
// exitFullscreen();
|
2016-08-17 06:01:20 +08:00
|
|
|
this.accountMenuDropdownTrigger(true);
|
2020-10-09 21:00:26 +08:00
|
|
|
return false;
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// shortcuts help
|
2022-03-04 21:43:58 +08:00
|
|
|
registerShortcut('?,f1,help', '', [Scope.MessageList, Scope.MessageView, Scope.Settings], () => {
|
2021-09-23 02:17:44 +08:00
|
|
|
if (!this.viewModelDom.hidden) {
|
2021-01-26 05:00:13 +08:00
|
|
|
showScreenPopup(KeyboardShortcutsHelpPopupView);
|
2016-08-17 06:01:20 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|