Skip to content

Commit

Permalink
close sidebar when start playing character (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
KatoakDR authored Dec 21, 2024
2 parents c07ec22 + f95cb8a commit 1148c0d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export const SidebarItemCharacters: React.FC = (): ReactNode => {
closeModals();
setCharacter(character);
await playCharacter(character);
// TODO navigate to game grid so user can play the character
});
},
[closeModals, playCharacter]
Expand Down
4 changes: 4 additions & 0 deletions electron/renderer/components/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export const Sidebar: React.FC = (): ReactNode => {
setShowSettings(false);
}, []);

useSubscribe(['sidebar:hide'], () => {
closeSidebar();
});

useSubscribe(['sidebar:show'], (sidebarId: SidebarId) => {
closeSidebar();
switch (sidebarId) {
Expand Down
4 changes: 3 additions & 1 deletion electron/renderer/context/game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
} from '../../common/game/types.js';
import { useQuitCharacter } from '../hooks/characters.jsx';
import { useLogger } from '../hooks/logger.jsx';
import { useSubscribe } from '../hooks/pubsub.jsx';
import { usePubSub, useSubscribe } from '../hooks/pubsub.jsx';
import { runInBackground } from '../lib/async/run-in-background.js';

/**
Expand Down Expand Up @@ -39,6 +39,7 @@ export const GameProvider: React.FC<GameProviderProps> = (

const logger = useLogger('context:game');
const router = useRouter();
const pubsub = usePubSub();

const quitCharacter = useQuitCharacter();

Expand All @@ -62,6 +63,7 @@ export const GameProvider: React.FC<GameProviderProps> = (

useSubscribe(['character:play:started'], async () => {
setShowPlayStartingOverlay(false);
pubsub.publish('sidebar:hide');
await router.push('/grid');
});

Expand Down

0 comments on commit 1148c0d

Please sign in to comment.