Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions src/model/Match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
IFormattedRoundInfo,
IFormattedScore,
IFormattedScoreboard,
IToastInfo,
} from "./eventData";
import logging from "../util/Logging";
import { ReplayLogging } from "../util/ReplayLogging";
Expand Down Expand Up @@ -53,6 +54,14 @@ export class Match {
private timeoutGracePeriodPassed: boolean = false;

private toastEndTimeout: any = undefined;
private toastInfo: IToastInfo = {
active: false,
title: "",
message: "",
duration: null,
eventLogoEnabled: true,
selectedTeam: undefined,
};

private hasEnteredOvertime: boolean = false;

Expand Down Expand Up @@ -360,7 +369,7 @@ export class Match {
break;

case DataTypes.TOAST:
this.handleToast();
this.handleToast(data.data as IToastInfo);
break;
case DataTypes.SWAP_A_D:
this.handleSwapAD();
Expand Down Expand Up @@ -503,23 +512,24 @@ export class Match {
this.spikeDetonationTime = timestamp + 45 * 1000; // Add 45 seconds to the current time
}

private handleToast() {
if (this.tools.toastInfo.active) {
private handleToast(data: IToastInfo) {
if (this.toastInfo.active) {
// Toast is active — deactivate it immediately
this.tools.toastInfo.active = false;
this.toastInfo.active = false;
clearTimeout(this.toastEndTimeout);
this.toastEndTimeout = undefined;
} else {
// Activate the toast
this.tools.toastInfo.active = true;
// Activate the toast with data from the event
this.toastInfo = data;
this.toastInfo.active = true;

if (this.tools.toastInfo.duration !== null) {
if (this.toastInfo.duration !== null) {
// Auto-deactivate after the configured duration (ms)
this.toastEndTimeout = setTimeout(() => {
this.tools.toastInfo.active = false;
this.toastInfo.active = false;
this.toastEndTimeout = undefined;
this.eventNumber++;
}, this.tools.toastInfo.duration);
}, this.toastInfo.duration);
}
// If duration is null, the toast stays until the hotkey is pressed again
}
Expand Down
7 changes: 0 additions & 7 deletions src/model/ToolsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ export class ToolsData {
type: "disabled",
sponsors: [],
};
public toastInfo: IToastInfo = {
duration: null,
message: "",
eventLogoEnabled: true,
selectedTeam: undefined,
active: false,
};

public constructor(init?: Partial<ToolsData>) {
Object.assign(this, init);
Expand Down
10 changes: 10 additions & 0 deletions src/model/eventData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface IAuthedData {
| IFormattedRoundInfo
| IFormattedScore
| IFormattedAuxiliary
| IToastInfo
| boolean
| string
| number;
Expand Down Expand Up @@ -200,6 +201,15 @@ export function isAuthedData(data: object): data is IAuthedData | IAuthedAuxData
return false;
}

export type IToastInfo = {
duration: number | null;
title: string;
message: string;
eventLogoEnabled: boolean;
selectedTeam?: "left" | "right" | "none";
active: boolean;
};

//#region Preview
export interface IPreviewData {
type: DataTypes.PREVIEW;
Expand Down
6 changes: 0 additions & 6 deletions src/replay/ReplayConnectorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@ export class ReplayConnectorService {
type: "tournamentInfo",
sponsors: [],
},
toastInfo: {
duration: null,
message: "",
eventLogoEnabled: false,
active: false,
},
timeoutCounter: {
max: 2,
left: 2,
Expand Down
Loading