feat(mobile): update notifications and more error handling added
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 1m24s
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 1m24s
This commit is contained in:
@@ -15,6 +15,15 @@ export default function TabsLayout() {
|
||||
options={{
|
||||
title: "Scan",
|
||||
tabBarIcon: ({ color, size }) => <Home size={size} color={color} />,
|
||||
// header: ({ route }) => {
|
||||
// const version = serverVersion?.versionCode;
|
||||
|
||||
// const hasUpdate = version && version > build;
|
||||
|
||||
// if (!hasUpdate) return null; // 👈 hides header completely
|
||||
|
||||
// return <GlobalHeader title={route.name} />;
|
||||
// },
|
||||
}}
|
||||
/>
|
||||
<Tabs.Screen
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Stack } from "expo-router";
|
||||
import { StatusBar } from "expo-status-bar";
|
||||
import "../../global.css";
|
||||
import { PortalHost } from "@rn-primitives/portal";
|
||||
import { View } from "react-native";
|
||||
|
||||
export default function RootLayout() {
|
||||
return (
|
||||
@@ -9,7 +10,17 @@ export default function RootLayout() {
|
||||
<StatusBar style="dark" />
|
||||
<Stack screenOptions={{ headerShown: false }}>
|
||||
<Stack.Screen name="index" />
|
||||
{/* <Stack.Screen name="(tabs)" /> */}
|
||||
<View className="items-center">
|
||||
<Stack.Screen
|
||||
name="(tabs)"
|
||||
options={{
|
||||
title: "Pending update",
|
||||
headerStyle: {
|
||||
backgroundColor: "lightblue",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</Stack>
|
||||
<PortalHost />
|
||||
</>
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
import axios from "axios";
|
||||
import Constants from "expo-constants";
|
||||
import { Redirect, useRouter } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { ActivityIndicator, Text, View } from "react-native";
|
||||
import { useAppStore } from "../hooks/useAppStore";
|
||||
import { useServerStore } from "../hooks/useServerCheck";
|
||||
import { devDelay } from "../lib/devMode";
|
||||
|
||||
export default function Index() {
|
||||
const router = useRouter();
|
||||
const [message, setMessage] = useState(<Text>Starting app...</Text>);
|
||||
const [ready, setReady] = useState(false);
|
||||
const setServerVersion = useServerStore((s) => s.setServerVersion);
|
||||
|
||||
const hasHydrated = useAppStore((s) => s.hasHydrated);
|
||||
const serverPort = useAppStore((s) => s.serverPort);
|
||||
const serverIp = useAppStore((s) => s.serverIp);
|
||||
const build = Constants.expoConfig?.android?.versionCode ?? 1;
|
||||
const hasValidSetup = useAppStore((s) => s.hasValidSetup);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -46,6 +50,18 @@ export default function Index() {
|
||||
);
|
||||
|
||||
console.log(res.data);
|
||||
|
||||
// if the build version dose not match the latest server version force update
|
||||
if (res.status === 200) {
|
||||
setServerVersion(res.data);
|
||||
}
|
||||
|
||||
// TODO: change the header to show orange and theres a new version
|
||||
// console.log(build < res.data.minSupportedVersionCode);
|
||||
// if (build < res.data.minSupportedVersionCode) {
|
||||
// router.replace("/updateScreen");
|
||||
// return;
|
||||
// }
|
||||
} catch (error) {
|
||||
console.log("Error: ", error);
|
||||
}
|
||||
@@ -79,7 +95,14 @@ export default function Index() {
|
||||
};
|
||||
|
||||
startup();
|
||||
}, [hasHydrated, hasValidSetup, serverPort, serverIp, router]);
|
||||
}, [
|
||||
hasHydrated,
|
||||
hasValidSetup,
|
||||
serverPort,
|
||||
serverIp,
|
||||
router,
|
||||
setServerVersion,
|
||||
]);
|
||||
|
||||
if (ready) {
|
||||
return <Redirect href="/(tabs)/scanner" />;
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useRouter } from "expo-router";
|
||||
import { useState } from "react";
|
||||
import { Alert, Button, Text, TextInput, View } from "react-native";
|
||||
import { useAppStore } from "../hooks/useAppStore";
|
||||
import { useServerStore } from "../hooks/useServerCheck";
|
||||
|
||||
export default function Setup() {
|
||||
const router = useRouter();
|
||||
@@ -22,6 +23,8 @@ export default function Setup() {
|
||||
const [serverPort, setLocalServerPort] = useState(serverPortFromStore);
|
||||
const [scannerId, setScannerId] = useState(scannerIdFromStore);
|
||||
|
||||
const server = useServerStore((s) => s.serverVersion);
|
||||
|
||||
const authCheck = () => {
|
||||
if (pin === "6971") {
|
||||
setAuth(true);
|
||||
@@ -151,8 +154,11 @@ export default function Setup() {
|
||||
marginBottom: 12,
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 12, color: "#666" }}>
|
||||
LST Scanner v{version}-{build}
|
||||
<Text className="text-[12] color-#666">
|
||||
App v{version}-{build}
|
||||
</Text>
|
||||
<Text className="text-[12] color-#666">
|
||||
Server version - v{server?.versionName}-{server?.versionCode}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -1,9 +1,47 @@
|
||||
import Constants from "expo-constants";
|
||||
import { Link } from "expo-router";
|
||||
import { Text, View } from "react-native";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
} from "../components/ui/card";
|
||||
import { Separator } from "../components/ui/separator";
|
||||
import { useServerStore } from "../hooks/useServerCheck";
|
||||
|
||||
export default function blocked() {
|
||||
export default function Update() {
|
||||
const version = Constants.expoConfig?.version;
|
||||
const build = Constants.expoConfig?.android?.versionCode ?? 1;
|
||||
const server = useServerStore((s) => s.serverVersion);
|
||||
return (
|
||||
<View>
|
||||
<Text>Blocked</Text>
|
||||
<View className="flex-1 mt-5 p-5">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<Text className="text-center underline">Update Required</Text>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Text>Your app is out of date and needs to be updated</Text>
|
||||
<Separator className="mt-5 mb-5" />
|
||||
<Text>
|
||||
App version - v{version}-{build}
|
||||
</Text>
|
||||
<Text>
|
||||
Server version - v{server?.versionName}-{server?.versionCode}
|
||||
</Text>
|
||||
<Separator className="mt-5 mb-5" />
|
||||
<Text>
|
||||
To update the app please head go to a computer and open LST.
|
||||
</Text>
|
||||
<Text>Then head to Scan.</Text>
|
||||
<Text>Click update Then follow the instructions on screen</Text>
|
||||
</CardContent>
|
||||
</Card>
|
||||
{server && server?.versionCode >= build && (
|
||||
<Link href={"/"}>
|
||||
<Text className="text-center underline">Home</Text>
|
||||
</Link>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user