Skip to content

Commit

Permalink
Added min stable version check
Browse files Browse the repository at this point in the history
  • Loading branch information
jLynx committed Jan 27, 2024
1 parent dd3be3d commit 593f125
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
20 changes: 11 additions & 9 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ const Home = () => {

return (
<>
<header>
<NavBar />
</header>
<main className="flex h-full min-h-screen flex-col items-center justify-between p-1">
<SerialLoader>
<Controller />
</SerialLoader>
</main>
<Footer />
<div className="flex min-h-screen flex-col">
<header>
<NavBar />
</header>
<main className="flex min-h-0 grow flex-col items-center justify-between p-1">
<SerialLoader>
<Controller />
</SerialLoader>
</main>
<Footer />
</div>
</>
);
};
Expand Down
7 changes: 5 additions & 2 deletions src/components/Controller/Controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
getVersionLink,
getVersionType,
nightlyVersionFormat,
stableVersionFormat,
} from "@/utils/versionUtils";
import { FileBrowser, FileStructure } from "../FileBrowser/FileBrowser";
import HotkeyButton from "../HotkeyButton/HotkeyButton";
Expand Down Expand Up @@ -557,8 +558,10 @@ const Controller = () => {
closeModal={() => setFirmwarModalOpen(false)}
className="w-[40%]"
>
{nightlyVersionFormat(deviceVersion) < 240114 &&
getVersionType(deviceVersion) == "nightly" ? (
{(nightlyVersionFormat(deviceVersion) < 240114 &&
getVersionType(deviceVersion) == "nightly") ||
(stableVersionFormat(deviceVersion) < 200 &&
getVersionType(deviceVersion) == "stable") ? (
<p>
Sorry, your firmware version is too old to do this. Please manually
update to the latest nightly!
Expand Down
10 changes: 5 additions & 5 deletions src/components/SerialLoader/SerialLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ const SerialLoader = ({ children }: PropsWithChildren<SerialLoaderProps>) => {
};

const errorMessage = () => (
<div className="absolute inset-0 flex h-full min-h-screen w-full flex-1 flex-col items-center justify-center text-black">
<div className="flex flex-1 flex-col items-center justify-center text-black">
<div className="flex w-full max-w-lg flex-col rounded-xl bg-white p-6">
<h1 className="-mt-1 mb-2 text-xl font-medium">😔 Uh oh... </h1>
<p className="mb-1">
<p className="mb-1 pb-5">
Looks like your browser doesn&apos;t support the{" "}
<a
className="text-green-800 focus:underline"
className="text-green-800 underline"
href="https://caniuse.com/web-serial"
target="_blank"
rel="noopener noreferrer"
Expand All @@ -77,8 +77,8 @@ const SerialLoader = ({ children }: PropsWithChildren<SerialLoaderProps>) => {
</a>
.
</p>
<p>Please try switching to a supported browser.</p>
<p>(e.g.: Chrome, Edge, Opera...)</p>
<p>Please try switching to a browser that supports the API.</p>
<p className="italic opacity-70">(e.g.: Chrome, Edge, Opera...)</p>
</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/components/SerialProvider/SerialProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ const useWebSerial = ({
portState.current = "closed";
setIsOpen(false);
console.error("Could not open port");
throw new Error("Could not open port");
}
};

Expand Down
5 changes: 5 additions & 0 deletions src/utils/versionUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ export const nightlyVersionFormat = (input: string): number => {
return number;
};

export const stableVersionFormat = (input: string): number => {
const number = parseInt(input.replace(/\D/g, ""));
return number;
};

const nightlyToDate = (input: string): string => {
const prefixRemoved = input.replace("n_", "");

Expand Down

0 comments on commit 593f125

Please sign in to comment.