Skip to content

Commit

Permalink
Types
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Mar 29, 2024
1 parent ad8961a commit d7846bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/contentScript/focusCaptureDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,18 @@ async function rawFocusCaptureDialog(

dialog.showModal();

await Promise.race([
const anyPromiseWillCloseTheDialog = [
oneEvent(button, "click"),
oneEvent(dialog, "cancel"),
oneEvent(signal, "abort"),
onContextInvalidated.promise,
]);
];

if (signal) {
anyPromiseWillCloseTheDialog.push(oneEvent(signal, "abort"));
}

await Promise.race(anyPromiseWillCloseTheDialog);

dialog.remove();
}

Expand Down
3 changes: 2 additions & 1 deletion src/utils/postMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { deserializeError, serializeError } from "serialize-error";
import { type SerializedError } from "@/types/messengerTypes";
import { assertNotNullish } from "./nullishUtils";
import { type JsonValue } from "type-fest";
import { AbortSignalAsOptions } from "./promiseUtils";

Check failure on line 38 in src/utils/postMessage.ts

View workflow job for this annotation

GitHub Actions / lint

All imports in the declaration are only used as types. Use `import type`

const TIMEOUT_MS = 3000;

Expand Down Expand Up @@ -100,7 +101,7 @@ export default async function postMessage<TReturn extends Payload = Payload>({
export function addPostMessageListener(
type: string,
listener: PostMessageListener,
{ signal }: { signal?: AbortSignal } = {},
{ signal }: AbortSignalAsOptions = {},
): void {
const rawListener = async ({
data,
Expand Down

0 comments on commit d7846bf

Please sign in to comment.