Easier refresh Folders

This commit is contained in:
djmaze 2021-03-18 13:52:56 +01:00
parent 11fd6736bb
commit 87bee226b4
4 changed files with 14 additions and 14 deletions

View file

@ -81,6 +81,9 @@ import { FolderSystemPopupView } from 'View/Popup/FolderSystem';
import { AskPopupView } from 'View/Popup/Ask';
import { TwoFactorConfigurationPopupView } from 'View/Popup/TwoFactorConfiguration';
// Every 5 minutes
const refreshFolders = 300000;
class AppUser extends AbstractApp {
constructor() {
super(Remote);
@ -561,7 +564,7 @@ class AppUser extends AbstractApp {
const folderFromCache = getFolderFromCacheList(data.Result.Folder);
if (folderFromCache) {
folderFromCache.interval = Date.now();
folderFromCache.expires = Date.now();
if (data.Result.Hash) {
setFolderHash(data.Result.Folder, data.Result.Hash);
@ -630,7 +633,7 @@ class AppUser extends AbstractApp {
* @param {boolean=} boot = false
*/
folderInformationMultiply(boot = false) {
const folders = FolderUserStore.getNextFolderNames();
const folders = FolderUserStore.getNextFolderNames(refreshFolders);
if (isNonEmptyArray(folders)) {
Remote.folderInformationMultiply((iError, oData) => {
if (!iError && oData && oData.Result && oData.Result.List && isNonEmptyArray(oData.Result.List)) {
@ -641,7 +644,7 @@ class AppUser extends AbstractApp {
let unreadCountChange = false;
if (folder) {
folder.interval = utc;
folder.expires = utc;
if (item.Hash) {
setFolderHash(item.Folder, item.Hash);
@ -956,7 +959,6 @@ class AppUser extends AbstractApp {
// false ? AboutUserScreen : null
]);
// Every 5 minutes
setInterval(() => {
const cF = FolderUserStore.currentFolderFullNameRaw(),
iF = getFolderInboxName();
@ -965,7 +967,7 @@ class AppUser extends AbstractApp {
this.folderInformation(cF);
}
this.folderInformationMultiply();
}, 300000);
}, refreshFolders);
// Every 15 minutes
setInterval(this.quota, 900000);

View file

@ -187,7 +187,7 @@ export class FolderModel extends AbstractModel {
this.delimiter = '';
this.namespace = '';
this.deep = 0;
this.interval = 0;
this.expires = 0;
this.selectable = false;
this.exists = true;

View file

@ -157,25 +157,23 @@ export const FolderUserStore = new class {
/**
* @returns {Array}
*/
getNextFolderNames() {
getNextFolderNames(ttl) {
const result = [],
limit = 10,
utc = Date.now(),
timeout = utc - 60000 * 5,
timeout = utc - ttl,
timeouts = [],
inboxFolderName = getFolderInboxName(),
bDisplaySpecSetting = this.displaySpecSetting(),
fSearchFunction = (list) => {
list.forEach(folder => {
if (
folder &&
inboxFolderName !== folder.fullNameRaw &&
folder.selectable &&
folder.exists &&
timeout > folder.interval &&
timeout > folder.expires &&
(folder.isSystemFolder() || (folder.subscribed() && (folder.checkable() || !bDisplaySpecSetting)))
) {
timeouts.push([folder.interval, folder.fullNameRaw]);
timeouts.push([folder.expires, folder.fullNameRaw]);
}
if (folder && folder.subFolders.length) {
@ -191,7 +189,7 @@ export const FolderUserStore = new class {
timeouts.find(aItem => {
const folder = getFolderFromCacheList(aItem[1]);
if (folder) {
folder.interval = utc;
folder.expires = utc;
result.push(aItem[1]);
}

View file

@ -671,7 +671,7 @@ export const MessageUserStore = new class {
folder = getFolderFromCacheList(collection.Folder);
if (folder && !cached) {
folder.interval = Date.now();
folder.expires = Date.now();
setFolderHash(collection.Folder, collection.FolderHash);