From 61e852d963fb04b13b7bda39830e208a648b3545 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 13 Mar 2024 16:51:42 +0000 Subject: fix(mobile): Multiple attempts to stop the duplication sharing --- packages/mobile/app/_layout.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'packages/mobile/app/_layout.tsx') diff --git a/packages/mobile/app/_layout.tsx b/packages/mobile/app/_layout.tsx index 561e911e..c4298ec4 100644 --- a/packages/mobile/app/_layout.tsx +++ b/packages/mobile/app/_layout.tsx @@ -9,16 +9,22 @@ import { useEffect } from "react"; import { View } from "react-native"; import { Providers } from "@/lib/providers"; +import { useLastSharedIntent } from "@/lib/last-shared-intent"; export default function RootLayout() { const router = useRouter(); const { hasShareIntent, shareIntent, resetShareIntent } = useShareIntent(); + const lastSharedIntent = useLastSharedIntent(); + useEffect(() => { - if (hasShareIntent) { + 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); router.replace({ pathname: "sharing", - params: { shareIntent: JSON.stringify(shareIntent) }, + params: { shareIntent: intentJson }, }); resetShareIntent(); } -- cgit v1.2.3-70-g09d2