mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-05-25 19:07:03 +00:00
Rename files and folders (uniform the case)
This commit is contained in:
parent
75dada87cb
commit
cb86a9b89d
@ -35,7 +35,7 @@ import PersonSearchIcon from '@mui/icons-material/PersonSearch';
|
||||
import qortLogo from './assets/qort.png';
|
||||
import { Return } from './assets/Icons/Return.tsx';
|
||||
import WarningIcon from '@mui/icons-material/Warning';
|
||||
import './utils/seedPhrase/RandomSentenceGenerator';
|
||||
import './utils/seedPhrase/randomSentenceGenerator.ts';
|
||||
import EngineeringIcon from '@mui/icons-material/Engineering';
|
||||
import AccountBalanceWalletIcon from '@mui/icons-material/AccountBalanceWallet';
|
||||
import PriorityHighIcon from '@mui/icons-material/PriorityHigh';
|
||||
|
@ -75,7 +75,7 @@ export const Wallets = ({ setExtState, setRawWallet, rawWallet }) => {
|
||||
const fileContents = await new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onabort = () => reject('File reading was aborted');
|
||||
reader.onabort = () => reject('File reading was aborted'); // TODO translate
|
||||
reader.onerror = () => reject('File reading has failed');
|
||||
reader.onload = () => {
|
||||
// Resolve the promise with the reader result when reading completes
|
||||
|
@ -15,7 +15,7 @@ import {
|
||||
resumeAllQueues,
|
||||
} from '../../App';
|
||||
import { getPublicKey } from '../../background/background.ts';
|
||||
import { useMessageQueue } from '../../MessageQueueContext';
|
||||
import { useMessageQueue } from '../../messaging/MessageQueueContext.tsx';
|
||||
import {
|
||||
executeEvent,
|
||||
subscribeToEvent,
|
||||
|
@ -25,7 +25,7 @@ import {
|
||||
} from '../../App';
|
||||
import { CustomizedSnackbars } from '../Snackbar/Snackbar';
|
||||
import { PUBLIC_NOTIFICATION_CODE_FIRST_SECRET_KEY } from '../../constants/constants';
|
||||
import { useMessageQueue } from '../../MessageQueueContext';
|
||||
import { useMessageQueue } from '../../messaging/MessageQueueContext.tsx';
|
||||
import {
|
||||
executeEvent,
|
||||
subscribeToEvent,
|
||||
|
@ -43,7 +43,7 @@ import {
|
||||
} from '../../utils/events';
|
||||
import { RequestQueueWithPromise } from '../../utils/queue/queue';
|
||||
import { WebSocketActive } from './WebsocketActive';
|
||||
import { useMessageQueue } from '../../MessageQueueContext';
|
||||
import { useMessageQueue } from '../../messaging/MessageQueueContext';
|
||||
import { HomeDesktop } from './HomeDesktop';
|
||||
import { IconWrapper } from '../Desktop/DesktopFooter';
|
||||
import { DesktopHeader } from '../Desktop/DesktopHeader';
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import App from './App.tsx';
|
||||
import '../src/styles/index.css';
|
||||
import './messaging/messagesToBackground';
|
||||
import { MessageQueueProvider } from './MessageQueueContext.tsx';
|
||||
import './messaging/MessagesToBackground.tsx';
|
||||
import { MessageQueueProvider } from './messaging/MessageQueueContext.tsx';
|
||||
import { ThemeProvider } from './components/Theme/ThemeContext.tsx';
|
||||
import { CssBaseline } from '@mui/material';
|
||||
import './i18n/i18n.js';
|
||||
|
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
// Utility to generate unique request IDs
|
||||
function generateRequestId() {
|
||||
return `msg-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
||||
@ -9,34 +7,55 @@ function generateRequestId() {
|
||||
const callbackMap = new Map();
|
||||
|
||||
// Global listener for handling message responses
|
||||
window.addEventListener("message", (event) => {
|
||||
window.addEventListener('message', (event) => {
|
||||
const { type, requestId, payload, error, message } = event.data;
|
||||
|
||||
// Only process messages of type `backgroundMessageResponse`
|
||||
if (type !== "backgroundMessageResponse") return;
|
||||
if (type !== 'backgroundMessageResponse') return;
|
||||
|
||||
// Check if there’s a callback stored for this requestId
|
||||
if (callbackMap.has(requestId)) {
|
||||
const { resolve, reject } = callbackMap.get(requestId);
|
||||
callbackMap.delete(requestId); // Remove callback after use
|
||||
|
||||
resolve(event.data)
|
||||
resolve(event.data);
|
||||
}
|
||||
});
|
||||
|
||||
export const sendMessageBackground = (action, data = {}, timeout = 240000, isExtension, appInfo, skipAuth) => {
|
||||
export const sendMessageBackground = (
|
||||
action,
|
||||
data = {},
|
||||
timeout = 240000,
|
||||
isExtension,
|
||||
appInfo,
|
||||
skipAuth
|
||||
) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const requestId = generateRequestId(); // Unique ID for each request
|
||||
callbackMap.set(requestId, { resolve, reject }); // Store both resolve and reject callbacks
|
||||
const targetOrigin = window.location.origin
|
||||
const targetOrigin = window.location.origin;
|
||||
// Send the message with `backgroundMessage` type
|
||||
window.postMessage({ type: "backgroundMessage", action, requestId, payload: data, isExtension, appInfo, skipAuth }, targetOrigin);
|
||||
window.postMessage(
|
||||
{
|
||||
type: 'backgroundMessage',
|
||||
action,
|
||||
requestId,
|
||||
payload: data,
|
||||
isExtension,
|
||||
appInfo,
|
||||
skipAuth,
|
||||
},
|
||||
targetOrigin
|
||||
);
|
||||
|
||||
// Set up a timeout to automatically reject if no response is received
|
||||
const timeoutId = setTimeout(() => {
|
||||
// Remove the callback to prevent memory leaks
|
||||
callbackMap.delete(requestId);
|
||||
reject({ error: "timeout", message: `Request timed out after ${timeout} ms` });
|
||||
reject({
|
||||
error: 'timeout',
|
||||
message: `Request timed out after ${timeout} ms`,
|
||||
});
|
||||
}, timeout);
|
||||
|
||||
// Adjust resolve/reject to clear the timeout when a response arrives
|
||||
@ -48,14 +67,17 @@ export const sendMessageBackground = (action, data = {}, timeout = 240000, isExt
|
||||
reject: (error) => {
|
||||
clearTimeout(timeoutId); // Clear the timeout if an error occurs
|
||||
reject(error);
|
||||
}
|
||||
},
|
||||
});
|
||||
}).then((response) => {
|
||||
// Return payload or error based on response content
|
||||
if (response?.payload !== null && response?.payload !== undefined) {
|
||||
return response.payload;
|
||||
} else if (response?.error) {
|
||||
return { error: response.error, message: response?.message || "An error occurred" };
|
||||
return {
|
||||
error: response.error,
|
||||
message: response?.message || 'An error occurred',
|
||||
};
|
||||
}
|
||||
});
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user