Fix details popup when no mid parameter

This commit is contained in:
Jordan Wages 2025-06-27 21:59:11 -05:00
commit 9b91abb338

View file

@ -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 });