Skip to content

Commit

Permalink
Handle cancellation for the scrambler name in the default handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Mar 28, 2024
1 parent db599bd commit ab2990f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/lib/elements/CompetitorScrambleDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ export class CompetitorScrambleDisplay extends HTMLElement {
const setScramblerButton = this.querySelector(".set-scrambler");
setScramblerButton.textContent = "Please identify this scrambler…";
const name = await this.sharedState.setScramblerCallback(this.displayIndex);
this.#setField("scrambler-name", `Scrambler: ${name}`);
if (name === null) {
this.#setField("scrambler-name", "Scrambler: (unassigned)");
} else {
this.#setField("scrambler-name", `Scrambler: ${name}`);
}
setScramblerButton.textContent =
setScramblerButton.getAttribute("data-original-text");
}
Expand Down
4 changes: 3 additions & 1 deletion src/lib/elements/SharedState.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { ScrambleJSONCache } from "../json/ScrambleJSONCache";

export type SetScramblerCallback = (displayNumber: number) => Promise<string>;
export type SetScramblerCallback = (
displayNumber: number,
) => Promise<string | null>;

export interface ScrambleTableInitializationOptions {
numDisplays?: number;
Expand Down

0 comments on commit ab2990f

Please sign in to comment.