Skip to content

Commit

Permalink
fix display of multiple async alerts
Browse files Browse the repository at this point in the history
they should be shown in succession, not all at once
because then only the last one is visible
  • Loading branch information
ornicar committed Oct 28, 2024
1 parent e22fd8b commit 7efd7ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 4 additions & 0 deletions ui/common/src/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ export async function alert(msg: string): Promise<void> {
});
}

export async function alerts(msgs: string[]): Promise<void> {
for (const msg of msgs) await alert(msg);
}

// non-blocking window.confirm-alike
export async function confirm(
msg: string,
Expand Down
9 changes: 4 additions & 5 deletions ui/tournament/src/ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as sound from './sound';
import { TournamentData, TournamentOpts, Pages, PlayerInfo, TeamInfo, Standing, Player } from './interfaces';
import { storage } from 'common/storage';
import { pubsub } from 'common/pubsub';
import { alert } from 'common/dialog';
import { alerts } from 'common/dialog';

interface CtrlTeamInfo {
requested?: string;
Expand Down Expand Up @@ -141,12 +141,10 @@ export default class TournamentController {
this.focusOnMe = false;
};

join = (team?: string) => {
join = async (team?: string) => {
this.joinWithTeamSelector = false;
if (!this.data.verdicts.accepted)
return this.data.verdicts.list.forEach(async v => {
if (v.verdict !== 'ok') await alert(v.verdict);
});
return await alerts(this.data.verdicts.list.map(v => v.verdict).filter(v => v != 'ok'));
if (this.data.teamBattle && !team && !this.data.me) {
this.joinWithTeamSelector = true;
} else {
Expand All @@ -161,6 +159,7 @@ export default class TournamentController {
this.joinSpinner = true;
this.focusOnMe = true;
}
return;
};

scrollToMe = () => this.setPage(myPage(this));
Expand Down

0 comments on commit 7efd7ea

Please sign in to comment.