diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 7473ac6f6..7e757931c 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1085,8 +1085,7 @@ export class AppComponent implements OnInit, AfterViewInit, CanvasTableSelectLis // FIXME: Make a "not indexed folder list" somewhere!? // moveMessagesToFolder cant see these cos not in index - if (this.selectedFolder !== this.messagelistservice.spamFolderName && - this.selectedFolder !== this.messagelistservice.trashFolderName) { + if (this.messagelistservice.unindexedFolders.includes(this.selectedFolder)) { // remove from current message display this.canvastable.rows.removeMessages(messageIds); this.searchService.moveMessagesToFolder(msgIds, folderPath); @@ -1267,8 +1266,7 @@ export class AppComponent implements OnInit, AfterViewInit, CanvasTableSelectLis console.log('us', this.usewebsocketsearch); if ( this.usewebsocketsearch || - this.selectedFolder === this.messagelistservice.spamFolderName || - this.selectedFolder === this.messagelistservice.trashFolderName + this.messagelistservice.unindexedFolders.includes(this.selectedFolder) ) { /* * Message table from database, shown if local search index is not present diff --git a/src/app/rmmapi/messagelist.service.spec.ts b/src/app/rmmapi/messagelist.service.spec.ts index ea7259f23..f3a650140 100644 --- a/src/app/rmmapi/messagelist.service.spec.ts +++ b/src/app/rmmapi/messagelist.service.spec.ts @@ -36,7 +36,7 @@ describe('MessageListService', () => { [3692892, 0, 12, 'inbox', 'Inbox', 'Inbox', 0], [3692893, 0, 125, 'sent', 'Sent', 'Sent', 0], [3693770, 0, 3, 'user', 'Subsent', 'Sent.Subsent', 1], - [3692894, 0, 2, 'spam', 'CustomSpamFolderName', 'CustomSpamFolderName', 0], + [3692894, 0, 2, 'spam', 'Spam', 'Spam', 0], [3692895, 3, 239, 'trash', 'Trash', 'Trash', 0], [3693665, 0, 6, 'user', 'EmailPrivacyTester', 'EmailPrivacyTester', 0] ].map(entry => new FolderListEntry( @@ -58,7 +58,7 @@ describe('MessageListService', () => { filter(folders => folders && folders.length > 0) ).subscribe(() => { - expect(msglistservice.spamFolderName).toBe('CustomSpamFolderName'); + expect(msglistservice.spamFolderName).toBe('Spam'); done(); }); }); diff --git a/src/app/rmmapi/messagelist.service.ts b/src/app/rmmapi/messagelist.service.ts index 8a29406ce..2588d6c49 100644 --- a/src/app/rmmapi/messagelist.service.ts +++ b/src/app/rmmapi/messagelist.service.ts @@ -62,6 +62,7 @@ export class MessageListService { trashFolderName = 'Trash'; spamFolderName = 'Spam'; + unindexedFolders = ['Trash', 'Spam', 'Templates']; templateFolderName = 'Templates'; ignoreUnreadInFolders = [ 'Sent' ]; @@ -125,9 +126,8 @@ export class MessageListService { this.searchservice.pipe(take(1)).subscribe(searchservice => { // searchservice / index worker uses currentFolder for checking counts searchservice.setCurrentFolder(folder); - if (!searchservice.localSearchActivated || - folder === this.spamFolderName || - folder === this.trashFolderName ) { + if (!searchservice.localSearchActivated + || this.unindexedFolders.includes(folder) ) { // Always fetch fresh folder listing when setting current folder this.fetchFolderMessages(true); @@ -186,15 +186,6 @@ export class MessageListService { return new Promise((resolve, _) => { this.rmmapi.getFolderList() .subscribe((folders) => { - const trashfolder = folders.find(folder => folder.folderType === 'trash'); - if (trashfolder) { - this.trashFolderName = trashfolder.folderName; - } - const spamfolder = folders.find(folder => folder.folderType === 'spam'); - if (spamfolder) { - this.spamFolderName = spamfolder.folderName; - } - this.folderListSubject.next(folders); resolve(folders); }); @@ -342,10 +333,10 @@ export class MessageListService { // we only have T/S messages now, so if index on // might not have this one // artificial count update - if (folderName === this.spamFolderName || folderName === this.trashFolderName) { + if (this.unindexedFolders.includes(folderName)) { this.folderCounts[folderName].total++; } - if (this.currentFolder === this.spamFolderName || this.currentFolder === this.trashFolderName) { + if (this.unindexedFolders.includes(this.currentFolder)) { this.folderCounts[folderName].total--; } return; diff --git a/src/app/xapian/index.worker.ts b/src/app/xapian/index.worker.ts index 797a40763..b8861ae43 100644 --- a/src/app/xapian/index.worker.ts +++ b/src/app/xapian/index.worker.ts @@ -83,8 +83,7 @@ class SearchIndexService { // postMessage ? // messagelistservice stuff! currentFolder = 'Inbox'; - spamFolderName = 'Spam'; - trashFolderName = 'Trash'; + unindexedFolders = ['Trash', 'Spam', 'Templates']; folderList: FolderListEntry[]; messageTextCache = new Map(); @@ -560,16 +559,14 @@ not matching with rest api counts for current folder`); const docid = this.api.getDocIdFromUniqueIdTerm(uniqueIdTerm); if ( docid === 0 && // document not found in the index - msginfo.folder !== this.spamFolderName && - msginfo.folder !== this.trashFolderName + !this.unindexedFolders.includes(msginfo.folder) ) { searchIndexDocumentUpdates.push( new SearchIndexDocumentUpdate(msginfo.id, async () => { try { - this.indexingTools.addMessageToIndex(msginfo, [ - this.spamFolderName, - this.trashFolderName - ]); + this.indexingTools.addMessageToIndex( + msginfo, this.unindexedFolders + ); // Add term about missing body text so that later stage can add this this.api.addTermToDocument(`Q${msginfo.id}`, XAPIAN_TERM_MISSING_BODY_TEXT); if (msginfo.deletedFlag) { @@ -606,7 +603,7 @@ not matching with rest api counts for current folder`); term.substr(XAPIAN_TERM_FOLDER.length) !== msginfo.folder) { // Folder changed const destinationFolder = folders.find(folder => folder.folderPath === msginfo.folder); - if (destinationFolder && (destinationFolder.folderType === 'spam' || destinationFolder.folderType === 'trash')) { + if (destinationFolder && (destinationFolder.folderType === 'spam' || destinationFolder.folderType === 'trash') || destinationFolder.folderType === 'templates') { addSearchIndexDocumentUpdate(() => this.api.deleteDocumentByUniqueTerm(uniqueIdTerm)); msgIsTrashed = true; } else {