From f4a99364195eb8b04116bf602b08d4856a9284df Mon Sep 17 00:00:00 2001 From: Bas Date: Mon, 27 Jan 2025 14:25:43 +0000 Subject: [PATCH] Add answered and folder column and fixed message data fn --- src/app/app.component.html | 27 +++++++++++++++ src/app/app.component.scss | 5 +++ src/app/app.component.ts | 19 ++--------- src/app/common/messagedisplay.ts | 1 + src/app/common/messagelist.ts | 18 ++++++++++ src/app/sort-button/sort-button.component.ts | 2 +- .../websocketsearchmaillist.ts | 11 ++++++ src/app/xapian/searchmessagedisplay.ts | 34 ++++++++++++++++++- 8 files changed, 99 insertions(+), 18 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index 809d5c2d9..8d255689b 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -467,7 +467,21 @@

No Message Selected

+ + + + Folder + + + Attachments + Answered Flagged @@ -559,6 +573,11 @@

No Message Selected

{{item.size | humanBytes}} + + {{item.folder}} + No Message Selected svgIcon="attachment"> + + + + = this.rows.length) break - this.rows[index] = item + this.rows[index] = this.canvastable.rows.getRowData(index, this) } this.rows = Object.create(this.rows) diff --git a/src/app/common/messagedisplay.ts b/src/app/common/messagedisplay.ts index 2dd6227f1..2821fad8d 100644 --- a/src/app/common/messagedisplay.ts +++ b/src/app/common/messagedisplay.ts @@ -203,4 +203,5 @@ export abstract class MessageDisplay { // columns abstract getCanvasTableColumns(app: any): CanvasTableColumn[]; + abstract getRowData(index: number, app: any): any; } diff --git a/src/app/common/messagelist.ts b/src/app/common/messagelist.ts index a5c8a960c..f57cf2abc 100644 --- a/src/app/common/messagelist.ts +++ b/src/app/common/messagelist.ts @@ -157,4 +157,22 @@ export class MessageList extends MessageDisplay { return columns; } + + getRowData(rowIndex, app) { + const row = this.rows[rowIndex] + + return { + id: row.id, + messageDate: MessageTableRowTool.formatTimestamp(row.messageDate.toJSON()), + from: app.selectedFolder === 'Sent' + ? this.getToColumnValueForRow(rowIndex) + : this.getFromColumnValueForRow(rowIndex), + subject: row.subject, + size: row.size, + attachment: row.attachment , + answered: row.answeredFlag , + flagged: row.flaggedFlag , + plaintext: row.plaintext?.trim(), + }; + } } diff --git a/src/app/sort-button/sort-button.component.ts b/src/app/sort-button/sort-button.component.ts index 2f3a509bb..15d086add 100644 --- a/src/app/sort-button/sort-button.component.ts +++ b/src/app/sort-button/sort-button.component.ts @@ -62,6 +62,7 @@ export interface OrderEvent { border: none; font-size: inherit; font-weight: inherit; + padding-left: 0; } .sort-button:hover { @@ -97,7 +98,6 @@ export class SortButtonComponent { ]); get directionIcon() { - return (this.data === this.order?.data) ? this.directionIconMap.get(this.order?.direction) : this.directionIconMap.get(Direction.None); diff --git a/src/app/websocketsearch/websocketsearchmaillist.ts b/src/app/websocketsearch/websocketsearchmaillist.ts index e70c19e8f..9158afad2 100644 --- a/src/app/websocketsearch/websocketsearchmaillist.ts +++ b/src/app/websocketsearch/websocketsearchmaillist.ts @@ -98,4 +98,15 @@ export class WebSocketSearchMailList extends MessageDisplay { return columns; } + getRowData(rowIndex, app) { + return { + id: this.getRowMessageId(rowIndex), + selectbox: this.isSelectedRow(rowIndex), + messageDate: this.getRow(rowIndex).dateTime, + from: this.getRow(rowIndex).fromName, + subject: this.getRow(rowIndex).subject, + size: this.getRow(rowIndex).size, + }; + } + } diff --git a/src/app/xapian/searchmessagedisplay.ts b/src/app/xapian/searchmessagedisplay.ts index d91e81164..3e8bcca38 100644 --- a/src/app/xapian/searchmessagedisplay.ts +++ b/src/app/xapian/searchmessagedisplay.ts @@ -46,7 +46,7 @@ export class SearchMessageDisplay extends MessageDisplay { } catch (e) { // This shouldnt happen, it means something changed the stored // data without updating the messagedisplay rows. - console.log('Tried to lookup ' + index + ' in searchIndex, isnt there! ' + e); + console.error('Tried to lookup ' + index + ' in searchIndex, isnt there! ' + e); } return msgId; } @@ -215,4 +215,36 @@ export class SearchMessageDisplay extends MessageDisplay { } return columns; } + + public getRowData(index: number, app: any) { + const rowData: any = { + id: this.getRowMessageId(index), + messageDate: MessageTableRowTool.formatTimestampFromStringWithoutSeparators(this.searchService.api.getStringValue(this.getRowId(index), 2)), + from: app.selectedFolder.indexOf('Sent') === 0 && !app.displayFolderColumn + ? this.searchService.getDocData(this.getRowId(index)).recipients.join(', ') + : this.searchService.getDocData(this.getRowId(index)).from, + subject: this.searchService.getDocData(this.getRowId(index)).subject, + plaintext: this.searchService.getDocData(this.getRowId(index)).textcontent?.trim(), + size: this.searchService.api.getNumericValue(this.getRowId(index), 3), + attachment: this.searchService.getDocData(this.getRowId(index)).attachment ? true : false, + answered: this.searchService.getDocData(this.getRowId(index)).answered ? true : false, + flagged: this.searchService.getDocData(this.getRowId(index)).flagged ? true : false, + folder: this.searchService.getDocData(this.getRowId(index)).folder, + }; + + if (app.viewmode === 'conversations') { + const row = this.getRow(index); + if (!row[2]) { + const conversationId = this.searchService.api.getStringValue(row[0], 1); + const results = this.searchService.api.sortedXapianQuery( + `conversation:${conversationId}..${conversationId}`, + 1, 0, 0, 1000, 1 + ); + row[2] = `${results[0][1] + 1}`; + } + rowData.count = row[2]; + } + + return rowData; + } }