diff --git a/packages/app/src/attachments/utils.ts b/packages/app/src/attachments/utils.ts index f6a78f6a0..397a67f65 100644 --- a/packages/app/src/attachments/utils.ts +++ b/packages/app/src/attachments/utils.ts @@ -98,7 +98,7 @@ export function createPreviewAttachmentId(input: { export async function blobToBase64(blob: Blob): Promise { return await new Promise((resolve, reject) => { const reader = new FileReader(); - reader.onload = () => { + reader.addEventListener("load", () => { if (typeof reader.result !== "string") { reject(new Error("Unexpected FileReader result while encoding attachment.")); return; @@ -109,10 +109,10 @@ export async function blobToBase64(blob: Blob): Promise { return; } resolve(payload); - }; - reader.onerror = () => { + }); + reader.addEventListener("error", () => { reject(reader.error ?? new Error("Failed to read attachment blob.")); - }; + }); reader.readAsDataURL(blob); }); } diff --git a/packages/app/src/attachments/web/indexeddb-attachment-store.ts b/packages/app/src/attachments/web/indexeddb-attachment-store.ts index e2352749b..7d5ee4483 100644 --- a/packages/app/src/attachments/web/indexeddb-attachment-store.ts +++ b/packages/app/src/attachments/web/indexeddb-attachment-store.ts @@ -40,13 +40,13 @@ function openAttachmentDb(): Promise { } }; - request.onsuccess = () => { + request.addEventListener("success", () => { resolve(request.result); - }; + }); - request.onerror = () => { + request.addEventListener("error", () => { reject(request.error ?? new Error("Failed to open attachment IndexedDB.")); - }; + }); }); } @@ -60,17 +60,17 @@ function runTx( const store = transaction.objectStore(STORE_NAME); const request = run(store); - request.onsuccess = () => { + request.addEventListener("success", () => { resolve(request.result as T); - }; + }); - request.onerror = () => { + request.addEventListener("error", () => { reject(request.error ?? new Error("IndexedDB transaction request failed.")); - }; + }); - transaction.onerror = () => { + transaction.addEventListener("error", () => { reject(transaction.error ?? new Error("IndexedDB transaction failed.")); - }; + }); }); } @@ -203,13 +203,13 @@ export function createIndexedDbAttachmentStore(): AttachmentStore { const store = tx.objectStore(STORE_NAME); const cursorRequest = store.openCursor(); - cursorRequest.onerror = () => { + cursorRequest.addEventListener("error", () => { reject( cursorRequest.error ?? new Error("Failed to iterate IndexedDB attachment store."), ); - }; + }); - cursorRequest.onsuccess = () => { + cursorRequest.addEventListener("success", () => { const cursor = cursorRequest.result; if (!cursor) { resolve(); @@ -221,11 +221,11 @@ export function createIndexedDbAttachmentStore(): AttachmentStore { cursor.delete(); } cursor.continue(); - }; + }); - tx.onerror = () => { + tx.addEventListener("error", () => { reject(tx.error ?? new Error("Failed to garbage collect IndexedDB attachments.")); - }; + }); }); } finally { db.close(); diff --git a/packages/app/src/hooks/use-audio-recorder.web.ts b/packages/app/src/hooks/use-audio-recorder.web.ts index 2e783bac3..65794d450 100644 --- a/packages/app/src/hooks/use-audio-recorder.web.ts +++ b/packages/app/src/hooks/use-audio-recorder.web.ts @@ -242,10 +242,10 @@ export function useAudioRecorder(config?: AudioCaptureConfig) { } }; - recorder.onerror = (event) => { + recorder.addEventListener("error", (event) => { const error = (event as { error?: Error }).error; console.error("[AudioRecorder][Web] Recorder error", error ?? event); - }; + }); const timeslice = options?.enableContinuousRecording ? 1000 : undefined; diff --git a/packages/app/src/hooks/use-dictation-audio-source.web.ts b/packages/app/src/hooks/use-dictation-audio-source.web.ts index 5e20c6a34..344f8a05a 100644 --- a/packages/app/src/hooks/use-dictation-audio-source.web.ts +++ b/packages/app/src/hooks/use-dictation-audio-source.web.ts @@ -283,9 +283,9 @@ export function useDictationAudioSource(config: DictationAudioSourceConfig): Dic recorderRefs.audioChunks.push(data); } }; - recorder.onerror = (event: any) => { + recorder.addEventListener("error", (event: Event) => { recorderRefs.stoppedReject?.(event); - }; + }); recorder.addEventListener("stop", () => { try { const blob = diff --git a/packages/app/src/utils/os-notifications.ts b/packages/app/src/utils/os-notifications.ts index 16bff8c30..8762c5d88 100644 --- a/packages/app/src/utils/os-notifications.ts +++ b/packages/app/src/utils/os-notifications.ts @@ -14,7 +14,7 @@ export interface WebNotificationClickDetail { } interface WebNotificationInstance { - onclick?: ((event: Event) => void) | null; + addEventListener: (type: "click", listener: (event: Event) => void) => void; } export const WEB_NOTIFICATION_CLICK_EVENT = "paseo:web-notification-click"; @@ -144,12 +144,12 @@ function attachWebClickHandler( notification: WebNotificationInstance, data: Record | undefined, ): void { - notification.onclick = () => { + notification.addEventListener("click", () => { const handledByApp = dispatchWebNotificationClick({ data }); if (!handledByApp) { fallbackNavigateToNotificationTarget(data); } - }; + }); } export async function sendOsNotification(payload: OsNotificationPayload): Promise { diff --git a/packages/app/src/voice/audio-engine.web.ts b/packages/app/src/voice/audio-engine.web.ts index e377c4f36..d6b17c609 100644 --- a/packages/app/src/voice/audio-engine.web.ts +++ b/packages/app/src/voice/audio-engine.web.ts @@ -192,9 +192,9 @@ export function createAudioEngine( fn(); }; - source.onended = () => { + source.addEventListener("ended", () => { settle(() => resolve(durationSec)); - }; + }); try { source.start(); @@ -384,7 +384,6 @@ export function createAudioEngine( const active = refs.activePlayback; refs.activePlayback = null; try { - active.source.onended = null; active.source.stop(); } catch { // Ignore best-effort stop errors.