Skip to content

Commit

Permalink
Remove alert
Browse files Browse the repository at this point in the history
  • Loading branch information
netalondon committed Jan 4, 2024
1 parent 9b96c97 commit 17dc09a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
2 changes: 1 addition & 1 deletion web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function App() {
fs.stat("/projects/01/Not/Not.hdl").catch(async () => {
await loaders.resetFiles(fs);
});
updateVersion(fs, baseContext.setStatus);
updateVersion(fs);
}, [fs]);

useEffect(() => {
Expand Down
16 changes: 2 additions & 14 deletions web/src/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import * as project_04 from "@nand2tetris/projects/project_04/index.js";
const VERSION_KEY = "version";
const CURRENT_VERSION = 2;

const VERSION_MISMATCH_WARNING =
"Error occurred while updating file templates, your files may differ from the latest official version";

export function getVersion() {
return Number(localStorage.getItem(VERSION_KEY) ?? "0");
}
Expand All @@ -15,28 +12,19 @@ export function setVersion(version: number) {
localStorage.setItem(VERSION_KEY, version.toString());
}

export async function updateVersion(
fs: FileSystem,
setStatus: (status: string) => void
) {
export async function updateVersion(fs: FileSystem) {
let version = getVersion();
let success = true;

while (version < CURRENT_VERSION) {
try {
await versionUpdates[version](fs);
version++;
} catch (e) {
success = false;
console.warn(`Error loading files at version ${version}`, e);
version++;
}
}

if (!success) {
console.warn(VERSION_MISMATCH_WARNING);
alert(`Warning: ${VERSION_MISMATCH_WARNING}`);
}

setVersion(CURRENT_VERSION);
}

Expand Down

0 comments on commit 17dc09a

Please sign in to comment.