test(mobile): stallion intergration starts
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import * as Updates from "expo-updates";
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
@@ -8,14 +9,13 @@ import {
|
||||
TextInput,
|
||||
View,
|
||||
} from "react-native";
|
||||
import * as Updates from 'expo-updates';
|
||||
|
||||
export default function App() {
|
||||
const [buffer, setBuffer] = useState("");
|
||||
const [items, setItems] = useState<string[]>([]);
|
||||
const [status, setStatus] = useState("");
|
||||
|
||||
const [updates, setUpdates] = useState("")
|
||||
const [updates, setUpdates] = useState("");
|
||||
|
||||
const handleChange = (text: string) => {
|
||||
// Scanner "types" characters then appends Enter (\n)
|
||||
@@ -28,37 +28,36 @@ export default function App() {
|
||||
}
|
||||
};
|
||||
|
||||
async function checkServerUpdate() {
|
||||
setUpdates('Checking for updates...');
|
||||
try {
|
||||
async function checkServerUpdate() {
|
||||
setUpdates("Checking for updates...");
|
||||
try {
|
||||
const cacheBuster = `?t=${Date.now()}`;
|
||||
|
||||
const cacheBuster = `?t=${Date.now()}`;
|
||||
const res = await Updates.checkForUpdateAsync();
|
||||
console.log("Update check result:", res);
|
||||
|
||||
const res = await Updates.checkForUpdateAsync();
|
||||
console.log('Update check result:', res);
|
||||
|
||||
if (res.isAvailable) {
|
||||
setUpdates('Update available! Downloading...');
|
||||
const fetchResult = await Updates.fetchUpdateAsync();
|
||||
console.log('Fetch result:', fetchResult);
|
||||
|
||||
if (fetchResult.isNew) {
|
||||
setUpdates('Update downloaded! Reloading app...');
|
||||
// Add a small delay to ensure everything is ready
|
||||
setTimeout(() => {
|
||||
Updates.reloadAsync();
|
||||
}, 1000);
|
||||
} else {
|
||||
setUpdates('Update download completed but no new bundle?');
|
||||
}
|
||||
} else {
|
||||
setUpdates('No new update available.');
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.error('Update error:', e);
|
||||
setUpdates(`Update failed: ${e.message}`);
|
||||
}
|
||||
}
|
||||
if (res.isAvailable) {
|
||||
setUpdates("Update available! Downloading...");
|
||||
const fetchResult = await Updates.fetchUpdateAsync();
|
||||
console.log("Fetch result:", fetchResult);
|
||||
|
||||
if (fetchResult.isNew) {
|
||||
setUpdates("Update downloaded! Reloading app...");
|
||||
// Add a small delay to ensure everything is ready
|
||||
setTimeout(() => {
|
||||
Updates.reloadAsync();
|
||||
}, 1000);
|
||||
} else {
|
||||
setUpdates("Update download completed but no new bundle?");
|
||||
}
|
||||
} else {
|
||||
setUpdates("No new update available.");
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.error("Update error:", e);
|
||||
setUpdates(`Update failed: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
const handleScan = (code: string) => {
|
||||
//console.log("Scanned:", code);
|
||||
@@ -87,9 +86,8 @@ async function checkServerUpdate() {
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
|
||||
<Text>But maybe later i will be </Text>
|
||||
|
||||
<Text>But maybe later i will be </Text>
|
||||
|
||||
<Button
|
||||
title="Clear Items"
|
||||
onPress={() => {
|
||||
@@ -112,16 +110,19 @@ async function checkServerUpdate() {
|
||||
width: 0,
|
||||
}}
|
||||
/>
|
||||
<Pressable onPress={checkServerUpdate}style={{
|
||||
marginVertical: 12,
|
||||
padding: 12,
|
||||
backgroundColor: '#007AFF',
|
||||
borderRadius: 6,
|
||||
}}>
|
||||
<Pressable
|
||||
onPress={checkServerUpdate}
|
||||
style={{
|
||||
marginVertical: 12,
|
||||
padding: 12,
|
||||
backgroundColor: "#007AFF",
|
||||
borderRadius: 6,
|
||||
}}
|
||||
>
|
||||
<Text>Check Update</Text>
|
||||
</Pressable>
|
||||
<Text>Update Data</Text>
|
||||
<Text>{updates}</Text>
|
||||
<Text>Update Data</Text>
|
||||
<Text>{updates}</Text>
|
||||
<FlatList
|
||||
data={items}
|
||||
keyExtractor={(_, i) => i.toString()}
|
||||
@@ -129,9 +130,7 @@ async function checkServerUpdate() {
|
||||
/>
|
||||
|
||||
<Text style={styles.status}>{status}</Text>
|
||||
|
||||
</View>
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user