Separate attachment types
This commit is contained in:
parent
e21fac2c70
commit
6b9d3684df
|
@ -33,7 +33,8 @@ const styles = StyleSheet.create({
|
||||||
|
|
||||||
@connect(state => ({
|
@connect(state => ({
|
||||||
message: state.messages.message,
|
message: state.messages.message,
|
||||||
editing: state.messages.editing
|
editing: state.messages.editing,
|
||||||
|
server: state.server.server
|
||||||
}), dispatch => ({
|
}), dispatch => ({
|
||||||
actionsShow: actionMessage => dispatch(actionsShow(actionMessage))
|
actionsShow: actionMessage => dispatch(actionsShow(actionMessage))
|
||||||
}))
|
}))
|
||||||
|
@ -44,7 +45,8 @@ export default class Message extends React.Component {
|
||||||
Message_TimeFormat: PropTypes.string.isRequired,
|
Message_TimeFormat: PropTypes.string.isRequired,
|
||||||
message: PropTypes.object.isRequired,
|
message: PropTypes.object.isRequired,
|
||||||
editing: PropTypes.bool,
|
editing: PropTypes.bool,
|
||||||
actionsShow: PropTypes.func
|
actionsShow: PropTypes.func,
|
||||||
|
server: PropTypes.string
|
||||||
}
|
}
|
||||||
|
|
||||||
onLongPress() {
|
onLongPress() {
|
||||||
|
@ -57,11 +59,24 @@ export default class Message extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
attachments() {
|
attachments() {
|
||||||
return this.props.item.attachments.length ? (
|
if (this.props.item.attachments.length === 0) {
|
||||||
<Card
|
return null;
|
||||||
data={this.props.item.attachments[0]}
|
}
|
||||||
/>
|
|
||||||
) : null;
|
const file = this.props.item.attachments[0];
|
||||||
|
if (file.image_type) {
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
data={file}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
} else if (file.audio_type) {
|
||||||
|
return <Text>{`${ this.props.server }${ JSON.parse(JSON.stringify(file.audio_url)) }`}</Text>;
|
||||||
|
} else if (file.video_type) {
|
||||||
|
return <Text>{`${ this.props.server }${ JSON.parse(JSON.stringify(file.video_url)) }`}</Text>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <Text>Other type</Text>;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderMessageContent() {
|
renderMessageContent() {
|
||||||
|
|
|
@ -99,14 +99,16 @@ const attachment = {
|
||||||
name: 'attachment',
|
name: 'attachment',
|
||||||
properties: {
|
properties: {
|
||||||
description: { type: 'string', optional: true },
|
description: { type: 'string', optional: true },
|
||||||
|
|
||||||
image_size: { type: 'int', optional: true },
|
image_size: { type: 'int', optional: true },
|
||||||
|
|
||||||
image_type: { type: 'string', optional: true },
|
image_type: { type: 'string', optional: true },
|
||||||
|
|
||||||
image_url: { type: 'string', optional: true },
|
image_url: { type: 'string', optional: true },
|
||||||
|
audio_size: { type: 'int', optional: true },
|
||||||
|
audio_type: { type: 'string', optional: true },
|
||||||
|
audio_url: { type: 'string', optional: true },
|
||||||
|
video_size: { type: 'int', optional: true },
|
||||||
|
video_type: { type: 'string', optional: true },
|
||||||
|
video_url: { type: 'string', optional: true },
|
||||||
title: { type: 'string', optional: true },
|
title: { type: 'string', optional: true },
|
||||||
|
|
||||||
title_link: { type: 'string', optional: true },
|
title_link: { type: 'string', optional: true },
|
||||||
title_link_download: { type: 'bool', optional: true },
|
title_link_download: { type: 'bool', optional: true },
|
||||||
type: { type: 'string', optional: true }
|
type: { type: 'string', optional: true }
|
||||||
|
|
Loading…
Reference in New Issue