Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion app/AppContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@
ip: string;
}

function isNewerVersion(latest: string, current: string): boolean {
const latestParts = latest.split(".").map(Number);
const currentParts = current.split(".").map(Number);

if (
latestParts.length !== 3 ||
currentParts.length !== 3 ||
[...latestParts, ...currentParts].some(Number.isNaN)
) {
return false;
}

for (let index = 0; index < latestParts.length; index += 1) {
if (latestParts[index] !== currentParts[index]) {
return latestParts[index] > currentParts[index];
}
}

return false;
}

/** Steps the auth flow can be opened directly to. */
export type AuthStep = "server" | "login" | "signup";

Expand Down Expand Up @@ -110,7 +131,7 @@
return false;
}

if (currentAppVersion === latestRelease.version) {
if (!isNewerVersion(latestRelease.version, currentAppVersion)) {
return false;
}

Expand All @@ -123,7 +144,7 @@
}

return true;
} catch (error) {

Check warning on line 147 in app/AppContext.tsx

View workflow job for this annotation

GitHub Actions / checks

'error' is defined but never used

Check warning on line 147 in app/AppContext.tsx

View workflow job for this annotation

GitHub Actions / checks

'error' is defined but never used
return false;
}
};
Expand Down Expand Up @@ -183,7 +204,7 @@
setAuthenticated(false);
openAuthFlow("server");
}
} catch (error) {

Check warning on line 207 in app/AppContext.tsx

View workflow job for this annotation

GitHub Actions / checks

'error' is defined but never used

Check warning on line 207 in app/AppContext.tsx

View workflow job for this annotation

GitHub Actions / checks

'error' is defined but never used
setAuthenticated(false);
} finally {
setIsLoading(false);
Expand Down Expand Up @@ -230,7 +251,7 @@
if (!userInfo?.username) {
setAuthenticated(false);
}
} catch (error) {

Check warning on line 254 in app/AppContext.tsx

View workflow job for this annotation

GitHub Actions / checks

'error' is defined but never used

Check warning on line 254 in app/AppContext.tsx

View workflow job for this annotation

GitHub Actions / checks

'error' is defined but never used
// Network blips shouldn't log the user out; the 401 callback handles
// genuine auth failures.
} finally {
Expand Down
Loading