refactor(mobile): valildation of server after each scan
Some checks failed
Build and Push LST Docker Image / docker (push) Failing after 3m40s

This commit is contained in:
2026-05-06 12:10:14 -05:00
parent 12412536d1
commit 4ca74de279
2 changed files with 68 additions and 34 deletions

View File

@@ -19,7 +19,11 @@ export default function useDeviceLock() {
nextAppState === "background" || nextAppState === "inactive";
if (wasActive && isNowInactive) {
useMobileAuthStore.getState().lock();
const auth = useMobileAuthStore.getState();
if (auth.shouldLockForIdle()) {
auth.lock();
}
}
appStateRef.current = nextAppState;

View File

@@ -1,4 +1,6 @@
import axios from "axios";
import { useAppStore } from "../hooks/useAppStore";
import { useServerStore } from "../hooks/useServerCheck";
export type ServerVersionInfo = {
packageName: string;
@@ -18,7 +20,7 @@ export type StartupStatus =
export function evaluateVersion(
appBuildCode: number,
server: ServerVersionInfo
server: ServerVersionInfo,
): StartupStatus {
if (appBuildCode < server.minSupportedVersionCode) {
return {
@@ -41,3 +43,31 @@ export function evaluateVersion(
server,
};
}
export const versionCheck = async () => {
const { setServerVersion } = useServerStore.getState();
const { serverPort, serverIp } = useAppStore.getState();
const port = parseInt(serverPort || "0", 10) >= 50000 ? "3000" : serverPort;
try {
const res = await axios.get(
`http://${serverIp}:${port}/lst/api/mobile/version`,
{ timeout: 5000 },
);
if (res.status === 200) {
setServerVersion(res.data);
}
// const build = Constants.expoConfig?.android?.versionCode ?? 1;
// if (build < res.data.minSupportedVersionCode) {
// setStartupRoute("/updateScreen");
// setReady(true);
// return;
// }
} catch (error) {
console.log("Version check error:", error);
}
};