throttle 'tilts' from the server

This commit is contained in:
Gavin McDonald
2025-06-28 20:16:52 -04:00
parent 2ae4c6a77b
commit 1dbe6b7ec0
8 changed files with 66 additions and 28 deletions

View File

@@ -25,10 +25,10 @@ export interface AppContext {
noGame: boolean;
tilt: Tilt[];
selectCardIndex: number;
flipCard: (cardIndex: number) => void;
handleSettings: (gameData: GameUpdate) => void;
redraw: (cardIndex: number) => void;
select: (cardID: string) => void;
emitFlip: (cardIndex: number) => void;
emitSettings: (gameData: GameUpdate) => void;
emitRedraw: (cardIndex: number) => void;
emitSelect: (cardID: string) => void;
setGameID: (gameID: string) => void;
setSelectCardIndex: (cardIndex: number) => void;
setTilt: (tilt: Tilt[]) => void;
@@ -41,7 +41,7 @@ export function AppProvider({ children }: { children: ReactNode }) {
const [selectCardIndex, setSelectCardIndex] = useState(-1);
const [tilt, setTilt] = useState<Tilt[]>([]);
const { flipCard, redraw, select, handleSettings, emitTilt } = useSocket({
const { emitFlip, emitRedraw, emitSelect, emitSettings, emitTilt } = useSocket({
gameID,
setGameData,
setNoGame,
@@ -58,7 +58,7 @@ export function AppProvider({ children }: { children: ReactNode }) {
const handleSelect = (cardID: string) => {
setSelectCardIndex(-1);
select(selectCardIndex, cardID);
emitSelect(selectCardIndex, cardID);
};
const appInterface = {
@@ -66,10 +66,10 @@ export function AppProvider({ children }: { children: ReactNode }) {
noGame,
tilt,
selectCardIndex,
flipCard,
handleSettings,
redraw,
select: handleSelect,
emitFlip,
emitSettings,
emitRedraw,
emitSelect: handleSelect,
setGameID,
setSelectCardIndex,
setTilt,