changed qortalrequest messaging

This commit is contained in:
2024-10-30 09:37:23 +02:00
parent 4f91924947
commit eb8049c12d
11 changed files with 674 additions and 652 deletions

View File

@@ -24,13 +24,13 @@ window.addEventListener("message", (event) => {
}
});
export const sendMessageBackground = (action, data = {}, timeout = 60000, isFromExtension) => {
export const sendMessageBackground = (action, data = {}, timeout = 60000, isExtension) => {
return new Promise((resolve, reject) => {
const requestId = generateRequestId(); // Unique ID for each request
callbackMap.set(requestId, { resolve, reject }); // Store both resolve and reject callbacks
// Send the message with `backgroundMessage` type
window.postMessage({ type: "backgroundMessage", action, requestId, payload: data, isFromExtension }, "*");
window.postMessage({ type: "backgroundMessage", action, requestId, payload: data, isExtension }, "*");
// Set up a timeout to automatically reject if no response is received
const timeoutId = setTimeout(() => {