mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 04:29:21 +03:00
Bugfix boostrap alerts.less was accidentally removed
Bugfix Date.fromNow('past'/'future') reversed
Replace Events[pub/sub]('interval.*') with setInterval()
Events[pub/sub] to native
Cleanup knockout extensions
Replaced momentToNode with proper HTML5 <time>
Cleanup Momentor
This commit is contained in:
parent
6541a1de7c
commit
9f1ea1a0fd
44 changed files with 539 additions and 1126 deletions
|
|
@ -13,7 +13,6 @@ import { isNormal, pString, detectDropdownVisibility, windowResizeCallback } fro
|
|||
import { KeyState } from 'Common/Enums';
|
||||
import { root, rootAdmin, rootUser, populateAuthSuffix } from 'Common/Links';
|
||||
import { initOnStartOrLangChange, initNotificationLanguage } from 'Common/Translator';
|
||||
import * as Events from 'Common/Events';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
import LanguageStore from 'Stores/Language';
|
||||
|
|
@ -32,11 +31,9 @@ class AbstractApp extends AbstractBoot {
|
|||
this.isLocalAutocomplete = true;
|
||||
this.lastErrorTime = 0;
|
||||
|
||||
addEventListener('resize', () => Events.pub('window.resize'));
|
||||
|
||||
var t;
|
||||
Events.sub(
|
||||
'window.resize',
|
||||
addEventListener(
|
||||
'resize',
|
||||
()=>{
|
||||
// throttle
|
||||
if (!t) {
|
||||
|
|
@ -47,8 +44,7 @@ class AbstractApp extends AbstractBoot {
|
|||
if ($win.__sizes[0] !== iH || $win.__sizes[1] !== iW) {
|
||||
$win.__sizes[0] = iH;
|
||||
$win.__sizes[1] = iW;
|
||||
|
||||
Events.pub('window.resize.real');
|
||||
dispatchEvent(new CustomEvent('resize.real'));
|
||||
}
|
||||
t = 0;
|
||||
}, 50);
|
||||
|
|
@ -56,16 +52,6 @@ class AbstractApp extends AbstractBoot {
|
|||
}
|
||||
);
|
||||
|
||||
// DEBUG
|
||||
// Events.sub({
|
||||
// 'window.resize': function() {
|
||||
// console.log('window.resize');
|
||||
// },
|
||||
// 'window.resize.real': function() {
|
||||
// console.log('window.resize.real');
|
||||
// }
|
||||
// });
|
||||
|
||||
const $doc = document;
|
||||
$doc.addEventListener('keydown', (event) => {
|
||||
if (event && event.ctrlKey) {
|
||||
|
|
@ -81,8 +67,8 @@ class AbstractApp extends AbstractBoot {
|
|||
var d;
|
||||
const fn = ()=>{
|
||||
// debounce
|
||||
d && clearTimeout(d);
|
||||
d = setTimeout(()=>Events.pub('rl.auto-logout-refresh'), 5000);
|
||||
clearTimeout(d);
|
||||
d = setTimeout(()=>dispatchEvent(new CustomEvent('rl.auto-logout-refresh')), 5000);
|
||||
}
|
||||
|
||||
$doc.addEventListener('mousemove', fn);
|
||||
|
|
@ -211,8 +197,6 @@ class AbstractApp extends AbstractBoot {
|
|||
}
|
||||
|
||||
bootstart() {
|
||||
Events.pub('rl.bootstart');
|
||||
|
||||
const mobile = Settings.appSettingsGet('mobile');
|
||||
|
||||
ko.components.register('SaveTrigger', require('Component/SaveTrigger').default);
|
||||
|
|
@ -239,10 +223,6 @@ class AbstractApp extends AbstractBoot {
|
|||
|
||||
setTimeout(windowResizeCallback, 1000);
|
||||
|
||||
Events.sub('ssm.mobile-enter', () => leftPanelDisabled(true));
|
||||
|
||||
Events.sub('ssm.mobile-leave', () => leftPanelDisabled(false));
|
||||
|
||||
if (!mobile) {
|
||||
$htmlCL.add('rl-desktop');
|
||||
|
||||
|
|
@ -251,11 +231,11 @@ class AbstractApp extends AbstractBoot {
|
|||
query: '(max-width: 767px)',
|
||||
onEnter: () => {
|
||||
$htmlCL.add('ssm-state-mobile');
|
||||
Events.pub('ssm.mobile-enter');
|
||||
leftPanelDisabled(true);
|
||||
},
|
||||
onLeave: () => {
|
||||
$htmlCL.remove('ssm-state-mobile');
|
||||
Events.pub('ssm.mobile-leave');
|
||||
leftPanelDisabled(false);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -281,7 +261,7 @@ class AbstractApp extends AbstractBoot {
|
|||
});
|
||||
} else {
|
||||
$htmlCL.add('ssm-state-mobile', 'rl-mobile');
|
||||
Events.pub('ssm.mobile-enter');
|
||||
leftPanelDisabled(true);
|
||||
}
|
||||
|
||||
leftPanelDisabled.subscribe((bValue) => {
|
||||
|
|
|
|||
119
dev/App/User.js
119
dev/App/User.js
|
|
@ -23,7 +23,7 @@ import { $htmlCL, leftPanelDisabled, bMobileDevice } from 'Common/Globals';
|
|||
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
import { runHook } from 'Common/Plugins';
|
||||
import { momentNowUnix, reload as momentReload } from 'Common/Momentor';
|
||||
import { reload as momentReload } from 'Common/Momentor';
|
||||
|
||||
import {
|
||||
initMessageFlagsFromCache,
|
||||
|
|
@ -44,8 +44,6 @@ import {
|
|||
openPgpJs
|
||||
} from 'Common/Links';
|
||||
|
||||
import * as Events from 'Common/Events';
|
||||
|
||||
import { getNotification, i18n } from 'Common/Translator';
|
||||
|
||||
import AppStore from 'Stores/User/App';
|
||||
|
|
@ -85,22 +83,19 @@ import { AbstractApp } from 'App/Abstract';
|
|||
const doc = document;
|
||||
|
||||
if (!window.ResizeObserver) {
|
||||
let rot;
|
||||
window.ResizeObserver = class {
|
||||
constructor(callback) {
|
||||
this.observer = new MutationObserver(mutations => {
|
||||
let entries = [];
|
||||
mutations.forEach(mutation => {
|
||||
if ('style' == mutation.attributeName) {
|
||||
entries.push({
|
||||
contentRect: {
|
||||
width: mutation.target.offsetWidth,
|
||||
height: mutation.target.offsetHeight
|
||||
},
|
||||
target: mutation.target
|
||||
});
|
||||
let i = mutations.length;
|
||||
while (i--) {
|
||||
if ('style' == mutations[i].attributeName) {
|
||||
// debounce
|
||||
clearTimeout(rot);
|
||||
rot = setTimeout(callback, 250);
|
||||
break;
|
||||
}
|
||||
});
|
||||
callback(entries);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -123,25 +118,12 @@ class AppUser extends AbstractApp {
|
|||
let qd, o = this;
|
||||
this.quotaDebounce = ()=>{
|
||||
// debounce
|
||||
qd && clearTimeout(qd);
|
||||
clearTimeout(qd);
|
||||
qd = setTimeout(o.quota, 30000);
|
||||
};
|
||||
|
||||
this.moveOrDeleteResponseHelper = this.moveOrDeleteResponseHelper.bind(this);
|
||||
|
||||
setInterval(() => Events.pub('interval.30s'), 30000);
|
||||
setInterval(() => Events.pub('interval.1m'), 60000);
|
||||
setInterval(() => Events.pub('interval.2m'), 120000);
|
||||
setInterval(() => Events.pub('interval.3m'), 180000);
|
||||
setInterval(() => Events.pub('interval.5m'), 300000);
|
||||
setInterval(() => Events.pub('interval.10m'), 600000);
|
||||
setInterval(() => Events.pub('interval.15m'), 900000);
|
||||
setInterval(() => Events.pub('interval.20m'), 1200000);
|
||||
|
||||
setTimeout(() => setInterval(() => Events.pub('interval.2m-after5m'), 120000), 300000);
|
||||
setTimeout(() => setInterval(() => Events.pub('interval.5m-after5m'), 300000), 300000);
|
||||
setTimeout(() => setInterval(() => Events.pub('interval.10m-after5m'), 600000), 300000);
|
||||
|
||||
// wakeUp
|
||||
const interval = 3600000; // 60m
|
||||
var lastTime = (new Date()).getTime();
|
||||
|
|
@ -284,7 +266,7 @@ class AppUser extends AbstractApp {
|
|||
messagesMoveTrigger() {
|
||||
// debounce
|
||||
const o = this;
|
||||
o.mt && clearTimeout(o.mt);
|
||||
clearTimeout(o.mt);
|
||||
o.mt = setTimeout(()=>{
|
||||
const sTrashFolder = FolderStore.trashFolder(),
|
||||
sSpamFolder = FolderStore.spamFolder();
|
||||
|
|
@ -537,37 +519,7 @@ class AppUser extends AbstractApp {
|
|||
}
|
||||
}
|
||||
|
||||
accountsCounts() {
|
||||
return false;
|
||||
// AccountStore.accounts.loading(true);
|
||||
//
|
||||
// Remote.accountsCounts((sResult, oData) => {
|
||||
//
|
||||
// AccountStore.accounts.loading(false);
|
||||
//
|
||||
// if (StorageResultType.Success === sResult && oData.Result && oData.Result['Counts'])
|
||||
// {
|
||||
// var
|
||||
// sEmail = AccountStore.email(),
|
||||
// aAcounts = AccountStore.accounts()
|
||||
// ;
|
||||
//
|
||||
// oData.Result['Counts'].find(oItem => {
|
||||
//
|
||||
// var oAccount = aAcounts.find(oAccount => {
|
||||
// return oAccount && oItem[0] === oAccount.email && sEmail !== oAccount.email;
|
||||
// });
|
||||
//
|
||||
// if (oAccount)
|
||||
// {
|
||||
// oAccount.count(pInt(oItem[1]));
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
accountsAndIdentities(bBoot) {
|
||||
accountsAndIdentities() {
|
||||
AccountStore.accounts.loading(true);
|
||||
IdentityStore.identities.loading(true);
|
||||
|
||||
|
|
@ -594,11 +546,6 @@ class AppUser extends AbstractApp {
|
|||
);
|
||||
}
|
||||
|
||||
if (undefined === bBoot ? false : !!bBoot) {
|
||||
setTimeout(() => this.accountsCounts(), 1000 * 5);
|
||||
Events.sub('interval.10m-after5m', () => this.accountsCounts());
|
||||
}
|
||||
|
||||
if (Array.isArray(oData.Result.Identities)) {
|
||||
delegateRunOnDestroy(IdentityStore.identities());
|
||||
|
||||
|
|
@ -673,7 +620,7 @@ class AppUser extends AbstractApp {
|
|||
|
||||
const folderFromCache = getFolderFromCacheList(data.Result.Folder);
|
||||
if (folderFromCache) {
|
||||
folderFromCache.interval = momentNowUnix();
|
||||
folderFromCache.interval = Date.now() / 1000;
|
||||
|
||||
if (data.Result.Hash) {
|
||||
setFolderHash(data.Result.Folder, data.Result.Hash);
|
||||
|
|
@ -748,7 +695,7 @@ class AppUser extends AbstractApp {
|
|||
Remote.folderInformationMultiply((sResult, oData) => {
|
||||
if (StorageResultType.Success === sResult) {
|
||||
if (oData && oData.Result && oData.Result.List && isNonEmptyArray(oData.Result.List)) {
|
||||
const utc = momentNowUnix();
|
||||
const utc = Date.now() / 1000;
|
||||
oData.Result.List.forEach(item => {
|
||||
const hash = getFolderHash(item.Folder),
|
||||
folder = getFolderFromCacheList(item.Folder);
|
||||
|
|
@ -974,7 +921,7 @@ class AppUser extends AbstractApp {
|
|||
};
|
||||
if (top && bottom) {
|
||||
fDisable(false);
|
||||
Events.sub('layout', layout => fDisable(Layout.BottomPreview !== layout));
|
||||
addEventListener('rl-layout', e => fDisable(Layout.BottomPreview !== e.detail));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -986,8 +933,7 @@ class AppUser extends AbstractApp {
|
|||
};
|
||||
if (left && right) {
|
||||
fDisable(false);
|
||||
Events.sub('left-panel.off', () => fDisable(true));
|
||||
Events.sub('left-panel.on', () => fDisable(false));
|
||||
leftPanelDisabled.subscribe(value => fDisable(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1018,7 +964,6 @@ class AppUser extends AbstractApp {
|
|||
startScreens([LoginUserScreen]);
|
||||
|
||||
runHook('rl-start-login-screens');
|
||||
Events.pub('rl.bootstart-login-screens');
|
||||
} else {
|
||||
routeOff();
|
||||
setHash(root(), true);
|
||||
|
|
@ -1054,10 +999,6 @@ class AppUser extends AbstractApp {
|
|||
progressJs.set(90);
|
||||
}
|
||||
|
||||
leftPanelDisabled.subscribe((value) => {
|
||||
Events.pub('left-panel.' + (value ? 'off' : 'on'));
|
||||
});
|
||||
|
||||
this.setWindowTitle('');
|
||||
if (Settings.settingsGet('Auth')) {
|
||||
$htmlCL.add('rl-user-auth');
|
||||
|
|
@ -1102,8 +1043,6 @@ class AppUser extends AbstractApp {
|
|||
PgpStore.openpgpKeyring = new openpgp.Keyring();
|
||||
PgpStore.capaOpenPGP(true);
|
||||
|
||||
Events.pub('openpgp.init');
|
||||
|
||||
this.reloadOpenPgpKeys();
|
||||
|
||||
return true;
|
||||
|
|
@ -1126,25 +1065,25 @@ class AppUser extends AbstractApp {
|
|||
// false ? AboutUserScreen : null
|
||||
]);
|
||||
|
||||
Events.sub('interval.2m', () => this.folderInformation(getFolderInboxName()));
|
||||
Events.sub('interval.3m', () => {
|
||||
setInterval(() => this.folderInformation(getFolderInboxName()), 120000);
|
||||
setInterval(() => {
|
||||
const sF = FolderStore.currentFolderFullNameRaw();
|
||||
if (getFolderInboxName() !== sF) {
|
||||
this.folderInformation(sF);
|
||||
}
|
||||
});
|
||||
}, 180000);
|
||||
|
||||
Events.sub('interval.2m-after5m', () => this.folderInformationMultiply());
|
||||
Events.sub('interval.15m', () => this.quota());
|
||||
Events.sub('interval.20m', () => this.foldersReload());
|
||||
setTimeout(() => setInterval(this.folderInformationMultiply, 120000), 300000);
|
||||
setInterval(this.quota, 900000);
|
||||
setInterval(this.foldersReload, 1200000);
|
||||
|
||||
contactsSyncInterval = 5 <= contactsSyncInterval ? contactsSyncInterval : 20;
|
||||
contactsSyncInterval = 320 >= contactsSyncInterval ? contactsSyncInterval : 320;
|
||||
|
||||
setTimeout(() => this.contactsSync(), 10000);
|
||||
setTimeout(this.contactsSync, 10000);
|
||||
setTimeout(() => this.folderInformationMultiply(true), 2000);
|
||||
|
||||
setInterval(() => this.contactsSync(), contactsSyncInterval * 60000 + 5000);
|
||||
setInterval(this.contactsSync, contactsSyncInterval * 60000 + 5000);
|
||||
|
||||
this.accountsAndIdentities(true);
|
||||
|
||||
|
|
@ -1155,13 +1094,12 @@ class AppUser extends AbstractApp {
|
|||
}
|
||||
}, 1000);
|
||||
|
||||
setTimeout(() => this.quota(), 5000);
|
||||
setTimeout(this.quota, 5000);
|
||||
setTimeout(() => Remote.appDelayStart(()=>{}), 35000);
|
||||
|
||||
Events.sub('rl.auto-logout', () => this.logout());
|
||||
addEventListener('rl.auto-logout', () => this.logout());
|
||||
|
||||
runHook('rl-start-user-screens');
|
||||
Events.pub('rl.bootstart-user-screens');
|
||||
|
||||
if (Settings.settingsGet('WelcomePageUrl')) {
|
||||
setTimeout(() => this.bootstartWelcomePopup(Settings.settingsGet('WelcomePageUrl')), 1000);
|
||||
|
|
@ -1203,10 +1141,9 @@ class AppUser extends AbstractApp {
|
|||
this.bootstartLoginScreen();
|
||||
}
|
||||
|
||||
Events.sub('interval.1m', () => momentReload());
|
||||
setInterval(momentReload, 60000);
|
||||
|
||||
runHook('rl-start-screens');
|
||||
Events.pub('rl.bootstart-end');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue