Skip to content

Commit

Permalink
fix: restore file picker on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexogamer committed Apr 22, 2024
1 parent f3e2605 commit 0e2f47e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
19 changes: 9 additions & 10 deletions src/MessageBox.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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[],
);

Expand Down Expand Up @@ -177,7 +175,8 @@ export const MessageBox = observer((props: MessageBoxProps) => {
</View>
) : null}
<View style={styles.messageBoxInner}>
{app.settings.get('ui.messaging.sendAttachments') &&
{Platform.OS !== 'web' &&
app.settings.get('ui.messaging.sendAttachments') &&
attachments.length < 5 ? (
<Pressable
style={{
Expand Down
9 changes: 7 additions & 2 deletions src/components/sheets/SettingsSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,12 @@ export const SettingsSheet = observer(({setState}: {setState: Function}) => {
</View>
<View style={{alignItems: 'center', marginVertical: 16}}>
<Text type={'header'}>RVMob v{app.version}</Text>
<View style={{flexDirection: 'row'}}>
<View
style={{
justifyContent: 'center',
flexDirection: 'row',
flexWrap: 'wrap',
}}>
<Text>Powered by </Text>
<Link link={'https://reactnative.dev'} label={'React Native'} />
<Text>
Expand All @@ -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 '}
Expand Down
3 changes: 3 additions & 0 deletions src/crossplat/DocumentPicker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import CoreDocumentPicker from 'react-native-document-picker';

export const DocumentPicker = CoreDocumentPicker;
5 changes: 5 additions & 0 deletions src/crossplat/DocumentPicker.web.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const DocumentPicker = {
pickSingle: (_opts: any) => {
console.warn('DocumentPicker is not implemented on web');
},
};

0 comments on commit 0e2f47e

Please sign in to comment.