aboutsummaryrefslogtreecommitdiffstats
path: root/apps/mobile/app
diff options
context:
space:
mode:
Diffstat (limited to 'apps/mobile/app')
-rw-r--r--apps/mobile/app/_layout.tsx50
-rw-r--r--apps/mobile/app/sharing.tsx21
2 files changed, 26 insertions, 45 deletions
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>
);
}
diff --git a/apps/mobile/app/sharing.tsx b/apps/mobile/app/sharing.tsx
index f9f423b5..e8b0ad09 100644
--- a/apps/mobile/app/sharing.tsx
+++ b/apps/mobile/app/sharing.tsx
@@ -1,8 +1,7 @@
-import type { ShareIntent } from "expo-share-intent";
-import { useEffect, useMemo, useState } from "react";
+import { useEffect, useState } from "react";
import { Text, View } from "react-native";
-import { Link, useLocalSearchParams, useRouter } from "expo-router";
-import { useShareIntent } from "expo-share-intent";
+import { Link, useRouter } from "expo-router";
+import { useShareIntentContext } from "expo-share-intent";
import { api } from "@/lib/trpc";
import { z } from "zod";
@@ -12,19 +11,7 @@ type Mode =
| { type: "error" };
function SaveBookmark({ setMode }: { setMode: (mode: Mode) => void }) {
- // Desperate attempt to fix sharing duplication
- const { hasShareIntent, resetShareIntent } = useShareIntent();
-
- const params = useLocalSearchParams();
-
- const shareIntent = useMemo(() => {
- if (params?.shareIntent) {
- if (typeof params.shareIntent === "string") {
- return JSON.parse(params.shareIntent) as ShareIntent;
- }
- }
- return null;
- }, [params]);
+ const { hasShareIntent, shareIntent, resetShareIntent } = useShareIntentContext();
const invalidateAllBookmarks =
api.useUtils().bookmarks.getBookmarks.invalidate;