[FIX] Messages View (#2090)

* [FIX] Messages View

* [FIX] Opening PDF from Files View

* [FIX] Audio

* [FIX] SearchMessagesView

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-05-08 14:07:58 -03:00 committed by GitHub
parent 61afa86c0e
commit 8870ef4236
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 22 deletions

View File

@ -119,10 +119,15 @@ class MessageAudio extends React.Component {
const { file } = this.props;
const { baseUrl, user } = this.context;
let url = file.audio_url;
if (!url.startsWith('http')) {
url = `${ baseUrl }${ file.audio_url }`;
}
this.setState({ loading: true });
try {
await Audio.setAudioModeAsync(mode);
await this.sound.loadAsync({ uri: `${ baseUrl }${ file.audio_url }?rc_uid=${ user.id }&rc_token=${ user.token }` });
await this.sound.loadAsync({ uri: `${ url }?rc_uid=${ user.id }&rc_token=${ user.token }` });
} catch {
// Do nothing
}

View File

@ -139,7 +139,10 @@ const Reply = React.memo(({
return;
}
if (attachment.type === 'file') {
url = `${ baseUrl }${ url }?rc_uid=${ user.id }&rc_token=${ user.token }`;
if (!url.startsWith('http')) {
url = `${ baseUrl }${ url }`;
}
url = `${ url }?rc_uid=${ user.id }&rc_token=${ user.token }`;
}
openLink(url, theme);
};

View File

@ -7,7 +7,7 @@ import equal from 'deep-equal';
import ActionSheet from 'react-native-action-sheet';
import styles from './styles';
import Message from '../../containers/message/Message';
import Message from '../../containers/message';
import ActivityIndicator from '../../containers/ActivityIndicator';
import I18n from '../../i18n';
import RocketChat from '../../lib/rocketchat';
@ -87,6 +87,7 @@ class MessagesView extends React.Component {
const { user, baseUrl, theme } = this.props;
const renderItemCommonProps = item => ({
item,
baseUrl,
user,
author: item.u || item.user,
@ -110,21 +111,21 @@ class MessagesView extends React.Component {
},
noDataMsg: I18n.t('No_files'),
testID: 'room-files-view',
renderItem: (item) => {
const url = getFileUrlFromMessage(item);
return (
<Message
{...renderItemCommonProps(item)}
attachments={[{
renderItem: item => (
<Message
{...renderItemCommonProps(item)}
item={{
...item,
u: item.user,
attachments: [{
title: item.name,
description: item.description,
...url
}]}
theme={theme}
/>
);
}
...getFileUrlFromMessage(item)
}]
}}
theme={theme}
/>
)
},
// Mentions Messages Screen
Mentions: {

View File

@ -11,7 +11,7 @@ import styles from './styles';
import Markdown from '../../containers/markdown';
import debounce from '../../utils/debounce';
import RocketChat from '../../lib/rocketchat';
import Message from '../../containers/message/Message';
import Message from '../../containers/message';
import scrollPersistTaps from '../../utils/scrollPersistTaps';
import I18n from '../../i18n';
import StatusBar from '../../containers/StatusBar';
@ -115,14 +115,10 @@ class SearchMessagesView extends React.Component {
const { user, baseUrl, theme } = this.props;
return (
<Message
item={item}
baseUrl={baseUrl}
user={user}
author={item.u}
ts={item.ts}
msg={item.msg}
attachments={item.attachments || []}
timeFormat='MMM Do YYYY, h:mm:ss a'
isEdited={!!item.editedAt}
isHeader
showAttachment={() => {}}
getCustomEmoji={this.getCustomEmoji}