2023-03-06 18:36:23 +08:00
|
|
|
let FOLDERS_CACHE = new Map,
|
|
|
|
FOLDERS_HASH_MAP = new Map,
|
2020-10-15 18:23:11 +08:00
|
|
|
inboxFolderName = 'INBOX';
|
2016-06-17 07:23:49 +08:00
|
|
|
|
2021-08-20 21:40:07 +08:00
|
|
|
export const
|
|
|
|
/**
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2021-11-13 16:46:59 +08:00
|
|
|
clearCache = () => {
|
2023-03-06 18:36:23 +08:00
|
|
|
FOLDERS_CACHE.clear();
|
|
|
|
FOLDERS_HASH_MAP.clear();
|
2021-08-20 21:40:07 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
getFolderInboxName = () => inboxFolderName,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
setFolderInboxName = name => inboxFolderName = name,
|
|
|
|
|
|
|
|
/**
|
2023-02-16 17:55:23 +08:00
|
|
|
* @param {string} fullNameHash
|
2021-08-20 21:40:07 +08:00
|
|
|
* @returns {string}
|
|
|
|
*/
|
2023-03-06 18:36:23 +08:00
|
|
|
getFolderFromHashMap = fullNameHash => getFolderFromCacheList(FOLDERS_HASH_MAP.get(fullNameHash)),
|
2021-08-20 21:40:07 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {?FolderModel} folder
|
|
|
|
*/
|
2021-12-07 21:03:30 +08:00
|
|
|
setFolder = folder => {
|
2023-02-16 17:55:23 +08:00
|
|
|
folder.etag = '';
|
2023-03-06 18:36:23 +08:00
|
|
|
FOLDERS_CACHE.set(folder.fullName, folder);
|
|
|
|
FOLDERS_HASH_MAP.set(folder.fullNameHash, folder.fullName);
|
2021-08-20 21:40:07 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2021-11-30 17:19:43 +08:00
|
|
|
* @param {string} folderFullName
|
2023-02-16 17:55:23 +08:00
|
|
|
* @param {string} folderETag
|
2021-08-20 21:40:07 +08:00
|
|
|
*/
|
2023-02-16 17:55:23 +08:00
|
|
|
setFolderETag = (folderFullName, folderETag) =>
|
2023-03-06 18:36:23 +08:00
|
|
|
FOLDERS_CACHE.has(folderFullName) && (FOLDERS_CACHE.get(folderFullName).etag = folderETag),
|
2021-08-20 21:40:07 +08:00
|
|
|
|
|
|
|
/**
|
2021-11-30 17:19:43 +08:00
|
|
|
* @param {string} folderFullName
|
2021-08-20 21:40:07 +08:00
|
|
|
* @returns {?FolderModel}
|
|
|
|
*/
|
2021-11-30 17:19:43 +08:00
|
|
|
getFolderFromCacheList = folderFullName =>
|
2023-03-06 18:36:23 +08:00
|
|
|
FOLDERS_CACHE.get(folderFullName),
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2021-12-07 07:05:55 +08:00
|
|
|
/**
|
|
|
|
* @param {string} folderFullName
|
|
|
|
*/
|
2023-03-06 18:36:23 +08:00
|
|
|
removeFolderFromCacheList = folderFullName => FOLDERS_CACHE.delete(folderFullName);
|