Skip to content

Commit

Permalink
Merge pull request #52 from RileyTheFox/old-version-warning
Browse files Browse the repository at this point in the history
Old version warning and version tag for latest release
  • Loading branch information
EliteAsian123 authored Aug 26, 2024
2 parents 2a5763a + 9f87219 commit 366c4ae
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
33 changes: 33 additions & 0 deletions src/dialogs/Dialogs/OldVersionDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Button, { ButtonColor } from "@app/components/Button";
import { BaseDialog } from "./BaseDialog";
import { closeDialog } from "..";

export class OldVersionDialog extends BaseDialog<Record<string, never>> {
constructor(props: Record<string, unknown>) {
super(props);
}

getInnerContents() {
return <>
<p>
<strong>You are trying to select an old version of this application!</strong>
&#32;These versions may be missing features, contain bugs and potentially corrupt your game data. Use at your own risk!
</p>
</>;
}

getTitle() {
return <>Old Application Version</>;
}

getButtons() {
return <>
<Button color={ButtonColor.RED} rounded onClick={() => closeDialog("cancel")}>
Cancel
</Button>
<Button color={ButtonColor.GREEN} rounded onClick={() => closeDialog("okay")}>
Okay
</Button>
</>;
}
}
21 changes: 17 additions & 4 deletions src/routes/AppProfile/AppSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import InputBox from "@app/components/InputBox";
import * as Tabs from "@radix-ui/react-tabs";
import { useOfflineStatus } from "@app/hooks/useOfflineStatus";
import { useQuery } from "@tanstack/react-query";
import { showErrorDialog } from "@app/dialogs";
import { createAndShowDialog, showErrorDialog } from "@app/dialogs";
import { distanceFromToday } from "@app/utils/timeFormat";
import { OldVersionDialog } from "@app/dialogs/Dialogs/OldVersionDialog";

interface VersionListProps {
activeProfile: ActiveProfile,
Expand All @@ -29,6 +30,18 @@ const VersionListComp: React.FC<VersionListProps> = ({ activeProfile, selectedVe
.then(res => res.json())
});

const selectVersion = async (uuid: string, index: number) => {
if (index !== 0) {
const versionDialogOutput = await createAndShowDialog(OldVersionDialog);

if (versionDialogOutput === "okay") {
setSelectedVersion(uuid);
}
} else {
setSelectedVersion(uuid);
}
};

if (versionListQuery.isLoading) {
return <span className={styles.centered}>
Loading...
Expand Down Expand Up @@ -57,15 +70,15 @@ const VersionListComp: React.FC<VersionListProps> = ({ activeProfile, selectedVe
data-state={selectedVersion === undefined ? "active" : "inactive"}
onClick={() => setSelectedVersion(undefined)}>

<header>Latest Release</header>
<header>Latest Release ({versionList.length > 0 ? versionList[0].tag : ""})</header>
<div>Recommended</div>
</div>
{
versionList.map(i =>
versionList.map((i, index) =>
<div
data-state={selectedVersion === i.uuid ? "active" : "inactive"}
key={i.uuid}
onClick={() => setSelectedVersion(i.uuid)}>
onClick={async () => await selectVersion(i.uuid, index)}>

<header>{i.tag}</header>
<div>{distanceFromToday(i.release)}</div>
Expand Down

0 comments on commit 366c4ae

Please sign in to comment.