added update check
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import "../globals.css";
|
||||
import { useEffect } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Stack } from 'expo-router';
|
||||
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
||||
import {
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
} from '@react-native-firebase/messaging';
|
||||
import { registerDeviceToken, listenForTokenRefresh, displayLocalNotification } from '@/services/notifications';
|
||||
import { AuthProvider, useAuth } from "@/context/AuthContext";
|
||||
import { useUpdatecheck } from '@/hooks/useUpdatecheck';
|
||||
import { UpdatePrompt } from '@/components/UpdatePrompt';
|
||||
import Toast from 'react-native-toast-message';
|
||||
|
||||
// Registered at module scope so it's installed as soon as this entry file
|
||||
@@ -60,12 +62,22 @@ function NotificationSetup() {
|
||||
return null;
|
||||
}
|
||||
|
||||
function UpdateCheck() {
|
||||
const { updateInfo } = useUpdatecheck();
|
||||
const [dismissed, setDismissed] = useState(false);
|
||||
|
||||
if (!updateInfo || dismissed) return null;
|
||||
|
||||
return <UpdatePrompt updateInfo={updateInfo} onDismiss={() => setDismissed(true)} />;
|
||||
}
|
||||
|
||||
export default function RootLayout() {
|
||||
return (
|
||||
<AuthProvider>
|
||||
<SafeAreaProvider>
|
||||
<NotificationSetup />
|
||||
<Stack screenOptions={{ headerShown: false }} />
|
||||
<UpdateCheck />
|
||||
<Toast />
|
||||
</SafeAreaProvider>
|
||||
</AuthProvider>
|
||||
|
||||
Reference in New Issue
Block a user