From f922e1650df550b3dec2f010ffdc6c15ea11390d Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Fri, 15 Mar 2024 16:34:42 +0000
Subject: fix(mobile): Bump expo-share-intent version and remove the hacks
 around the old version

---
 apps/mobile/app/_layout.tsx | 50 ++++++++++++++++++++-------------------------
 1 file changed, 22 insertions(+), 28 deletions(-)

(limited to 'apps/mobile/app/_layout.tsx')

diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsx
index b338af5e..9f8f8ad5 100644
--- a/apps/mobile/app/_layout.tsx
+++ b/apps/mobile/app/_layout.tsx
@@ -5,48 +5,42 @@ import { useEffect } from "react";
 import { View } from "react-native";
 import { useRouter } from "expo-router";
 import { Stack } from "expo-router/stack";
-import { useShareIntent } from "expo-share-intent";
+import { ShareIntentProvider, useShareIntent } from "expo-share-intent";
 import { StatusBar } from "expo-status-bar";
-import { useLastSharedIntent } from "@/lib/last-shared-intent";
 import { Providers } from "@/lib/providers";
 
 export default function RootLayout() {
   const router = useRouter();
-  const { hasShareIntent, shareIntent, resetShareIntent } = useShareIntent();
-
-  const lastSharedIntent = useLastSharedIntent();
+  const { hasShareIntent } = useShareIntent();
 
   useEffect(() => {
-    const intentJson = JSON.stringify(shareIntent);
-    if (hasShareIntent && !lastSharedIntent.isPreviouslyShared(intentJson)) {
-      // TODO: Remove once https://github.com/achorein/expo-share-intent/issues/14 is fixed
-      lastSharedIntent.setIntent(intentJson);
+    if (hasShareIntent) {
       router.replace({
         pathname: "sharing",
-        params: { shareIntent: intentJson },
       });
-      resetShareIntent();
     }
   }, [hasShareIntent]);
 
   return (
-    <Providers>
-      <View className="h-full w-full bg-white">
-        <Stack
-          screenOptions={{
-            headerShown: false,
-          }}
-        >
-          <Stack.Screen name="index" />
-          <Stack.Screen
-            name="sharing"
-            options={{
-              presentation: "modal",
+    <ShareIntentProvider>
+      <Providers>
+        <View className="h-full w-full bg-white">
+          <Stack
+            screenOptions={{
+              headerShown: false,
             }}
-          />
-        </Stack>
-        <StatusBar style="auto" />
-      </View>
-    </Providers>
+          >
+            <Stack.Screen name="index" />
+            <Stack.Screen
+              name="sharing"
+              options={{
+                presentation: "modal",
+              }}
+            />
+          </Stack>
+          <StatusBar style="auto" />
+        </View>
+      </Providers>
+    </ShareIntentProvider>
   );
 }
-- 
cgit v1.2.3-70-g09d2

