Fix message lookup in details popup

This commit is contained in:
Jordan Wages 2025-07-05 05:07:48 -05:00
commit 6b741595cc
2 changed files with 3 additions and 3 deletions

View file

@ -413,7 +413,7 @@ async function clearCacheForMessages(idsInput) {
}
} else if (msg?.type === "sortana:clearCacheForDisplayed") {
try {
const tabs = await browser.tabs.query({ active: true, currentWindow: true });
const tabs = await browser.tabs.query({ active: true, lastFocusedWindow: true });
const tabId = tabs[0]?.id;
const msgs = tabId ? await browser.messageDisplay.getDisplayedMessages(tabId) : [];
const ids = msgs.map(m => m.id);

View file

@ -11,13 +11,13 @@ document.addEventListener('DOMContentLoaded', async () => {
if (!id) {
try {
const tabs = await browser.tabs.query({ active: true, currentWindow: true });
const tabs = await browser.tabs.query({ active: true, lastFocusedWindow: true });
const tabId = tabs[0]?.id;
const msgs = tabId ? await browser.messageDisplay.getDisplayedMessages(tabId) : [];
id = msgs[0]?.id;
logger.aiLog('message id from displayed messages', { debug: true }, id);
if (!id) {
const mailTabs = await browser.mailTabs.query({ active: true, currentWindow: true });
const mailTabs = await browser.mailTabs.query({ active: true, lastFocusedWindow: true });
const mailTabId = mailTabs[0]?.id;
const selected = mailTabId !== undefined ? await browser.mailTabs.getSelectedMessages(mailTabId) : null;
id = selected?.messages?.[0]?.id;