204000aabc
Resolve 3 merge conflicts and renumber the automation_hooks migration to follow main's migration chain (036_add_document_translation_fields). Conflicts resolved: - app/api/__init__.py: add automation_router alongside main's new routers - app/utils/settings_service.py: add automation_hooks_enabled alongside compliance_enabled - tests/conftest.py: add AutomationHook alongside AuditLog/ComplianceTemplate imports Migration renumbered: - 027_add_automation_hooks → 037_add_automation_hooks - down_revision: 026_add_scheduled_jobs → 036_add_document_translation_fields Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
/**
|
||
* 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);
|
||
}
|