@@ -5,6 +5,7 @@ import TossupBonusClient from '../TossupBonusClient.js';
55import { arrayToRange } from '../ranges.js' ;
66import upsertPlayerItem from '../upsert-player-item.js' ;
77import { setYear } from '../year-slider.js' ;
8+ import { showAlert } from './alert.js' ;
89
910export const MultiplayerClientMixin = ( ClientClass ) => class extends ClientClass {
1011 constructor ( room , userId , socket ) {
@@ -50,19 +51,14 @@ export const MultiplayerClientMixin = (ClientClass) => class extends ClientClass
5051
5152 // if a banned/kicked user tries to join a this.room they were removed from this is the response
5253 ackRemovedFromRoom ( { removalType } ) {
53- if ( removalType === 'kick' ) {
54- window . alert ( 'You were kicked from this room by room players, and cannot rejoin it.' ) ;
55- } else {
56- window . alert ( 'You were banned from this room by the room owner, and cannot rejoin it.' ) ;
57- }
58- setTimeout ( ( ) => {
59- window . location . replace ( '../' ) ;
60- } , 100 ) ;
54+ const message = removalType === 'kick'
55+ ? 'You were kicked from this room by room players, and cannot rejoin it.'
56+ : 'You were banned from this room by the room owner, and cannot rejoin it.' ;
57+ showAlert ( message , ( ) => window . location . replace ( '../' ) ) ;
6158 }
6259
6360 adminLock ( { message } ) {
64- window . alert ( message ) ;
65- window . location . replace ( '/play/mp' ) ;
61+ showAlert ( message , ( ) => window . location . replace ( '/play/mp' ) ) ;
6662 }
6763
6864 buzz ( { userId, username } ) {
@@ -121,10 +117,7 @@ export const MultiplayerClientMixin = (ClientClass) => class extends ClientClass
121117
122118 confirmBan ( { targetId, targetUsername } ) {
123119 if ( targetId === this . USER_ID ) {
124- window . alert ( 'You were banned from this room by the room owner.' ) ;
125- setTimeout ( ( ) => {
126- window . location . replace ( '../' ) ;
127- } , 100 ) ;
120+ showAlert ( 'You were banned from this room by the room owner.' , ( ) => window . location . replace ( '../' ) ) ;
128121 } else {
129122 this . logEventConditionally ( targetUsername + ' has been banned from this room.' ) ;
130123 }
@@ -301,12 +294,12 @@ export const MultiplayerClientMixin = (ClientClass) => class extends ClientClass
301294
302295 failedVotekickPoints ( { userId } ) {
303296 if ( userId === this . USER_ID ) {
304- window . alert ( 'You can only votekick once you have answered a question correctly!' ) ;
297+ showAlert ( 'You can only votekick once you have answered a question correctly!' ) ;
305298 }
306299 }
307300
308301 forceUsername ( { message, username } ) {
309- window . alert ( message ) ;
302+ showAlert ( message ) ;
310303 window . localStorage . setItem ( 'multiplayer-username' , username ) ;
311304 document . querySelector ( '#username' ) . value = username ;
312305 }
@@ -378,8 +371,7 @@ export const MultiplayerClientMixin = (ClientClass) => class extends ClientClass
378371
379372 handleError ( { message } ) {
380373 this . socket . close ( 3000 ) ;
381- window . alert ( message ) ;
382- window . location . href = '/multiplayer' ;
374+ showAlert ( message , ( ) => { window . location . href = '/multiplayer' ; } ) ;
383375 }
384376
385377 join ( { isNew, team, user, userId, username } ) {
@@ -764,10 +756,7 @@ export const MultiplayerClientMixin = (ClientClass) => class extends ClientClass
764756
765757 vkHandle ( { targetUsername, targetId } ) {
766758 if ( this . USER_ID === targetId ) {
767- window . alert ( 'You were vote kicked from this room by others.' ) ;
768- setTimeout ( ( ) => {
769- window . location . replace ( '../' ) ;
770- } , 100 ) ;
759+ showAlert ( 'You were vote kicked from this room by others.' , ( ) => window . location . replace ( '../' ) ) ;
771760 } else {
772761 this . logEventConditionally ( targetUsername + ' has been vote kicked from this room.' ) ;
773762 }
@@ -793,6 +782,5 @@ function attachEventListeners (room, socket, client) {
793782 } ) ;
794783 } ) ;
795784}
796-
797785const MultiplayerTossupBonusClient = MultiplayerClientMixin ( TossupBonusClient ) ;
798786export default MultiplayerTossupBonusClient ;
0 commit comments