Kaynağa Gözat

"Update available" modal fix

Viktoriia 4 gün önce
ebeveyn
işleme
dc896532d8
1 değiştirilmiş dosya ile 12 ekleme ve 2 silme
  1. 12 2
      App.tsx

+ 12 - 2
App.tsx

@@ -134,6 +134,7 @@ const InnerApp = () => {
   const errorContext = useError();
   const navigation = React.useRef<any>(null);
   const [isUpdateAvailable, setIsUpdateAvailable] = useState(false);
+  const [latestVersion, setLatestVersion] = useState<string | null>(null);
 
   useEffect(() => {
     setupGlobalErrorHandler(navigation);
@@ -162,7 +163,11 @@ const InnerApp = () => {
         const latestVersionInt = formatVersion(version);
 
         if (latestVersionInt > currentVersionInt) {
-          setIsUpdateAvailable(true);
+          const dismissedVersion = storage.get('dismissed_update_version', StoreType.STRING) as string | null;
+          if (dismissedVersion !== version) {
+            setIsUpdateAvailable(true);
+            setLatestVersion(version);
+          }
         }
       } catch (error) {
         console.error('Failed to check latest version:', error);
@@ -202,7 +207,12 @@ const InnerApp = () => {
             title="Update Available"
             message="A new version of the NomadMania app is available. Please update to the latest version."
             action={handleUpdatePress}
-            onClose={() => setIsUpdateAvailable(false)}
+            onClose={() => {
+              if (latestVersion) {
+                storage.set('dismissed_update_version', latestVersion);
+              }
+              setIsUpdateAvailable(false);
+            }}
           />
         </NavigationContainer>
       </RegionProvider>