[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:
parent
61afa86c0e
commit
8870ef4236
|
@ -119,10 +119,15 @@ class MessageAudio extends React.Component {
|
||||||
const { file } = this.props;
|
const { file } = this.props;
|
||||||
const { baseUrl, user } = this.context;
|
const { baseUrl, user } = this.context;
|
||||||
|
|
||||||
|
let url = file.audio_url;
|
||||||
|
if (!url.startsWith('http')) {
|
||||||
|
url = `${ baseUrl }${ file.audio_url }`;
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({ loading: true });
|
this.setState({ loading: true });
|
||||||
try {
|
try {
|
||||||
await Audio.setAudioModeAsync(mode);
|
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 {
|
} catch {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,10 @@ const Reply = React.memo(({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (attachment.type === 'file') {
|
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);
|
openLink(url, theme);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@ import equal from 'deep-equal';
|
||||||
import ActionSheet from 'react-native-action-sheet';
|
import ActionSheet from 'react-native-action-sheet';
|
||||||
|
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
import Message from '../../containers/message/Message';
|
import Message from '../../containers/message';
|
||||||
import ActivityIndicator from '../../containers/ActivityIndicator';
|
import ActivityIndicator from '../../containers/ActivityIndicator';
|
||||||
import I18n from '../../i18n';
|
import I18n from '../../i18n';
|
||||||
import RocketChat from '../../lib/rocketchat';
|
import RocketChat from '../../lib/rocketchat';
|
||||||
|
@ -87,6 +87,7 @@ class MessagesView extends React.Component {
|
||||||
const { user, baseUrl, theme } = this.props;
|
const { user, baseUrl, theme } = this.props;
|
||||||
|
|
||||||
const renderItemCommonProps = item => ({
|
const renderItemCommonProps = item => ({
|
||||||
|
item,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
user,
|
user,
|
||||||
author: item.u || item.user,
|
author: item.u || item.user,
|
||||||
|
@ -110,21 +111,21 @@ class MessagesView extends React.Component {
|
||||||
},
|
},
|
||||||
noDataMsg: I18n.t('No_files'),
|
noDataMsg: I18n.t('No_files'),
|
||||||
testID: 'room-files-view',
|
testID: 'room-files-view',
|
||||||
renderItem: (item) => {
|
renderItem: item => (
|
||||||
const url = getFileUrlFromMessage(item);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Message
|
<Message
|
||||||
{...renderItemCommonProps(item)}
|
{...renderItemCommonProps(item)}
|
||||||
attachments={[{
|
item={{
|
||||||
|
...item,
|
||||||
|
u: item.user,
|
||||||
|
attachments: [{
|
||||||
title: item.name,
|
title: item.name,
|
||||||
description: item.description,
|
description: item.description,
|
||||||
...url
|
...getFileUrlFromMessage(item)
|
||||||
}]}
|
}]
|
||||||
|
}}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
/>
|
/>
|
||||||
);
|
)
|
||||||
}
|
|
||||||
},
|
},
|
||||||
// Mentions Messages Screen
|
// Mentions Messages Screen
|
||||||
Mentions: {
|
Mentions: {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import styles from './styles';
|
||||||
import Markdown from '../../containers/markdown';
|
import Markdown from '../../containers/markdown';
|
||||||
import debounce from '../../utils/debounce';
|
import debounce from '../../utils/debounce';
|
||||||
import RocketChat from '../../lib/rocketchat';
|
import RocketChat from '../../lib/rocketchat';
|
||||||
import Message from '../../containers/message/Message';
|
import Message from '../../containers/message';
|
||||||
import scrollPersistTaps from '../../utils/scrollPersistTaps';
|
import scrollPersistTaps from '../../utils/scrollPersistTaps';
|
||||||
import I18n from '../../i18n';
|
import I18n from '../../i18n';
|
||||||
import StatusBar from '../../containers/StatusBar';
|
import StatusBar from '../../containers/StatusBar';
|
||||||
|
@ -115,14 +115,10 @@ class SearchMessagesView extends React.Component {
|
||||||
const { user, baseUrl, theme } = this.props;
|
const { user, baseUrl, theme } = this.props;
|
||||||
return (
|
return (
|
||||||
<Message
|
<Message
|
||||||
|
item={item}
|
||||||
baseUrl={baseUrl}
|
baseUrl={baseUrl}
|
||||||
user={user}
|
user={user}
|
||||||
author={item.u}
|
|
||||||
ts={item.ts}
|
|
||||||
msg={item.msg}
|
|
||||||
attachments={item.attachments || []}
|
|
||||||
timeFormat='MMM Do YYYY, h:mm:ss a'
|
timeFormat='MMM Do YYYY, h:mm:ss a'
|
||||||
isEdited={!!item.editedAt}
|
|
||||||
isHeader
|
isHeader
|
||||||
showAttachment={() => {}}
|
showAttachment={() => {}}
|
||||||
getCustomEmoji={this.getCustomEmoji}
|
getCustomEmoji={this.getCustomEmoji}
|
||||||
|
|
Loading…
Reference in New Issue