Skip to content

Commit 6b02a8d

Browse files
committed
feat: Implement game de-selection
Click on the same game to hide the sidebar.
1 parent 7661776 commit 6b02a8d

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

src/renderer/components/pages/BrowsePage.tsx

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -403,19 +403,28 @@ export class BrowsePage extends React.Component<BrowsePageProps, BrowsePageState
403403

404404
onGridGameSelect = async (gameId?: string, col?: number, row?: number): Promise<void> => {
405405
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({
411419
view: currentView.id,
412-
col,
413-
row
420+
game,
414421
});
415422
}
423+
} else {
424+
// Deselect the same game that's already selected
416425
this.props.searchActions.selectGame({
417426
view: currentView.id,
418-
game,
427+
game: undefined
419428
});
420429
}
421430
}
@@ -424,18 +433,27 @@ export class BrowsePage extends React.Component<BrowsePageProps, BrowsePageState
424433

425434
onListGameSelect = async (gameId?: string, row?: number): Promise<void> => {
426435
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({
432448
view: currentView.id,
433-
row
449+
game,
434450
});
435451
}
452+
} else {
453+
// Deselect the same game that's already selected
436454
this.props.searchActions.selectGame({
437455
view: currentView.id,
438-
game,
456+
game: undefined,
439457
});
440458
}
441459
}

0 commit comments

Comments
 (0)