mattermost-mobile/app/components/message_attachments/attachment_actions.js
Elias Nahum 736a955be8
Use post metadata to prevent scroll pop (#2304)
* Use post metadata to prevent scroll pop

* Fix not to fetch for reactions every time

* Update post-metadata mm-redux ref

* Update mattermost-redux to include post-metadata
2018-11-22 19:47:27 -03:00

76 lines
1.9 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {PureComponent} from 'react';
import {StyleSheet, View} from 'react-native';
import PropTypes from 'prop-types';
import ActionMenu from './action_menu';
import ActionButton from './action_button';
export default class AttachmentActions extends PureComponent {
static propTypes = {
actions: PropTypes.array,
navigator: PropTypes.object.isRequired,
postId: PropTypes.string.isRequired,
};
render() {
const {
actions,
navigator,
postId,
} = this.props;
if (!actions?.length) {
return null;
}
const content = [];
actions.forEach((action) => {
if (!action.id || !action.name) {
return;
}
switch (action.type) {
case 'select':
content.push(
<ActionMenu
key={action.id}
id={action.id}
name={action.name}
dataSource={action.data_source}
options={action.options}
postId={postId}
navigator={navigator}
/>
);
break;
case 'button':
default:
content.push(
<ActionButton
key={action.id}
id={action.id}
name={action.name}
postId={postId}
/>
);
break;
}
});
return (
<View style={style.container}>
{content}
</View>
);
}
}
const style = StyleSheet.create({
container: {
flex: 1,
},
});