2021-01-26 18:46:30 +08:00
|
|
|
import 'External/User/ko';
|
2021-01-26 05:00:13 +08:00
|
|
|
|
2022-03-31 23:39:53 +08:00
|
|
|
import { isArray, pString, changeTheme } from 'Common/Utils';
|
2022-03-08 17:52:08 +08:00
|
|
|
import { mailToHelper, setLayoutResizer, dropdownsDetectVisibility } from 'Common/UtilsUser';
|
2016-06-07 05:57:52 +08:00
|
|
|
|
2021-01-25 05:58:06 +08:00
|
|
|
import {
|
2019-07-05 03:19:24 +08:00
|
|
|
FolderType,
|
|
|
|
SetSystemFoldersNotification,
|
2022-03-14 22:42:05 +08:00
|
|
|
ClientSideKeyNameFolderListSize
|
2021-01-25 05:58:06 +08:00
|
|
|
} from 'Common/EnumsUser';
|
2016-06-07 05:57:52 +08:00
|
|
|
|
2021-02-17 03:12:23 +08:00
|
|
|
import {
|
|
|
|
doc,
|
|
|
|
elementById,
|
|
|
|
$htmlCL,
|
|
|
|
Settings,
|
2021-03-10 18:44:48 +08:00
|
|
|
SettingsGet,
|
2022-02-24 18:19:19 +08:00
|
|
|
leftPanelDisabled,
|
2022-03-09 22:08:22 +08:00
|
|
|
addEventsListener,
|
|
|
|
addShortcut
|
2021-02-17 03:12:23 +08:00
|
|
|
} from 'Common/Globals';
|
2016-06-07 05:57:52 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
2016-08-22 05:30:34 +08:00
|
|
|
|
|
|
|
import {
|
2020-10-25 20:50:26 +08:00
|
|
|
MessageFlagsCache,
|
2019-07-05 03:19:24 +08:00
|
|
|
setFolderHash,
|
|
|
|
getFolderHash,
|
|
|
|
getFolderInboxName,
|
2020-10-25 20:50:26 +08:00
|
|
|
getFolderFromCacheList
|
2016-08-22 05:30:34 +08:00
|
|
|
} from 'Common/Cache';
|
|
|
|
|
2022-02-24 02:26:52 +08:00
|
|
|
import { i18n, reloadTime } from 'Common/Translator';
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
import { SettingsUserStore } from 'Stores/User/Settings';
|
|
|
|
import { NotificationUserStore } from 'Stores/User/Notification';
|
|
|
|
import { AccountUserStore } from 'Stores/User/Account';
|
|
|
|
import { ContactUserStore } from 'Stores/User/Contact';
|
2021-02-17 21:40:21 +08:00
|
|
|
import { IdentityUserStore } from 'Stores/User/Identity';
|
2021-03-11 05:41:35 +08:00
|
|
|
import { FolderUserStore } from 'Stores/User/Folder';
|
|
|
|
import { PgpUserStore } from 'Stores/User/Pgp';
|
2022-02-24 02:26:52 +08:00
|
|
|
import { MessagelistUserStore } from 'Stores/User/Messagelist';
|
2021-02-17 03:12:23 +08:00
|
|
|
import { ThemeStore } from 'Stores/Theme';
|
2022-03-31 23:39:53 +08:00
|
|
|
import { LanguageStore } from 'Stores/Language';
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2020-09-15 01:40:56 +08:00
|
|
|
import Remote from 'Remote/User/Fetch';
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
import { AccountModel } from 'Model/Account';
|
|
|
|
import { IdentityModel } from 'Model/Identity';
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
import { LoginUserScreen } from 'Screen/User/Login';
|
|
|
|
import { MailBoxUserScreen } from 'Screen/User/MailBox';
|
|
|
|
import { SettingsUserScreen } from 'Screen/User/Settings';
|
2016-07-07 07:11:13 +08:00
|
|
|
|
2021-08-31 22:17:20 +08:00
|
|
|
import { startScreens, showScreenPopup, arePopupsVisible } from 'Knoin/Knoin';
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
import { AbstractApp } from 'App/Abstract';
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2021-01-26 05:00:13 +08:00
|
|
|
import { ComposePopupView } from 'View/Popup/Compose';
|
|
|
|
import { FolderSystemPopupView } from 'View/Popup/FolderSystem';
|
|
|
|
import { AskPopupView } from 'View/Popup/Ask';
|
2020-09-17 06:02:35 +08:00
|
|
|
|
2022-02-24 06:11:12 +08:00
|
|
|
import {
|
|
|
|
folderInformationMultiply,
|
|
|
|
refreshFoldersInterval,
|
|
|
|
messagesMoveHelper,
|
|
|
|
messagesDeleteHelper,
|
|
|
|
fetchFolderInformation
|
|
|
|
} from 'Common/Folders';
|
2022-02-24 02:26:52 +08:00
|
|
|
import { loadFolders } from 'Model/FolderCollection';
|
2022-02-08 00:27:25 +08:00
|
|
|
|
2022-03-31 23:39:53 +08:00
|
|
|
export class AppUser extends AbstractApp {
|
2016-07-16 05:29:42 +08:00
|
|
|
constructor() {
|
2015-11-19 01:32:29 +08:00
|
|
|
super(Remote);
|
2014-04-09 00:08:16 +08:00
|
|
|
|
2020-07-17 01:49:56 +08:00
|
|
|
// wakeUp
|
2020-08-14 04:58:41 +08:00
|
|
|
const interval = 3600000; // 60m
|
2022-02-24 02:26:52 +08:00
|
|
|
let lastTime = Date.now();
|
2020-07-17 01:49:56 +08:00
|
|
|
setInterval(() => {
|
2020-09-04 23:07:35 +08:00
|
|
|
const currentTime = Date.now();
|
2020-07-17 01:49:56 +08:00
|
|
|
if (currentTime > (lastTime + interval + 1000)) {
|
2021-12-03 06:15:24 +08:00
|
|
|
Remote.request('Version',
|
2022-03-03 23:28:05 +08:00
|
|
|
iError => (100 < iError) && (Settings.app('inIframe') ? parent : window).location.reload(),
|
2021-12-03 06:15:24 +08:00
|
|
|
{ Version: Settings.app('version') }
|
|
|
|
);
|
2020-07-17 01:49:56 +08:00
|
|
|
}
|
|
|
|
lastTime = currentTime;
|
|
|
|
}, interval);
|
2014-08-22 23:08:56 +08:00
|
|
|
|
2021-03-03 00:39:02 +08:00
|
|
|
const fn = (ev=>$htmlCL.toggle('rl-ctrl-key-pressed', ev.ctrlKey)).debounce(500);
|
2022-02-24 18:19:19 +08:00
|
|
|
addEventsListener(doc, ['keydown','keyup'], fn);
|
2021-02-17 21:40:21 +08:00
|
|
|
|
2022-03-09 22:08:22 +08:00
|
|
|
addShortcut('escape,enter', '', dropdownsDetectVisibility);
|
2022-03-08 17:52:08 +08:00
|
|
|
addEventListener('click', dropdownsDetectVisibility);
|
2022-05-18 23:15:31 +08:00
|
|
|
|
|
|
|
this.folderList = FolderUserStore.folderList;
|
2013-11-16 06:21:12 +08:00
|
|
|
}
|
|
|
|
|
2022-03-31 23:39:53 +08:00
|
|
|
refresh() {
|
|
|
|
LanguageStore.language(SettingsGet('Language'));
|
|
|
|
ThemeStore.populate();
|
|
|
|
changeTheme(SettingsGet('Theme'));
|
|
|
|
this.start();
|
|
|
|
}
|
|
|
|
|
2014-08-20 23:03:12 +08:00
|
|
|
/**
|
|
|
|
* @param {number} iDeleteType
|
2021-11-30 17:19:43 +08:00
|
|
|
* @param {string} sFromFolderFullName
|
2014-08-20 23:03:12 +08:00
|
|
|
* @param {Array} aUidForRemove
|
|
|
|
* @param {boolean=} bUseFolder = true
|
|
|
|
*/
|
2021-11-30 17:19:43 +08:00
|
|
|
deleteMessagesFromFolder(iDeleteType, sFromFolderFullName, aUidForRemove, bUseFolder) {
|
2019-07-05 03:19:24 +08:00
|
|
|
let oMoveFolder = null,
|
2016-06-30 08:02:45 +08:00
|
|
|
nSetSystemFoldersNotification = null;
|
2014-03-20 00:18:28 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
switch (iDeleteType) {
|
2016-06-07 05:57:52 +08:00
|
|
|
case FolderType.Spam:
|
2021-03-11 05:41:35 +08:00
|
|
|
oMoveFolder = getFolderFromCacheList(FolderUserStore.spamFolder());
|
2016-06-07 05:57:52 +08:00
|
|
|
nSetSystemFoldersNotification = SetSystemFoldersNotification.Spam;
|
2014-08-20 23:03:12 +08:00
|
|
|
break;
|
2016-06-07 05:57:52 +08:00
|
|
|
case FolderType.NotSpam:
|
2016-08-22 05:30:34 +08:00
|
|
|
oMoveFolder = getFolderFromCacheList(getFolderInboxName());
|
2014-08-20 23:03:12 +08:00
|
|
|
break;
|
2016-06-07 05:57:52 +08:00
|
|
|
case FolderType.Trash:
|
2021-03-11 05:41:35 +08:00
|
|
|
oMoveFolder = getFolderFromCacheList(FolderUserStore.trashFolder());
|
2016-06-07 05:57:52 +08:00
|
|
|
nSetSystemFoldersNotification = SetSystemFoldersNotification.Trash;
|
2014-08-20 23:03:12 +08:00
|
|
|
break;
|
2016-06-07 05:57:52 +08:00
|
|
|
case FolderType.Archive:
|
2021-03-11 05:41:35 +08:00
|
|
|
oMoveFolder = getFolderFromCacheList(FolderUserStore.archiveFolder());
|
2016-06-07 05:57:52 +08:00
|
|
|
nSetSystemFoldersNotification = SetSystemFoldersNotification.Archive;
|
2014-08-20 23:03:12 +08:00
|
|
|
break;
|
2016-06-30 08:02:45 +08:00
|
|
|
// no default
|
2014-08-20 23:03:12 +08:00
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2020-07-30 03:49:41 +08:00
|
|
|
bUseFolder = undefined === bUseFolder ? true : !!bUseFolder;
|
2019-07-05 03:19:24 +08:00
|
|
|
if (bUseFolder) {
|
|
|
|
if (
|
2021-03-11 05:41:35 +08:00
|
|
|
(FolderType.Spam === iDeleteType && UNUSED_OPTION_VALUE === FolderUserStore.spamFolder()) ||
|
|
|
|
(FolderType.Trash === iDeleteType && UNUSED_OPTION_VALUE === FolderUserStore.trashFolder()) ||
|
|
|
|
(FolderType.Archive === iDeleteType && UNUSED_OPTION_VALUE === FolderUserStore.archiveFolder())
|
2019-07-05 03:19:24 +08:00
|
|
|
) {
|
2014-08-20 23:03:12 +08:00
|
|
|
bUseFolder = false;
|
2013-11-16 06:21:12 +08:00
|
|
|
}
|
|
|
|
}
|
2014-08-20 23:03:12 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (!oMoveFolder && bUseFolder) {
|
2021-01-26 05:00:13 +08:00
|
|
|
showScreenPopup(FolderSystemPopupView, [nSetSystemFoldersNotification]);
|
2019-07-05 03:19:24 +08:00
|
|
|
} else if (
|
|
|
|
!bUseFolder ||
|
|
|
|
(FolderType.Trash === iDeleteType &&
|
2021-11-30 17:19:43 +08:00
|
|
|
(sFromFolderFullName === FolderUserStore.spamFolder()
|
|
|
|
|| sFromFolderFullName === FolderUserStore.trashFolder()))
|
2019-07-05 03:19:24 +08:00
|
|
|
) {
|
2021-01-26 05:00:13 +08:00
|
|
|
showScreenPopup(AskPopupView, [
|
2019-07-05 03:19:24 +08:00
|
|
|
i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'),
|
|
|
|
() => {
|
2022-02-24 02:26:52 +08:00
|
|
|
messagesDeleteHelper(sFromFolderFullName, aUidForRemove);
|
|
|
|
MessagelistUserStore.removeMessagesFromList(sFromFolderFullName, aUidForRemove);
|
2019-07-05 03:19:24 +08:00
|
|
|
}
|
|
|
|
]);
|
|
|
|
} else if (oMoveFolder) {
|
2022-02-24 02:26:52 +08:00
|
|
|
messagesMoveHelper(sFromFolderFullName, oMoveFolder.fullName, aUidForRemove);
|
|
|
|
MessagelistUserStore.removeMessagesFromList(sFromFolderFullName, aUidForRemove, oMoveFolder.fullName);
|
2014-08-20 23:03:12 +08:00
|
|
|
}
|
2015-11-19 01:32:29 +08:00
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2020-08-15 02:35:39 +08:00
|
|
|
accountsAndIdentities() {
|
2021-03-11 05:41:35 +08:00
|
|
|
AccountUserStore.loading(true);
|
2021-02-17 21:40:21 +08:00
|
|
|
IdentityUserStore.loading(true);
|
2014-05-13 16:29:36 +08:00
|
|
|
|
2021-12-03 06:15:24 +08:00
|
|
|
Remote.request('AccountsAndIdentities', (iError, oData) => {
|
2021-03-11 05:41:35 +08:00
|
|
|
AccountUserStore.loading(false);
|
2021-02-17 21:40:21 +08:00
|
|
|
IdentityUserStore.loading(false);
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2021-03-18 21:48:21 +08:00
|
|
|
if (!iError) {
|
2021-12-02 18:12:21 +08:00
|
|
|
const
|
|
|
|
// counts = {},
|
2021-11-15 17:56:52 +08:00
|
|
|
accounts = oData.Result.Accounts,
|
|
|
|
mainEmail = SettingsGet('MainEmail');
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2021-11-15 17:56:52 +08:00
|
|
|
if (isArray(accounts)) {
|
2021-12-02 18:12:21 +08:00
|
|
|
// AccountUserStore.accounts.forEach(oAccount => counts[oAccount.email] = oAccount.count());
|
2014-12-18 04:53:46 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
AccountUserStore.accounts(
|
2021-11-15 17:56:52 +08:00
|
|
|
accounts.map(
|
2021-12-02 18:12:21 +08:00
|
|
|
sValue => new AccountModel(sValue/*, counts[sValue]*/)
|
2019-07-05 03:19:24 +08:00
|
|
|
)
|
|
|
|
);
|
2021-11-15 17:56:52 +08:00
|
|
|
// accounts.length &&
|
2021-12-02 18:12:21 +08:00
|
|
|
AccountUserStore.accounts.unshift(new AccountModel(mainEmail/*, counts[mainEmail]*/, false));
|
2014-08-20 23:03:12 +08:00
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2021-03-16 23:49:14 +08:00
|
|
|
if (isArray(oData.Result.Identities)) {
|
2021-02-17 21:40:21 +08:00
|
|
|
IdentityUserStore(
|
2020-07-23 02:09:31 +08:00
|
|
|
oData.Result.Identities.map(identityData => {
|
2021-11-15 17:56:52 +08:00
|
|
|
const identity = new IdentityModel(
|
|
|
|
pString(identityData.Id),
|
|
|
|
pString(identityData.Email)
|
|
|
|
);
|
2013-12-07 06:45:46 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
identity.name(pString(identityData.Name));
|
|
|
|
identity.replyTo(pString(identityData.ReplyTo));
|
|
|
|
identity.bcc(pString(identityData.Bcc));
|
|
|
|
identity.signature(pString(identityData.Signature));
|
|
|
|
identity.signatureInsertBefore(!!identityData.SignatureInsertBefore);
|
2013-12-07 06:45:46 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
return identity;
|
|
|
|
})
|
|
|
|
);
|
2013-11-16 06:21:12 +08:00
|
|
|
}
|
|
|
|
}
|
2014-08-20 23:03:12 +08:00
|
|
|
});
|
2015-11-19 01:32:29 +08:00
|
|
|
}
|
|
|
|
|
2014-08-20 23:03:12 +08:00
|
|
|
/**
|
2015-11-19 01:32:29 +08:00
|
|
|
* @param {string} folder
|
|
|
|
* @param {Array=} list = []
|
2014-08-20 23:03:12 +08:00
|
|
|
*/
|
2015-11-19 01:32:29 +08:00
|
|
|
folderInformation(folder, list) {
|
2020-07-30 03:49:41 +08:00
|
|
|
if (folder && folder.trim()) {
|
2022-02-24 06:11:12 +08:00
|
|
|
fetchFolderInformation(
|
2021-03-16 16:46:23 +08:00
|
|
|
(iError, data) => {
|
2021-08-17 18:08:09 +08:00
|
|
|
if (!iError && data.Result) {
|
|
|
|
const result = data.Result,
|
|
|
|
hash = getFolderHash(result.Folder),
|
|
|
|
folderFromCache = getFolderFromCacheList(result.Folder);
|
2021-03-16 16:46:23 +08:00
|
|
|
if (folderFromCache) {
|
2021-03-18 20:52:56 +08:00
|
|
|
folderFromCache.expires = Date.now();
|
2021-03-16 16:46:23 +08:00
|
|
|
|
2021-08-17 18:08:09 +08:00
|
|
|
setFolderHash(result.Folder, result.Hash);
|
2013-12-16 01:16:25 +08:00
|
|
|
|
2021-08-17 18:08:09 +08:00
|
|
|
folderFromCache.messageCountAll(result.MessageCount);
|
2019-07-05 03:19:24 +08:00
|
|
|
|
2021-08-17 18:08:09 +08:00
|
|
|
let unreadCountChange = (folderFromCache.messageCountUnread() !== result.MessageUnseenCount);
|
2014-08-20 23:03:12 +08:00
|
|
|
|
2021-08-17 18:08:09 +08:00
|
|
|
folderFromCache.messageCountUnread(result.MessageUnseenCount);
|
2014-08-20 23:03:12 +08:00
|
|
|
|
2021-03-16 16:46:23 +08:00
|
|
|
if (unreadCountChange) {
|
2021-11-23 04:01:30 +08:00
|
|
|
MessageFlagsCache.clearFolder(folderFromCache.fullName);
|
2021-03-16 16:46:23 +08:00
|
|
|
}
|
2014-08-20 23:03:12 +08:00
|
|
|
|
2021-08-17 18:08:09 +08:00
|
|
|
if (result.Flags.length) {
|
2021-12-06 23:08:58 +08:00
|
|
|
result.Flags.forEach(message =>
|
2021-12-07 02:25:28 +08:00
|
|
|
MessageFlagsCache.setFor(folderFromCache.fullName, message.Uid.toString(), message.Flags)
|
2021-08-17 18:08:09 +08:00
|
|
|
);
|
2019-07-05 03:19:24 +08:00
|
|
|
|
2022-02-24 02:26:52 +08:00
|
|
|
MessagelistUserStore.reloadFlagsAndCachedMessage();
|
2021-03-16 16:46:23 +08:00
|
|
|
}
|
|
|
|
|
2022-02-24 02:26:52 +08:00
|
|
|
MessagelistUserStore.initUidNextAndNewMessages(
|
2021-11-23 04:01:30 +08:00
|
|
|
folderFromCache.fullName,
|
2021-08-17 18:08:09 +08:00
|
|
|
result.UidNext,
|
|
|
|
result.NewMessages
|
2021-03-16 16:46:23 +08:00
|
|
|
);
|
|
|
|
|
2021-08-17 18:08:09 +08:00
|
|
|
if (!hash || unreadCountChange || result.Hash !== hash) {
|
2021-11-30 17:19:43 +08:00
|
|
|
if (folderFromCache.fullName === FolderUserStore.currentFolderFullName()) {
|
2022-02-24 02:26:52 +08:00
|
|
|
MessagelistUserStore.reload();
|
2021-11-23 04:01:30 +08:00
|
|
|
} else if (getFolderInboxName() === folderFromCache.fullName) {
|
2021-11-13 16:45:06 +08:00
|
|
|
Remote.messageList(null, {Folder: getFolderInboxName()}, true);
|
2014-08-20 23:03:12 +08:00
|
|
|
}
|
2013-12-16 01:16:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-07-05 03:19:24 +08:00
|
|
|
},
|
|
|
|
folder,
|
|
|
|
list
|
|
|
|
);
|
2014-08-20 23:03:12 +08:00
|
|
|
}
|
2016-04-21 01:12:51 +08:00
|
|
|
}
|
2013-12-16 01:16:25 +08:00
|
|
|
|
2015-11-19 01:32:29 +08:00
|
|
|
logout() {
|
2022-03-09 20:11:28 +08:00
|
|
|
Remote.request('Logout', () => {
|
|
|
|
const customLogoutLink = Settings.app('customLogoutLink');
|
|
|
|
if (customLogoutLink) {
|
|
|
|
((window.parent && Settings.app('inIframe')) ? window.parent : window).location.href = customLogoutLink;
|
|
|
|
} else {
|
|
|
|
rl.logoutReload()
|
|
|
|
}
|
|
|
|
});
|
2016-04-21 01:12:51 +08:00
|
|
|
}
|
2015-02-19 03:52:52 +08:00
|
|
|
|
2015-11-19 01:32:29 +08:00
|
|
|
bootstart() {
|
|
|
|
super.bootstart();
|
2014-05-13 16:29:36 +08:00
|
|
|
|
2021-03-05 23:46:40 +08:00
|
|
|
addEventListener('resize', () => leftPanelDisabled(ThemeStore.isMobile() || 1000 > innerWidth));
|
2021-08-31 22:21:40 +08:00
|
|
|
addEventListener('beforeunload', event => {
|
|
|
|
if (arePopupsVisible()) {
|
|
|
|
event.preventDefault();
|
|
|
|
return event.returnValue = "Are you sure you want to exit?";
|
|
|
|
}
|
|
|
|
}, {capture: true});
|
2021-11-01 18:24:11 +08:00
|
|
|
}
|
2021-03-05 23:46:40 +08:00
|
|
|
|
2021-11-01 18:24:11 +08:00
|
|
|
start() {
|
2021-03-10 18:44:48 +08:00
|
|
|
if (SettingsGet('Auth')) {
|
2021-04-13 01:15:33 +08:00
|
|
|
rl.setWindowTitle(i18n('GLOBAL/LOADING'));
|
2014-08-20 23:03:12 +08:00
|
|
|
|
2021-09-23 20:24:06 +08:00
|
|
|
NotificationUserStore.enableSoundNotification(!!SettingsGet('SoundNotification'));
|
|
|
|
NotificationUserStore.enableDesktopNotification(!!SettingsGet('DesktopNotifications'));
|
|
|
|
|
|
|
|
AccountUserStore.email(SettingsGet('Email'));
|
|
|
|
|
2021-11-19 19:44:53 +08:00
|
|
|
SettingsUserStore.init();
|
2021-11-24 15:36:27 +08:00
|
|
|
ContactUserStore.init();
|
2021-11-19 19:44:53 +08:00
|
|
|
|
2022-02-24 02:26:52 +08:00
|
|
|
loadFolders(value => {
|
2021-04-13 01:15:33 +08:00
|
|
|
try {
|
|
|
|
if (value) {
|
|
|
|
startScreens([
|
|
|
|
MailBoxUserScreen,
|
2021-09-23 17:05:19 +08:00
|
|
|
SettingsUserScreen
|
2021-04-13 01:15:33 +08:00
|
|
|
]);
|
|
|
|
|
|
|
|
setInterval(() => {
|
2021-11-30 17:19:43 +08:00
|
|
|
const cF = FolderUserStore.currentFolderFullName(),
|
2021-04-13 01:15:33 +08:00
|
|
|
iF = getFolderInboxName();
|
|
|
|
this.folderInformation(iF);
|
|
|
|
if (iF !== cF) {
|
|
|
|
this.folderInformation(cF);
|
|
|
|
}
|
2022-02-24 02:26:52 +08:00
|
|
|
folderInformationMultiply();
|
|
|
|
}, refreshFoldersInterval);
|
2014-10-29 06:05:50 +08:00
|
|
|
|
2021-09-23 20:24:06 +08:00
|
|
|
ContactUserStore.init();
|
2014-10-29 06:05:50 +08:00
|
|
|
|
2021-11-13 16:46:59 +08:00
|
|
|
this.accountsAndIdentities();
|
2015-02-19 03:52:52 +08:00
|
|
|
|
2021-04-13 01:15:33 +08:00
|
|
|
setTimeout(() => {
|
2021-11-30 17:19:43 +08:00
|
|
|
const cF = FolderUserStore.currentFolderFullName();
|
2021-04-13 01:15:33 +08:00
|
|
|
if (getFolderInboxName() !== cF) {
|
|
|
|
this.folderInformation(cF);
|
|
|
|
}
|
2022-02-24 02:26:52 +08:00
|
|
|
FolderUserStore.hasCapability('LIST-STATUS') || folderInformationMultiply(true);
|
2021-04-13 01:15:33 +08:00
|
|
|
}, 1000);
|
|
|
|
|
2021-12-03 06:15:24 +08:00
|
|
|
setTimeout(() => Remote.request('AppDelayStart'), 35000);
|
2021-04-13 01:15:33 +08:00
|
|
|
|
2022-01-12 19:11:37 +08:00
|
|
|
// add pointermove ?
|
2022-02-24 18:19:19 +08:00
|
|
|
addEventsListener(doc, ['touchstart','mousemove','keydown'], SettingsUserStore.delayLogout, {passive:true});
|
2021-04-13 01:15:33 +08:00
|
|
|
SettingsUserStore.delayLogout();
|
2021-03-18 23:12:24 +08:00
|
|
|
|
2021-11-13 16:46:59 +08:00
|
|
|
// initLeftSideLayoutResizer
|
|
|
|
setTimeout(() => {
|
|
|
|
const left = elementById('rl-left'),
|
|
|
|
right = elementById('rl-right'),
|
|
|
|
fToggle = () =>
|
2022-03-14 22:42:05 +08:00
|
|
|
setLayoutResizer(left, right, ClientSideKeyNameFolderListSize,
|
2021-11-13 16:46:59 +08:00
|
|
|
(ThemeStore.isMobile() || leftPanelDisabled()) ? 0 : 'Width');
|
|
|
|
if (left && right) {
|
|
|
|
fToggle();
|
|
|
|
leftPanelDisabled.subscribe(fToggle);
|
|
|
|
}
|
|
|
|
}, 1);
|
2021-09-23 20:24:06 +08:00
|
|
|
|
2022-02-24 02:26:52 +08:00
|
|
|
setInterval(reloadTime(), 60000);
|
2021-09-23 20:24:06 +08:00
|
|
|
|
2022-01-20 01:24:07 +08:00
|
|
|
PgpUserStore.init();
|
2022-03-04 22:22:37 +08:00
|
|
|
|
|
|
|
// When auto-login is active
|
|
|
|
if (navigator.registerProtocolHandler) {
|
|
|
|
try {
|
|
|
|
navigator.registerProtocolHandler(
|
|
|
|
'mailto',
|
|
|
|
location.protocol + '//' + location.host + location.pathname + '?mailto&to=%s',
|
|
|
|
(SettingsGet('Title') || 'SnappyMail')
|
|
|
|
);
|
|
|
|
} catch (e) {} // eslint-disable-line no-empty
|
|
|
|
}
|
2022-03-08 17:05:24 +08:00
|
|
|
setTimeout(() => mailToHelper(SettingsGet('MailToEmail')), 500);
|
2021-04-13 01:15:33 +08:00
|
|
|
} else {
|
|
|
|
this.logout();
|
2015-04-08 00:39:43 +08:00
|
|
|
}
|
2021-04-13 01:15:33 +08:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
}
|
|
|
|
});
|
2014-10-30 05:08:53 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
} else {
|
2020-10-13 01:46:41 +08:00
|
|
|
startScreens([LoginUserScreen]);
|
2014-08-20 23:03:12 +08:00
|
|
|
}
|
2021-07-19 20:26:32 +08:00
|
|
|
}
|
|
|
|
|
2021-03-10 18:43:23 +08:00
|
|
|
showMessageComposer(params = [])
|
2021-01-26 05:00:13 +08:00
|
|
|
{
|
2021-09-17 19:58:49 +08:00
|
|
|
showScreenPopup(ComposePopupView, params);
|
2021-01-26 05:00:13 +08:00
|
|
|
}
|
2015-11-19 01:32:29 +08:00
|
|
|
}
|