Skip to content

Commit

Permalink
Merge pull request #1632 from shadow-dot-cat/castaway/templates_not_i…
Browse files Browse the repository at this point in the history
…ndexed

fix(messagelist): Show Templates folder contents from API
  • Loading branch information
castaway authored Nov 25, 2024
2 parents 67787c8 + 1d389a8 commit 603cb9e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 29 deletions.
6 changes: 2 additions & 4 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/app/rmmapi/messagelist.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -58,7 +58,7 @@ describe('MessageListService', () => {
filter(folders =>
folders && folders.length > 0)
).subscribe(() => {
expect(msglistservice.spamFolderName).toBe('CustomSpamFolderName');
expect(msglistservice.spamFolderName).toBe('Spam');
done();
});
});
Expand Down
19 changes: 5 additions & 14 deletions src/app/rmmapi/messagelist.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class MessageListService {

trashFolderName = 'Trash';
spamFolderName = 'Spam';
unindexedFolders = ['Trash', 'Spam', 'Templates'];
templateFolderName = 'Templates';

ignoreUnreadInFolders = [ 'Sent' ];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 6 additions & 9 deletions src/app/xapian/index.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ class SearchIndexService {
// postMessage ?
// messagelistservice stuff!
currentFolder = 'Inbox';
spamFolderName = 'Spam';
trashFolderName = 'Trash';
unindexedFolders = ['Trash', 'Spam', 'Templates'];
folderList: FolderListEntry[];
messageTextCache = new Map<number, string>();

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 603cb9e

Please sign in to comment.