fix(mobile): add shared file to ShareContext directly in +not-found.tsx

When iOS delivers a file via "Open In…", expo-router strips the
docuelevate:// scheme and routes to +not-found.tsx. Previously, this
screen only redirected to the Upload tab and relied on the Linking
handler in _layout.tsx to add the file to ShareContext. This was
unreliable because expo-router may consume the URL event before the
Linking handler fires.

Now +not-found.tsx directly reconstructs the file:// URI from the
pathname and adds it to ShareContext before redirecting. ShareContext
deduplicates by URI to prevent double uploads if both mechanisms fire.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-19 11:12:34 +00:00
parent 34ea9333fb
commit 71a7a57adc
5 changed files with 52 additions and 16 deletions
+10 -1
View File
@@ -32,7 +32,16 @@ export function ShareProvider({ children }: { children: React.ReactNode }) {
const [pendingFiles, setPendingFiles] = useState<SharedFile[]>([]);
const addPendingFile = useCallback((file: SharedFile) => {
setPendingFiles((prev) => [...prev, file]);
setPendingFiles((prev) => {
// Deduplicate by normalised URI so the same file is not uploaded twice
// when both the Linking handler (_layout.tsx) and +not-found.tsx fire.
const normalize = (uri: string) => {
try { return decodeURIComponent(uri); } catch { return uri; }
};
const norm = normalize(file.uri);
if (prev.some((f) => normalize(f.uri) === norm)) return prev;
return [...prev, file];
});
}, []);
const clearPendingFiles = useCallback(() => {