fix(mobile): iOS share sheet, empty files tab, and stuck upload status
- app.json: add CFBundleDocumentTypes to iOS infoPlist so the app appears in the iOS Share Sheet; add ACTION_SEND/SEND_MULTIPLE intentFilters for Android share intent support - src/context/ShareContext.tsx (new): React context that queues files received from the share sheet and delivers them to UploadScreen - app/_layout.tsx: wrap in ShareProvider; add Linking handler (makeUrlHandler factory + getInitialURL cold-start + addEventListener warm-start) to capture file:// and content:// URLs - src/services/api.ts: fix FileRecord interface (original_filename, nested ProcessingStatus, mime_type); fix UploadResponse interface; fix listFiles() (per_page param, unwrap data.files); add getFileStatus(fileId) for single-file status polling - src/screens/FilesScreen.tsx: use file.original_filename and file.processing_status.status; fix statusEmoji to use actual backend status values (completed/pending/duplicate) - src/screens/UploadScreen.tsx: consume ShareContext for auto-upload of shared files; add 5-second polling loop (search by filename → file_id → getFileStatus) to show real-time server processing status; uploadFile wrapped in useCallback; proper effect dependency arrays Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* ShareContext – propagates files received from the iOS Share Sheet or the
|
||||
* Android Share Intent to the UploadScreen so they can be uploaded
|
||||
* automatically.
|
||||
*
|
||||
* The root layout listens for incoming file:// / content:// URLs via
|
||||
* expo-linking and calls addPendingFile(). UploadScreen consumes the context,
|
||||
* uploads each pending file, then calls clearPendingFiles().
|
||||
*/
|
||||
|
||||
import React, { createContext, useCallback, useContext, useState } from "react";
|
||||
|
||||
export interface SharedFile {
|
||||
uri: string;
|
||||
filename: string;
|
||||
mimeType?: string;
|
||||
}
|
||||
|
||||
interface ShareContextValue {
|
||||
pendingFiles: SharedFile[];
|
||||
addPendingFile: (file: SharedFile) => void;
|
||||
clearPendingFiles: () => void;
|
||||
}
|
||||
|
||||
const ShareContext = createContext<ShareContextValue>({
|
||||
pendingFiles: [],
|
||||
addPendingFile: () => {},
|
||||
clearPendingFiles: () => {},
|
||||
});
|
||||
|
||||
export function ShareProvider({ children }: { children: React.ReactNode }) {
|
||||
const [pendingFiles, setPendingFiles] = useState<SharedFile[]>([]);
|
||||
|
||||
const addPendingFile = useCallback((file: SharedFile) => {
|
||||
setPendingFiles((prev) => [...prev, file]);
|
||||
}, []);
|
||||
|
||||
const clearPendingFiles = useCallback(() => {
|
||||
setPendingFiles([]);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<ShareContext.Provider value={{ pendingFiles, addPendingFile, clearPendingFiles }}>
|
||||
{children}
|
||||
</ShareContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useShare(): ShareContextValue {
|
||||
return useContext(ShareContext);
|
||||
}
|
||||
Reference in New Issue
Block a user