[mv3] Simplify sendMessage

onMessage() is now a listener installed synchrnously when uBOL
executes, so no longer need to deal with failure to send messages.

Related commit:
ab458b492a
This commit is contained in:
Raymond Hill 2025-04-21 08:13:16 -04:00
parent 22e848c9c2
commit 1d53441456
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -34,21 +34,8 @@ export const windows = browser.windows;
// send a message, we try a few more times when the message fails to be sent.
export function sendMessage(msg) {
return new Promise((resolve, reject) => {
let i = 5;
const send = ( ) => {
runtime.sendMessage(msg).then(response => {
resolve(response);
}).catch(reason => {
i -= 1;
if ( i <= 0 ) {
reject(reason);
} else {
setTimeout(send, 200);
}
});
};
send();
return runtime.sendMessage(msg).catch(reason => {
console.log(reason);
});
}