diff --git a/example/src/ConversationScreen.tsx b/example/src/ConversationScreen.tsx index 1b79f967b..9e22e9c96 100644 --- a/example/src/ConversationScreen.tsx +++ b/example/src/ConversationScreen.tsx @@ -36,12 +36,17 @@ import { PermissionStatus } from "expo-modules-core"; import type { DocumentPickerAsset } from "expo-document-picker"; import type { ImagePickerAsset } from "expo-image-picker"; +type Attachment = { + file?: DocumentPickerAsset + image?: ImagePickerAsset +} + /// Show the messages in a conversation. export default function ConversationScreen({ route, }: NativeStackScreenProps) { let { topic } = route.params; - let messageListRef = useRef(); + let messageListRef = useRef(null); let { data: messages, refetch: refreshMessages, @@ -52,8 +57,7 @@ export default function ConversationScreen({ let [replyingTo, setReplyingTo] = useState(null); let [text, setText] = useState(""); let [isShowingAttachmentModal, setShowingAttachmentModal] = useState(false); - let [attachment, setAttachment] = useState< - { image: ImagePickerAsset } | { file: DocumentPickerAsset } | null + let [attachment, setAttachment] = useState(null); let [isAttachmentPreviewing, setAttachmentPreviewing] = useState(false); let [isSending, setSending] = useState(false); @@ -255,8 +259,7 @@ function AttachmentPreviewModal({ onRequestClose, }: { attachment: - | { image: ImagePickerAsset } - | { file: DocumentPickerAsset } + Attachment | null; visible: boolean; onRequestClose: () => void; @@ -264,7 +267,7 @@ function AttachmentPreviewModal({ let isImage = attachment?.image?.type === "image"; return ( - {isImage && ( + {(isImage && attachment?.image) && ( void; onRemove: () => void; }) { @@ -323,7 +326,7 @@ function AttachmentInputHeader({ }} > - {isImage && ( + {(isImage && attachment?.image) && ( {}, }); export const useXmtp = () => useContext(XmtpContext); -export function XmtpContextProvider({ children }) { +type Props = { + children: ReactNode +} +export const XmtpContextProvider: FC = ({ children }) => { let [client, setClient] = useState(null); let context = useMemo(() => ({ client, setClient }), [client, setClient]); return ( diff --git a/example/src/hooks.tsx b/example/src/hooks.tsx index dcaafe763..ce50cd60a 100644 --- a/example/src/hooks.tsx +++ b/example/src/hooks.tsx @@ -248,7 +248,7 @@ export function usePrepareRemoteAttachment({ fileUri, mimeType, }: { - fileUri?: `file://${string}`; + fileUri?: string; mimeType?: string; }): { remoteAttachment: RemoteAttachmentContent | undefined; diff --git a/example/src/storage.ts b/example/src/storage.ts index 62cd03536..23297650e 100644 --- a/example/src/storage.ts +++ b/example/src/storage.ts @@ -25,7 +25,7 @@ export async function uploadFile( return url; } -export async function downloadFile(url: string): Promise<`file://${string}`> { +export async function downloadFile(url: string): Promise { console.log("downloading from", url); let res = await ReactNativeBlobUtil.config({ fileCache: true }).fetch( "GET",