diff --git a/src/components/Notifications/NotificationManager.tsx b/src/components/Notifications/NotificationManager.tsx index 8f253c2042..139839c98b 100644 --- a/src/components/Notifications/NotificationManager.tsx +++ b/src/components/Notifications/NotificationManager.tsx @@ -46,6 +46,7 @@ export interface NotificationManagerEvents { notification: any; "notification-list-updated": never; "notification-count": number; + "game-started": Notification; } const boot_time = Date.now(); @@ -458,6 +459,10 @@ export class NotificationManager { ); } + if (notification.type === "gameStarted") { + this.event_emitter.emit("game-started", notification); + } + if ( notification.type === "gameStarted" || notification.type === "gameEnded" || diff --git a/src/views/Play/CustomGames.tsx b/src/views/Play/CustomGames.tsx index 6bc1c09589..a38ba796aa 100644 --- a/src/views/Play/CustomGames.tsx +++ b/src/views/Play/CustomGames.tsx @@ -618,7 +618,12 @@ export function CustomGames(): JSX.Element {
- {_("Long Games")} + + {pgettext( + "Game speed: multi-day games", + "Daily Correspondence", + )} +
diff --git a/src/views/Play/QuickMatch.tsx b/src/views/Play/QuickMatch.tsx index 1fcada6cb6..4912cfb64e 100644 --- a/src/views/Play/QuickMatch.tsx +++ b/src/views/Play/QuickMatch.tsx @@ -44,6 +44,7 @@ import Select from "react-select"; import { SPEED_OPTIONS } from "./SPEED_OPTIONS"; import { useHaveActiveGameSearch } from "./hooks"; import { openPlayPageHelp } from "./PlayPageHelp"; +import { notification_manager, Notification } from "@/components/Notifications/NotificationManager"; moment.relativeTimeThreshold("m", 56); export interface SelectOption { @@ -179,11 +180,21 @@ export function QuickMatch(): JSX.Element { automatch_manager.on("cancel", refresh); bot_event_emitter.on("updated", refresh); + function onGameStarted(game?: Notification) { + console.log("game-started", game); + if (game?.speed !== "correspondence" && automatch_manager.active_live_automatcher) { + automatch_manager.cancel(automatch_manager.active_live_automatcher?.uuid); + } + } + + notification_manager.event_emitter.on("game-started", onGameStarted); + return () => { automatch_manager.off("entry", refresh); automatch_manager.off("start", refresh); automatch_manager.off("cancel", refresh); bot_event_emitter.off("updated", refresh); + notification_manager.event_emitter.off("game-started", onGameStarted); }; }, []); @@ -747,6 +758,7 @@ export function QuickMatch(): JSX.Element { styles={select_styles} isSearchable={false} value={game_clock_options.find((o) => o.value === game_clock)} + menuPlacement="auto" onChange={(opt) => { if (opt) { setGameClock(opt.value as "flexible" | "exact" | "multiple");