Rename files and folders (uniform the case)

This commit is contained in:
Nicola Benaglia 2025-05-24 12:19:11 +02:00
parent ed3a9350ea
commit 702e18a334
10 changed files with 40 additions and 18 deletions

View File

@ -35,7 +35,7 @@ import PersonSearchIcon from '@mui/icons-material/PersonSearch';
import qortLogo from './assets/qort.png'; import qortLogo from './assets/qort.png';
import { Return } from './assets/Icons/Return.tsx'; import { Return } from './assets/Icons/Return.tsx';
import WarningIcon from '@mui/icons-material/Warning'; import WarningIcon from '@mui/icons-material/Warning';
import './utils/seedPhrase/RandomSentenceGenerator'; import './utils/seedPhrase/randomSentenceGenerator.ts';
import EngineeringIcon from '@mui/icons-material/Engineering'; import EngineeringIcon from '@mui/icons-material/Engineering';
import AccountBalanceWalletIcon from '@mui/icons-material/AccountBalanceWallet'; import AccountBalanceWalletIcon from '@mui/icons-material/AccountBalanceWallet';
import PriorityHighIcon from '@mui/icons-material/PriorityHigh'; import PriorityHighIcon from '@mui/icons-material/PriorityHigh';

View File

@ -75,7 +75,7 @@ export const Wallets = ({ setExtState, setRawWallet, rawWallet }) => {
const fileContents = await new Promise((resolve, reject) => { const fileContents = await new Promise((resolve, reject) => {
const reader = new FileReader(); 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.onerror = () => reject('File reading has failed');
reader.onload = () => { reader.onload = () => {
// Resolve the promise with the reader result when reading completes // Resolve the promise with the reader result when reading completes

View File

@ -15,7 +15,7 @@ import {
resumeAllQueues, resumeAllQueues,
} from '../../App'; } from '../../App';
import { getPublicKey } from '../../background/background.ts'; import { getPublicKey } from '../../background/background.ts';
import { useMessageQueue } from '../../MessageQueueContext'; import { useMessageQueue } from '../../messaging/MessageQueueContext.tsx';
import { import {
executeEvent, executeEvent,
subscribeToEvent, subscribeToEvent,

View File

@ -25,7 +25,7 @@ import {
} from '../../App'; } from '../../App';
import { CustomizedSnackbars } from '../Snackbar/Snackbar'; import { CustomizedSnackbars } from '../Snackbar/Snackbar';
import { PUBLIC_NOTIFICATION_CODE_FIRST_SECRET_KEY } from '../../constants/constants'; import { PUBLIC_NOTIFICATION_CODE_FIRST_SECRET_KEY } from '../../constants/constants';
import { useMessageQueue } from '../../MessageQueueContext'; import { useMessageQueue } from '../../messaging/MessageQueueContext.tsx';
import { import {
executeEvent, executeEvent,
subscribeToEvent, subscribeToEvent,

View File

@ -43,7 +43,7 @@ import {
} from '../../utils/events'; } from '../../utils/events';
import { RequestQueueWithPromise } from '../../utils/queue/queue'; import { RequestQueueWithPromise } from '../../utils/queue/queue';
import { WebSocketActive } from './WebsocketActive'; import { WebSocketActive } from './WebsocketActive';
import { useMessageQueue } from '../../MessageQueueContext'; import { useMessageQueue } from '../../messaging/MessageQueueContext';
import { HomeDesktop } from './HomeDesktop'; import { HomeDesktop } from './HomeDesktop';
import { IconWrapper } from '../Desktop/DesktopFooter'; import { IconWrapper } from '../Desktop/DesktopFooter';
import { DesktopHeader } from '../Desktop/DesktopHeader'; import { DesktopHeader } from '../Desktop/DesktopHeader';

View File

@ -1,8 +1,8 @@
import { createRoot } from 'react-dom/client'; import { createRoot } from 'react-dom/client';
import App from './App.tsx'; import App from './App.tsx';
import '../src/styles/index.css'; import '../src/styles/index.css';
import './messaging/messagesToBackground'; import './messaging/MessagesToBackground.tsx';
import { MessageQueueProvider } from './MessageQueueContext.tsx'; import { MessageQueueProvider } from './messaging/MessageQueueContext.tsx';
import { ThemeProvider } from './components/Theme/ThemeContext.tsx'; import { ThemeProvider } from './components/Theme/ThemeContext.tsx';
import { CssBaseline } from '@mui/material'; import { CssBaseline } from '@mui/material';
import './i18n/i18n.js'; import './i18n/i18n.js';

View File

@ -1,5 +1,3 @@
// Utility to generate unique request IDs // Utility to generate unique request IDs
function generateRequestId() { function generateRequestId() {
return `msg-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`; return `msg-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
@ -9,34 +7,55 @@ function generateRequestId() {
const callbackMap = new Map(); const callbackMap = new Map();
// Global listener for handling message responses // Global listener for handling message responses
window.addEventListener("message", (event) => { window.addEventListener('message', (event) => {
const { type, requestId, payload, error, message } = event.data; const { type, requestId, payload, error, message } = event.data;
// Only process messages of type `backgroundMessageResponse` // Only process messages of type `backgroundMessageResponse`
if (type !== "backgroundMessageResponse") return; if (type !== 'backgroundMessageResponse') return;
// Check if theres a callback stored for this requestId // Check if theres a callback stored for this requestId
if (callbackMap.has(requestId)) { if (callbackMap.has(requestId)) {
const { resolve, reject } = callbackMap.get(requestId); const { resolve, reject } = callbackMap.get(requestId);
callbackMap.delete(requestId); // Remove callback after use 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) => { return new Promise((resolve, reject) => {
const requestId = generateRequestId(); // Unique ID for each request const requestId = generateRequestId(); // Unique ID for each request
callbackMap.set(requestId, { resolve, reject }); // Store both resolve and reject callbacks 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 // 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 // Set up a timeout to automatically reject if no response is received
const timeoutId = setTimeout(() => { const timeoutId = setTimeout(() => {
// Remove the callback to prevent memory leaks // Remove the callback to prevent memory leaks
callbackMap.delete(requestId); callbackMap.delete(requestId);
reject({ error: "timeout", message: `Request timed out after ${timeout} ms` }); reject({
error: 'timeout',
message: `Request timed out after ${timeout} ms`,
});
}, timeout); }, timeout);
// Adjust resolve/reject to clear the timeout when a response arrives // 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) => { reject: (error) => {
clearTimeout(timeoutId); // Clear the timeout if an error occurs clearTimeout(timeoutId); // Clear the timeout if an error occurs
reject(error); reject(error);
} },
}); });
}).then((response) => { }).then((response) => {
// Return payload or error based on response content // Return payload or error based on response content
if (response?.payload !== null && response?.payload !== undefined) { if (response?.payload !== null && response?.payload !== undefined) {
return response.payload; return response.payload;
} else if (response?.error) { } else if (response?.error) {
return { error: response.error, message: response?.message || "An error occurred" }; return {
error: response.error,
message: response?.message || 'An error occurred',
};
} }
}); });
}; };