Skip to content

Commit

Permalink
Rename a field for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
eanders-ms committed Oct 27, 2023
1 parent 14b98c8 commit 5467b78
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion kiosk/src/Components/GameSlide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const GameSlide: React.FC<IProps> = ({ game }) => {
const gameId = getEffectiveGameId(game);
return `url("https://makecode.com/api/${gameId}/thumb")`;
}
}, [game, game?.staticGameId]);
}, [game, game?.tempGameId]);

return (
<div className="gameTile" onClick={handleSlideClick}>
Expand Down
6 changes: 3 additions & 3 deletions kiosk/src/Services/GameRefreshService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ async function refreshOneAsync() {
//console.log(`Refreshing game ${game.id}`);
const details = await getGameDetailsAsync(game.id);
if (details) {
if (details.id !== game.staticGameId) {
// The static/temporary gameId changed, update local copy of game metadata
if (details.id !== game.tempGameId) {
// The temporary gameId changed, update local copy of game metadata
dispatch(
Actions.updateGame(game.id, {
name: safeGameName(details.name),
description: safeGameDescription(
details.description
),
staticGameId: details.id,
tempGameId: details.id,
})
);
//console.log(`Refreshed game ${game.id} ${details.name}`);
Expand Down
4 changes: 2 additions & 2 deletions kiosk/src/Transforms/saveNewGamesAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function saveNewGamesAsync(
uniqueIdentifier: incoming[shareId].id,
date: dateStr(),
userAdded: true,
staticGameId: gameDetails?.id
tempGameId: gameDetails?.id
};

dispatch(Actions.addGame(newGame));
Expand All @@ -62,7 +62,7 @@ export async function saveNewGamesAsync(
existing.description = safeGameDescription(
gameDetails?.description
);
existing.staticGameId = gameDetails?.id;
existing.tempGameId = gameDetails?.id;
}
existing.date = dateStr();
existing.uniqueIdentifier = incoming[shareId].id;
Expand Down
4 changes: 2 additions & 2 deletions kiosk/src/Types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type GameData = {
id: string; // Can be a static/temporary gameId or a permanent gameId
id: string; // If this is a persistent share game, this is the persistent game id and `tempGameId` will contain the temporary game id. Otherwise, it's the regular game Id.
name: string;
description: string;
highScoreMode: string;
Expand All @@ -8,7 +8,7 @@ export type GameData = {
userAdded?: boolean;
deleted?: boolean;
lastRefreshMs?: number; // The last time we refreshed the game from the backend (applies to user-added, persistent shares only)
staticGameId?: string; // If this is a persistent share game, this is the static game Id
tempGameId?: string; // If this is a persistent share game, this is the temp game Id
};

export type HighScore = {
Expand Down
2 changes: 1 addition & 1 deletion kiosk/src/Utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@ export function isPersistentGameId(id: string): boolean {
}

export function getEffectiveGameId(game: GameData): string {
return game.staticGameId ?? game.id;
return game.tempGameId ?? game.id;
}

0 comments on commit 5467b78

Please sign in to comment.