From 9b91abb338d17147792c3ca89dc30102afaebccd Mon Sep 17 00:00:00 2001 From: Jordan Wages Date: Fri, 27 Jun 2025 21:59:11 -0500 Subject: [PATCH] Fix details popup when no mid parameter --- details.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/details.js b/details.js index 2b5b9e7..0d190d5 100644 --- a/details.js +++ b/details.js @@ -1,6 +1,17 @@ document.addEventListener('DOMContentLoaded', async () => { const params = new URLSearchParams(location.search); - const id = parseInt(params.get('mid'), 10); + let id = parseInt(params.get('mid'), 10); + + if (!id) { + try { + const tabs = await browser.tabs.query({ active: true, currentWindow: true }); + const tabId = tabs[0]?.id; + const msgs = tabId ? await browser.messageDisplay.getDisplayedMessages(tabId) : []; + id = msgs[0]?.id; + } catch (e) { + console.error('failed to determine message id', e); + } + } if (!id) return; try { const { subject, results } = await browser.runtime.sendMessage({ type: 'sortana:getDetails', id });