Skip to content

Commit 17b3fb5

Browse files
author
HuyDo
committed
fix: address comment PR
1 parent 89bc16d commit 17b3fb5

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,30 @@ Then using our Addons component in ChatScreen
112112
```javascript
113113
import React from 'react'
114114
import {ChatScreen as BaseChatScreen} from 'rn-firebase-chat'
115-
import {CameraView, useCamera, FileAttachmentRef, FileAttachment} from 'rn-firebase-chat/src/addons/camera'
115+
import {
116+
CameraView,
117+
useCamera,
118+
FileAttachmentRef,
119+
FileAttachment,
120+
} from 'rn-firebase-chat/src/addons';
116121

117122
...
118123

119124
export const ChatScreen: React.FC = () => {
120125
const {onPressCamera, onPressGallery} = useCamera()
121-
const fileAttachmentRef = useRef<FileAttachmentRef>(null);
126+
const fileAttachmentRef = useRef<FileAttachmentRef>(null);
127+
const renderLeftCustomView = useCallback(() => {
128+
return (
129+
<View>
130+
<Button
131+
title="file"
132+
onPress={() => {
133+
fileAttachmentRef.current?.pickDocument();
134+
}}
135+
/>
136+
</View>
137+
);
138+
}, []);
122139

123140
return (
124141
<BaseChatScreen
@@ -129,6 +146,7 @@ export const ChatScreen: React.FC = () => {
129146
hasGallery: true,
130147
onPressCamera,
131148
onPressGallery,
149+
renderLeftCustomView
132150
}}
133151
>
134152
{({onSend}) => (

src/services/firebase/firestore.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,10 @@ export class FirestoreServices {
224224
const { path, extension, type, fileName, size } = message;
225225

226226
if (!path || !extension || this.conversationId === null || !type) {
227-
throw new Error('Please provide path and extension');
227+
console.error(
228+
'Please provide path, extension, conversationId and type before sending message with file'
229+
);
230+
return;
228231
}
229232

230233
try {
@@ -272,9 +275,8 @@ export class FirestoreServices {
272275
*/
273276
sendMessage = async (message: MessageProps) => {
274277
if (!this.conversationId) {
275-
throw new Error(
276-
'Please create conversation before send the first message!'
277-
);
278+
console.log('Please create conversation before send the first message!');
279+
return;
278280
}
279281
const { text, type, path, extension, fileName, size } = message;
280282
let messageData;

src/utilities/messageFormatter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ const getAbsoluteFilePathWithName = async (path: string, name: string) => {
172172
console.error('Error copying file:', error);
173173
}
174174
}
175-
return path?.startsWith?.('file:/') ? path : `file://${path}`;
175+
return getAbsoluteFilePath(path);
176176
};
177177

178178
export {

0 commit comments

Comments
 (0)