+ sorry your version is too old. Please manually update to the latest
+ nightly
+
+ ) : (
+
+
+ Current installed version:{" "}
+
+ {deviceVersion} - {getVersionType(deviceVersion)}
+
+
+
+
+
Select from the available options
+
+
+
+
{updateStatus}
+
+ )}
>
);
diff --git a/src/app/components/DeviceButtons/DeviceButtons.tsx b/src/components/DeviceButtons/DeviceButtons.tsx
similarity index 95%
rename from src/app/components/DeviceButtons/DeviceButtons.tsx
rename to src/components/DeviceButtons/DeviceButtons.tsx
index 74b92ee..ba39acc 100644
--- a/src/app/components/DeviceButtons/DeviceButtons.tsx
+++ b/src/components/DeviceButtons/DeviceButtons.tsx
@@ -1,5 +1,5 @@
import { useEffect } from "react";
-import { useWriteCommand } from "@/app/utils/serialUtils";
+import { useWriteCommand } from "@/utils/serialUtils";
import HotkeyButton from "../HotkeyButton/HotkeyButton";
export const DeviceButtons = ({
diff --git a/src/app/components/FileBrowser/FileBrowser.tsx b/src/components/FileBrowser/FileBrowser.tsx
similarity index 93%
rename from src/app/components/FileBrowser/FileBrowser.tsx
rename to src/components/FileBrowser/FileBrowser.tsx
index f3b9f73..255d7a0 100644
--- a/src/app/components/FileBrowser/FileBrowser.tsx
+++ b/src/components/FileBrowser/FileBrowser.tsx
@@ -6,8 +6,8 @@ import {
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Dispatch, RefObject, SetStateAction, useState } from "react";
-import { parseDirectories } from "@/app/utils/fileUtils";
-import { useWriteCommand } from "@/app/utils/serialUtils";
+import { parseDirectories } from "@/utils/fileUtils";
+import { useWriteCommand } from "@/utils/serialUtils";
// Define FileType
export type FileType = "file" | "folder";
diff --git a/src/app/components/HotkeyButton/HotkeyButton.tsx b/src/components/HotkeyButton/HotkeyButton.tsx
similarity index 100%
rename from src/app/components/HotkeyButton/HotkeyButton.tsx
rename to src/components/HotkeyButton/HotkeyButton.tsx
diff --git a/src/app/components/Loader/Loader.tsx b/src/components/Loader/Loader.tsx
similarity index 100%
rename from src/app/components/Loader/Loader.tsx
rename to src/components/Loader/Loader.tsx
diff --git a/src/app/components/Modal/Modal.tsx b/src/components/Modal/Modal.tsx
similarity index 100%
rename from src/app/components/Modal/Modal.tsx
rename to src/components/Modal/Modal.tsx
diff --git a/src/app/components/SerialLoader/SerialLoader.tsx b/src/components/SerialLoader/SerialLoader.tsx
similarity index 100%
rename from src/app/components/SerialLoader/SerialLoader.tsx
rename to src/components/SerialLoader/SerialLoader.tsx
diff --git a/src/app/components/SerialProvider/SerialProvider.tsx b/src/components/SerialProvider/SerialProvider.tsx
similarity index 100%
rename from src/app/components/SerialProvider/SerialProvider.tsx
rename to src/components/SerialProvider/SerialProvider.tsx
diff --git a/src/app/components/ToggleSwitch/ToggleSwitch.tsx b/src/components/ToggleSwitch/ToggleSwitch.tsx
similarity index 100%
rename from src/app/components/ToggleSwitch/ToggleSwitch.tsx
rename to src/components/ToggleSwitch/ToggleSwitch.tsx
diff --git a/src/app/utils/fileUtils.tsx b/src/utils/fileUtils.tsx
similarity index 100%
rename from src/app/utils/fileUtils.tsx
rename to src/utils/fileUtils.tsx
diff --git a/src/app/utils/serialUtils.tsx b/src/utils/serialUtils.tsx
similarity index 95%
rename from src/app/utils/serialUtils.tsx
rename to src/utils/serialUtils.tsx
index 107aff5..43e5ad6 100644
--- a/src/app/utils/serialUtils.tsx
+++ b/src/utils/serialUtils.tsx
@@ -1,10 +1,4 @@
-import {
- Dispatch,
- SetStateAction,
- useCallback,
- useEffect,
- useState,
-} from "react";
+import { Dispatch, SetStateAction, useEffect, useState } from "react";
import { hexToBytes } from "./fileUtils";
import { useSerial } from "../components/SerialLoader/SerialLoader";
import { DataPacket } from "../components/SerialProvider/SerialProvider";
diff --git a/src/utils/versionUtils.tsx b/src/utils/versionUtils.tsx
new file mode 100644
index 0000000..e39301f
--- /dev/null
+++ b/src/utils/versionUtils.tsx
@@ -0,0 +1,47 @@
+type Version = "stable" | "nightly" | "custom" | "unknown";
+
+export const nightlyVersionFormat = (input: string): number => {
+ const removedPrefix = input.replace("n_", "");
+ const number = parseInt(removedPrefix);
+ return number;
+};
+
+const nightlyToDate = (input: string): string => {
+ const prefixRemoved = input.replace("n_", "");
+
+ const year = "20" + prefixRemoved.slice(0, 2);
+ const month = prefixRemoved.slice(2, 4);
+ const day = prefixRemoved.slice(4, 8);
+
+ return `${year}-${month}-${day}`;
+};
+
+export const getVersionType = (versionString: string): Version => {
+ const stableRegex = /^v?\d+\.\d+\.\d+$/;
+ const nightlyRegex = /^n_\d+$/;
+ const customRegex = /^[a-f0-9]+$/;
+
+ if (stableRegex.test(versionString)) {
+ return "stable";
+ } else if (nightlyRegex.test(versionString)) {
+ return "nightly";
+ } else if (customRegex.test(versionString)) {
+ return "custom";
+ } else {
+ return "unknown";
+ }
+};
+
+export const getVersionLink = (versionString: string = ""): string => {
+ const type = getVersionType(versionString);
+ if (type === "stable") {
+ return `https://github.com/portapack-mayhem/mayhem-firmware/releases/tag/${versionString}`;
+ } else if (type === "nightly") {
+ return `https://github.com/portapack-mayhem/mayhem-firmware/releases/tag/nightly-tag-${nightlyToDate(
+ versionString
+ )}`;
+ } else if (type === "custom") {
+ return `https://github.com/portapack-mayhem/mayhem-firmware/commit/${versionString}`;
+ }
+ return "";
+};