mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 21:19:21 +03:00
Revamp the FullNameHash system for better readable urls
And reduce the folders caching footprint. And it reduces server load.
This commit is contained in:
parent
76627ae2f6
commit
3a61bb3e5a
10 changed files with 90 additions and 78 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { AbstractCollectionModel } from 'Model/AbstractCollection';
|
||||
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
import { isArray, getKeyByValue, forEachObjectEntry } from 'Common/Utils';
|
||||
import { isArray, getKeyByValue, forEachObjectEntry, b64EncodeJSONSafe } from 'Common/Utils';
|
||||
import { ClientSideKeyName, FolderType, FolderMetadataKeys } from 'Common/EnumsUser';
|
||||
import * as Cache from 'Common/Cache';
|
||||
import { Settings, SettingsGet } from 'Common/Globals';
|
||||
|
|
@ -79,7 +79,7 @@ export class FolderCollectionModel extends AbstractCollectionModel
|
|||
oCacheFolder.type(FolderType.Inbox);
|
||||
Cache.setFolderInboxName(oFolder.FullName);
|
||||
}
|
||||
Cache.setFolder(oCacheFolder.fullNameHash, oFolder.FullName, oCacheFolder);
|
||||
Cache.setFolder(oCacheFolder);
|
||||
}
|
||||
|
||||
if (1 < type) {
|
||||
|
|
@ -88,7 +88,7 @@ export class FolderCollectionModel extends AbstractCollectionModel
|
|||
|
||||
oCacheFolder.collapsed(!expandedFolders
|
||||
|| !isArray(expandedFolders)
|
||||
|| !expandedFolders.includes(oCacheFolder.fullNameHash));
|
||||
|| !expandedFolders.includes(oCacheFolder.fullName));
|
||||
|
||||
if (oFolder.Extended) {
|
||||
if (oFolder.Extended.Hash) {
|
||||
|
|
@ -180,7 +180,6 @@ export class FolderModel extends AbstractModel {
|
|||
super();
|
||||
|
||||
this.fullName = '';
|
||||
this.fullNameHash = '';
|
||||
this.delimiter = '';
|
||||
this.deep = 0;
|
||||
this.expires = 0;
|
||||
|
|
@ -188,6 +187,9 @@ export class FolderModel extends AbstractModel {
|
|||
|
||||
this.exists = true;
|
||||
|
||||
// this.hash = '';
|
||||
// this.uidNext = 0;
|
||||
|
||||
this.addObservables({
|
||||
name: '',
|
||||
type: FolderType.User,
|
||||
|
|
@ -218,6 +220,14 @@ export class FolderModel extends AbstractModel {
|
|||
this.actionBlink = ko.observable(false).extend({ falseTimeout: 1000 });
|
||||
}
|
||||
|
||||
/**
|
||||
* For url safe '/#/mailbox/...' path
|
||||
*/
|
||||
get fullNameHash() {
|
||||
return this.fullName.replace(/[^a-z0-9._-]+/giu, b64EncodeJSONSafe);
|
||||
// return /^[a-z0-9._-]+$/iu.test(this.fullName) ? this.fullName : b64EncodeJSONSafe(this.fullName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @param {FetchJsonFolder} json
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue