diff --git a/src/MessageBox.tsx b/src/MessageBox.tsx index cb76d3c..67f4e9f 100644 --- a/src/MessageBox.tsx +++ b/src/MessageBox.tsx @@ -1,17 +1,15 @@ import React from 'react'; -import {Pressable, View, TextInput} from 'react-native'; +import {Pressable, View, TextInput, Platform} from 'react-native'; import {observer} from 'mobx-react-lite'; -// FIXME: uncomment once rndp is excluded on web -// import DocumentPicker, { -// DocumentPickerResponse, -// } from 'react-native-document-picker'; +import {type DocumentPickerResponse} from 'react-native-document-picker'; import MaterialIcon from 'react-native-vector-icons/MaterialIcons'; import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'; import {Channel, Message} from 'revolt.js'; import {ulid} from 'ulid'; +import {DocumentPicker} from './crossplat/DocumentPicker'; import {app, client, setFunction} from './Generic'; import {Avatar} from './Profile'; import {styles, currentTheme} from './Theme'; @@ -43,14 +41,14 @@ function placeholderText(channel: Channel) { } export const MessageBox = observer((props: MessageBoxProps) => { - let [currentText, setCurrentText] = React.useState(''); - let [editingMessage, setEditingMessage] = React.useState( + const [currentText, setCurrentText] = React.useState(''); + const [editingMessage, setEditingMessage] = React.useState( null as Message | null, ); - let [replyingMessages, setReplyingMessages] = React.useState( + const [replyingMessages, setReplyingMessages] = React.useState( [] as ReplyingMessage[], ); - let [attachments, setAttachments] = React.useState( + const [attachments, setAttachments] = React.useState( [] as DocumentPickerResponse[], ); @@ -177,7 +175,8 @@ export const MessageBox = observer((props: MessageBoxProps) => { ) : null} - {app.settings.get('ui.messaging.sendAttachments') && + {Platform.OS !== 'web' && + app.settings.get('ui.messaging.sendAttachments') && attachments.length < 5 ? ( { RVMob v{app.version} - + Powered by @@ -586,7 +591,7 @@ export const SettingsSheet = observer(({setState}: {setState: Function}) => { Platform.constants.reactNativeVersion.minor }.${Platform.constants.reactNativeVersion.patch}${ Platform.constants.reactNativeVersion.prerelease - ? ` (prerel: ${Platform.constants.reactNativeVersion.prerelease})` + ? `-${Platform.constants.reactNativeVersion.prerelease}` : '' }`} {' and '} diff --git a/src/crossplat/DocumentPicker.ts b/src/crossplat/DocumentPicker.ts new file mode 100644 index 0000000..68346e4 --- /dev/null +++ b/src/crossplat/DocumentPicker.ts @@ -0,0 +1,3 @@ +import CoreDocumentPicker from 'react-native-document-picker'; + +export const DocumentPicker = CoreDocumentPicker; diff --git a/src/crossplat/DocumentPicker.web.ts b/src/crossplat/DocumentPicker.web.ts new file mode 100644 index 0000000..ec5d8f0 --- /dev/null +++ b/src/crossplat/DocumentPicker.web.ts @@ -0,0 +1,5 @@ +export const DocumentPicker = { + pickSingle: (_opts: any) => { + console.warn('DocumentPicker is not implemented on web'); + }, +};