Skip to content

Commit 7466a95

Browse files
#6115 Fix: Incorrect date issue when printing message (#6116)
* fix: incorrect date issue in print function * fix: pr reviews
1 parent efa3629 commit 7466a95

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

extension/js/common/message-renderer.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,15 @@ export class MessageRenderer {
461461

462462
private getMessageInfo = async (fullMsg: GmailRes.GmailMsg): Promise<MessageInfo> => {
463463
const sentDate = GmailParser.findHeader(fullMsg, 'date');
464-
let sentDateStr = $('div.gK span[title]').attr('title');
464+
let sentDateStr: string | undefined;
465+
466+
// Look for the date element within the specific message container
467+
const msgContainer = $(`div.adn[data-legacy-message-id="${fullMsg.id}"]`);
468+
if (msgContainer.length) {
469+
sentDateStr = msgContainer.find('.gK span[title]').first().attr('title');
470+
}
471+
472+
// fallback to formatted date from headers
465473
if (!sentDateStr || isNaN(Date.parse(sentDateStr))) {
466474
sentDateStr = sentDate ? new Date(sentDate).toLocaleString() : '';
467475
}

0 commit comments

Comments
 (0)