fixed callback issue

This commit is contained in:
2023-09-10 11:42:20 -06:00
parent 0f14772302
commit 0cae93c98a
5 changed files with 59 additions and 15 deletions
+19
View File
@@ -359,10 +359,15 @@ msg_sign
let confirm_window = await browser.windows.create({url : '../pages/msg_confirm.html',
type : 'popup'});
console.log('b');
console.log(confirm_window.tabs);
// @ts-ignore shut the fuck up
let tabid : number = confirm_window.tabs[0].id;
console.log('tabid', tabid);
// stupid hack because otherwise the message gets sent before the listener in the page script is created
await sleep(500);
console.log('slept');
let result = await browser.tabs.sendMessage(tabid, {msg_str : msg_str});
console.log('result', result);
@@ -769,3 +774,17 @@ bi_s2i
return {keypairs: i_keypairs};
}
/**
* Hack from stack overflow somewhere to sleep for the given number of ms
*/
async function
sleep
(ms: number)
: Promise<void>
{
return new Promise(resolve => setTimeout(resolve, ms));
}