Fix details popup when no mid parameter
This commit is contained in:
parent
ef864651d4
commit
9b91abb338
1 changed files with 12 additions and 1 deletions
13
details.js
13
details.js
|
@ -1,6 +1,17 @@
|
||||||
document.addEventListener('DOMContentLoaded', async () => {
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
const params = new URLSearchParams(location.search);
|
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;
|
if (!id) return;
|
||||||
try {
|
try {
|
||||||
const { subject, results } = await browser.runtime.sendMessage({ type: 'sortana:getDetails', id });
|
const { subject, results } = await browser.runtime.sendMessage({ type: 'sortana:getDetails', id });
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue