mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
chore(lint): prefer-add-event-listener in app
This commit is contained in:
@@ -98,7 +98,7 @@ export function createPreviewAttachmentId(input: {
|
|||||||
export async function blobToBase64(blob: Blob): Promise<string> {
|
export async function blobToBase64(blob: Blob): Promise<string> {
|
||||||
return await new Promise<string>((resolve, reject) => {
|
return await new Promise<string>((resolve, reject) => {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = () => {
|
reader.addEventListener("load", () => {
|
||||||
if (typeof reader.result !== "string") {
|
if (typeof reader.result !== "string") {
|
||||||
reject(new Error("Unexpected FileReader result while encoding attachment."));
|
reject(new Error("Unexpected FileReader result while encoding attachment."));
|
||||||
return;
|
return;
|
||||||
@@ -109,10 +109,10 @@ export async function blobToBase64(blob: Blob): Promise<string> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resolve(payload);
|
resolve(payload);
|
||||||
};
|
});
|
||||||
reader.onerror = () => {
|
reader.addEventListener("error", () => {
|
||||||
reject(reader.error ?? new Error("Failed to read attachment blob."));
|
reject(reader.error ?? new Error("Failed to read attachment blob."));
|
||||||
};
|
});
|
||||||
reader.readAsDataURL(blob);
|
reader.readAsDataURL(blob);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,13 +40,13 @@ function openAttachmentDb(): Promise<IDBDatabase> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
request.onsuccess = () => {
|
request.addEventListener("success", () => {
|
||||||
resolve(request.result);
|
resolve(request.result);
|
||||||
};
|
});
|
||||||
|
|
||||||
request.onerror = () => {
|
request.addEventListener("error", () => {
|
||||||
reject(request.error ?? new Error("Failed to open attachment IndexedDB."));
|
reject(request.error ?? new Error("Failed to open attachment IndexedDB."));
|
||||||
};
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,17 +60,17 @@ function runTx<T>(
|
|||||||
const store = transaction.objectStore(STORE_NAME);
|
const store = transaction.objectStore(STORE_NAME);
|
||||||
const request = run(store);
|
const request = run(store);
|
||||||
|
|
||||||
request.onsuccess = () => {
|
request.addEventListener("success", () => {
|
||||||
resolve(request.result as T);
|
resolve(request.result as T);
|
||||||
};
|
});
|
||||||
|
|
||||||
request.onerror = () => {
|
request.addEventListener("error", () => {
|
||||||
reject(request.error ?? new Error("IndexedDB transaction request failed."));
|
reject(request.error ?? new Error("IndexedDB transaction request failed."));
|
||||||
};
|
});
|
||||||
|
|
||||||
transaction.onerror = () => {
|
transaction.addEventListener("error", () => {
|
||||||
reject(transaction.error ?? new Error("IndexedDB transaction failed."));
|
reject(transaction.error ?? new Error("IndexedDB transaction failed."));
|
||||||
};
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,13 +203,13 @@ export function createIndexedDbAttachmentStore(): AttachmentStore {
|
|||||||
const store = tx.objectStore(STORE_NAME);
|
const store = tx.objectStore(STORE_NAME);
|
||||||
const cursorRequest = store.openCursor();
|
const cursorRequest = store.openCursor();
|
||||||
|
|
||||||
cursorRequest.onerror = () => {
|
cursorRequest.addEventListener("error", () => {
|
||||||
reject(
|
reject(
|
||||||
cursorRequest.error ?? new Error("Failed to iterate IndexedDB attachment store."),
|
cursorRequest.error ?? new Error("Failed to iterate IndexedDB attachment store."),
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
cursorRequest.onsuccess = () => {
|
cursorRequest.addEventListener("success", () => {
|
||||||
const cursor = cursorRequest.result;
|
const cursor = cursorRequest.result;
|
||||||
if (!cursor) {
|
if (!cursor) {
|
||||||
resolve();
|
resolve();
|
||||||
@@ -221,11 +221,11 @@ export function createIndexedDbAttachmentStore(): AttachmentStore {
|
|||||||
cursor.delete();
|
cursor.delete();
|
||||||
}
|
}
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
};
|
});
|
||||||
|
|
||||||
tx.onerror = () => {
|
tx.addEventListener("error", () => {
|
||||||
reject(tx.error ?? new Error("Failed to garbage collect IndexedDB attachments."));
|
reject(tx.error ?? new Error("Failed to garbage collect IndexedDB attachments."));
|
||||||
};
|
});
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
db.close();
|
db.close();
|
||||||
|
|||||||
@@ -242,10 +242,10 @@ export function useAudioRecorder(config?: AudioCaptureConfig) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
recorder.onerror = (event) => {
|
recorder.addEventListener("error", (event) => {
|
||||||
const error = (event as { error?: Error }).error;
|
const error = (event as { error?: Error }).error;
|
||||||
console.error("[AudioRecorder][Web] Recorder error", error ?? event);
|
console.error("[AudioRecorder][Web] Recorder error", error ?? event);
|
||||||
};
|
});
|
||||||
|
|
||||||
const timeslice = options?.enableContinuousRecording ? 1000 : undefined;
|
const timeslice = options?.enableContinuousRecording ? 1000 : undefined;
|
||||||
|
|
||||||
|
|||||||
@@ -283,9 +283,9 @@ export function useDictationAudioSource(config: DictationAudioSourceConfig): Dic
|
|||||||
recorderRefs.audioChunks.push(data);
|
recorderRefs.audioChunks.push(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
recorder.onerror = (event: any) => {
|
recorder.addEventListener("error", (event: Event) => {
|
||||||
recorderRefs.stoppedReject?.(event);
|
recorderRefs.stoppedReject?.(event);
|
||||||
};
|
});
|
||||||
recorder.addEventListener("stop", () => {
|
recorder.addEventListener("stop", () => {
|
||||||
try {
|
try {
|
||||||
const blob =
|
const blob =
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export interface WebNotificationClickDetail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface WebNotificationInstance {
|
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";
|
export const WEB_NOTIFICATION_CLICK_EVENT = "paseo:web-notification-click";
|
||||||
@@ -144,12 +144,12 @@ function attachWebClickHandler(
|
|||||||
notification: WebNotificationInstance,
|
notification: WebNotificationInstance,
|
||||||
data: Record<string, unknown> | undefined,
|
data: Record<string, unknown> | undefined,
|
||||||
): void {
|
): void {
|
||||||
notification.onclick = () => {
|
notification.addEventListener("click", () => {
|
||||||
const handledByApp = dispatchWebNotificationClick({ data });
|
const handledByApp = dispatchWebNotificationClick({ data });
|
||||||
if (!handledByApp) {
|
if (!handledByApp) {
|
||||||
fallbackNavigateToNotificationTarget(data);
|
fallbackNavigateToNotificationTarget(data);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function sendOsNotification(payload: OsNotificationPayload): Promise<boolean> {
|
export async function sendOsNotification(payload: OsNotificationPayload): Promise<boolean> {
|
||||||
|
|||||||
@@ -192,9 +192,9 @@ export function createAudioEngine(
|
|||||||
fn();
|
fn();
|
||||||
};
|
};
|
||||||
|
|
||||||
source.onended = () => {
|
source.addEventListener("ended", () => {
|
||||||
settle(() => resolve(durationSec));
|
settle(() => resolve(durationSec));
|
||||||
};
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
source.start();
|
source.start();
|
||||||
@@ -384,7 +384,6 @@ export function createAudioEngine(
|
|||||||
const active = refs.activePlayback;
|
const active = refs.activePlayback;
|
||||||
refs.activePlayback = null;
|
refs.activePlayback = null;
|
||||||
try {
|
try {
|
||||||
active.source.onended = null;
|
|
||||||
active.source.stop();
|
active.source.stop();
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore best-effort stop errors.
|
// Ignore best-effort stop errors.
|
||||||
|
|||||||
Reference in New Issue
Block a user