Skip to content

Commit

Permalink
fix(web): display version from json file
Browse files Browse the repository at this point in the history
  • Loading branch information
akorzunin committed Aug 3, 2024
1 parent 5a31693 commit 55d7640
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ tasks:
interactive: true
env:
VITE_GAME_VERSION: v0.0.0
VITE_GAME_COMMIT: ff7580e
VITE_GAME_COMMIT: taskbld01
preconditions:
- sh: >-
{{if eq OS "linux"}}
Expand Down
11 changes: 2 additions & 9 deletions web/src/components/GodotFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const GodotFrame = () => {
});
return (
<div className="grid justify-items-center px-6 pt-6">
<div className="w-screen-lg relative aspect-video min-w-[90vw]">
<div className="w-screen-lg relative aspect-video min-h-[70vh]">
{!showIframe && (
<div className="absolute inset-0 flex items-center justify-center bg-muted bg-opacity-75">
<Button onClick={() => setShowIframe(true)}>
Expand All @@ -37,14 +37,7 @@ export const GodotFrame = () => {
/>
)}
<p className="absolute bottom-0 right-2 text-primary-foreground">
build:{" "}
{gameVersionData
? gameVersionData.version
: import.meta.env.VITE_GAME_VERSION}{" "}
commit:{" "}
{gameVersionData
? gameVersionData.commit
: import.meta.env.VITE_GAME_COMMIT}
build: {gameVersionData?.version} commit: {gameVersionData?.commit}
</p>
</div>
</div>
Expand Down
22 changes: 12 additions & 10 deletions web/src/lib/versions.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
interface GameVarsion {
VERSION: string;
COMMIT: string;
interface GameVersion {
version: string;
commit: string;
}

export async function getGameVersionInfo() {
export async function getGameVersionInfo(): Promise<GameVersion> {
const req = await fetch("/download/latest_version.json");
const data = (await req.json()) as GameVarsion;

return {
version: data.VERSION,
commit: data.COMMIT,
};
if (!req.ok) {
return {
version: import.meta.env.VITE_GAME_VERSION ?? "v0.0.0",
commit: import.meta.env.VITE_GAME_COMMIT ?? "devbld01",
};
}
const data = (await req.json()) as GameVersion;
return data;
}

0 comments on commit 55d7640

Please sign in to comment.