@@ -403,19 +403,28 @@ export class BrowsePage extends React.Component<BrowsePageProps, BrowsePageState
403
403
404
404
onGridGameSelect = async ( gameId ?: string , col ?: number , row ?: number ) : Promise < void > => {
405
405
const { currentView } = this . props ;
406
- if ( currentView . selectedGame ?. id !== gameId && gameId ) {
407
- const game = await window . Shared . back . request ( BackIn . GET_GAME , gameId ) ;
408
- if ( game ) {
409
- if ( col !== undefined && row !== undefined ) {
410
- this . props . searchActions . setGridScroll ( {
406
+ if ( gameId ) {
407
+ if ( currentView . selectedGame ?. id !== gameId ) {
408
+ // Select a different game
409
+ const game = await window . Shared . back . request ( BackIn . GET_GAME , gameId ) ;
410
+ if ( game ) {
411
+ if ( col !== undefined && row !== undefined ) {
412
+ this . props . searchActions . setGridScroll ( {
413
+ view : currentView . id ,
414
+ col,
415
+ row
416
+ } ) ;
417
+ }
418
+ this . props . searchActions . selectGame ( {
411
419
view : currentView . id ,
412
- col,
413
- row
420
+ game,
414
421
} ) ;
415
422
}
423
+ } else {
424
+ // Deselect the same game that's already selected
416
425
this . props . searchActions . selectGame ( {
417
426
view : currentView . id ,
418
- game,
427
+ game : undefined
419
428
} ) ;
420
429
}
421
430
}
@@ -424,18 +433,27 @@ export class BrowsePage extends React.Component<BrowsePageProps, BrowsePageState
424
433
425
434
onListGameSelect = async ( gameId ?: string , row ?: number ) : Promise < void > => {
426
435
const { currentView } = this . props ;
427
- if ( currentView . selectedGame ?. id !== gameId && gameId ) {
428
- const game = await window . Shared . back . request ( BackIn . GET_GAME , gameId ) ;
429
- if ( game ) {
430
- if ( row !== undefined ) {
431
- this . props . searchActions . setListScroll ( {
436
+ if ( gameId ) {
437
+ if ( currentView . selectedGame ?. id !== gameId ) {
438
+ // Select a different game
439
+ const game = await window . Shared . back . request ( BackIn . GET_GAME , gameId ) ;
440
+ if ( game ) {
441
+ if ( row !== undefined ) {
442
+ this . props . searchActions . setListScroll ( {
443
+ view : currentView . id ,
444
+ row
445
+ } ) ;
446
+ }
447
+ this . props . searchActions . selectGame ( {
432
448
view : currentView . id ,
433
- row
449
+ game ,
434
450
} ) ;
435
451
}
452
+ } else {
453
+ // Deselect the same game that's already selected
436
454
this . props . searchActions . selectGame ( {
437
455
view : currentView . id ,
438
- game,
456
+ game : undefined ,
439
457
} ) ;
440
458
}
441
459
}
0 commit comments