From 4585a2a570373239baa3f48bd0d8b1de6620ceb3 Mon Sep 17 00:00:00 2001 From: Nicola Benaglia Date: Sat, 24 May 2025 12:05:23 +0200 Subject: [PATCH] Remove empty function clearAllNotifications --- src/background/background-cases.ts | 27 --------------------- src/background/background.ts | 21 +++-------------- src/encryption/encryption.ts | 38 +----------------------------- 3 files changed, 4 insertions(+), 82 deletions(-) diff --git a/src/background/background-cases.ts b/src/background/background-cases.ts index 7c6677e..80ab3ac 100644 --- a/src/background/background-cases.ts +++ b/src/background/background-cases.ts @@ -11,7 +11,6 @@ import { checkLocalFunc, checkNewMessages, checkThreads, - clearAllNotifications, createEndpoint, createGroup, decryptDirectFunc, @@ -1142,32 +1141,6 @@ export async function getEnteredQmailTimestampCase(request, event) { } } -export async function clearAllNotificationsCase(request, event) { - try { - await clearAllNotifications(); - - event.source.postMessage( - { - requestId: request.requestId, - action: 'clearAllNotifications', - payload: true, - type: 'backgroundMessageResponse', - }, - event.origin - ); - } catch (error) { - event.source.postMessage( - { - requestId: request.requestId, - action: 'clearAllNotifications', - error: error?.message, - type: 'backgroundMessageResponse', - }, - event.origin - ); - } -} - export async function setGroupDataCase(request, event) { try { const { groupId, secretKeyData, secretKeyResource, admins } = diff --git a/src/background/background.ts b/src/background/background.ts index 075abea..90b2f2e 100644 --- a/src/background/background.ts +++ b/src/background/background.ts @@ -34,7 +34,6 @@ import { cancelBanCase, cancelInvitationToGroupCase, checkLocalCase, - clearAllNotificationsCase, createGroupCase, createPollCase, createRewardShareCase, @@ -303,6 +302,7 @@ export const createEndpoint = async (endpoint, customApi?: string) => { }; export const walletVersion = 2; + // List of your API endpoints const apiEndpoints = [ 'https://api.qortal.org', @@ -436,10 +436,6 @@ export async function performPowTask(chatBytes, difficulty) { }); } -function playNotificationSound() { - // chrome.runtime.sendMessage({ action: "PLAY_NOTIFICATION_SOUND" }); -} - const handleNotificationDirect = async (directs) => { let isFocused; const wallet = await getSaveWallet(); @@ -603,7 +599,7 @@ export function updateThreadActivity({ threads = JSON.parse(storedData); } - let lastResetTime = threads.lastResetTime || 0; + const lastResetTime = threads.lastResetTime || 0; // Check if a week has passed since the last reset if (currentTime - lastResetTime > ONE_WEEK_IN_MS) { @@ -653,7 +649,7 @@ export function updateThreadActivity({ const handleNotification = async (groups) => { const wallet = await getSaveWallet(); const address = wallet.address0; - let isDisableNotifications = + const isDisableNotifications = (await getUserSettings({ key: 'disable-push-notifications' })) || false; let mutedGroups = (await getUserSettings({ key: 'mutedGroups' })) || []; @@ -678,7 +674,6 @@ const handleNotification = async (groups) => { const newActiveChats = data; const oldActiveChats = await getChatHeads(); - let results = []; let newestLatestTimestamp = null; let oldestLatestTimestamp = null; // Find the latest timestamp from newActiveChats @@ -878,13 +873,6 @@ export async function storeWallets(wallets) { }); } -export async function clearAllNotifications() { - // const notifications = await chrome.notifications.getAll(); - // for (const notificationId of Object.keys(notifications)) { - // await chrome.notifications.clear(notificationId); - // } -} - export async function getUserInfo() { const wallet = await getSaveWallet(); const address = wallet.address0; @@ -3233,9 +3221,6 @@ function setupMessageListener() { case 'addGroupNotificationTimestamp': addGroupNotificationTimestampCase(request, event); break; - case 'clearAllNotifications': - clearAllNotificationsCase(request, event); - break; case 'setGroupData': setGroupDataCase(request, event); break; diff --git a/src/encryption/encryption.ts b/src/encryption/encryption.ts index 02ccfa2..04c3b65 100644 --- a/src/encryption/encryption.ts +++ b/src/encryption/encryption.ts @@ -12,49 +12,13 @@ import { RequestQueueWithPromise } from '../utils/queue/queue.ts'; export const requestQueueGetPublicKeys = new RequestQueueWithPromise(10); -const apiEndpoints = [ - 'https://api.qortal.org', - 'https://api2.qortal.org', - 'https://appnode.qortal.org', - 'https://apinode.qortalnodes.live', - 'https://apinode1.qortalnodes.live', - 'https://apinode2.qortalnodes.live', - 'https://apinode3.qortalnodes.live', - 'https://apinode4.qortalnodes.live', -]; - -async function findUsableApi() { - for (const endpoint of apiEndpoints) { - try { - const response = await fetch(`${endpoint}/admin/status`); - if (!response.ok) throw new Error('Failed to fetch'); - - const data = await response.json(); - if (data.isSynchronizing === false && data.syncPercent === 100) { - console.log(`Usable API found: ${endpoint}`); - return endpoint; - } else { - console.log(`API not ready: ${endpoint}`); - } - } catch (error) { - console.error(`Error checking API ${endpoint}:`, error); - } - } - - throw new Error( - i18n.t('question:message.error.no_api_found', { - postProcess: 'capitalizeFirstChar', - }) - ); -} - async function getSaveWallet() { const res = await getData('walletInfo').catch(() => null); if (res) { return res; } else { - throw new Error('No wallet saved'); + throw new Error('No wallet saved'); // TODO translate } }