none folder added last

This commit is contained in:
Kyle Spearrin 2018-02-27 22:54:38 -05:00
parent f3f91c20ae
commit ab00dfd399
1 changed files with 6 additions and 9 deletions

View File

@ -67,15 +67,12 @@ export class FolderService implements FolderServiceAbstraction {
return this.decryptedFolderCache;
}
const noneFolder = new FolderView();
noneFolder.name = this.noneFolder();
const decFolders: FolderView[] = [noneFolder];
const key = await this.cryptoService.getKey();
if (key == null) {
throw new Error('No key.');
}
const decFolders: FolderView[] = [];
const promises: Array<Promise<any>> = [];
const folders = await this.getAll();
folders.forEach((folder) => {
@ -84,6 +81,11 @@ export class FolderService implements FolderServiceAbstraction {
await Promise.all(promises);
decFolders.sort(this.getLocaleSortingFunction());
const noneFolder = new FolderView();
noneFolder.name = this.noneFolder();
decFolders.push(noneFolder);
this.decryptedFolderCache = decFolders;
return this.decryptedFolderCache;
}
@ -164,11 +166,6 @@ export class FolderService implements FolderServiceAbstraction {
private getLocaleSortingFunction(): (a: FolderView, b: FolderView) => number {
return (a, b) => {
if (a.id == null) {
// No folder is always last
return Number.MAX_SAFE_INTEGER;
}
return this.i18nService.collator ? this.i18nService.collator.compare(a.name, b.name) :
a.name.localeCompare(b.name);
};