import React from 'react';
import PropTypes from 'prop-types';
import { FlatList, Text, View } from 'react-native';
import { connect } from 'react-redux';
import LoggedView from '../View';
import { openRoomFiles, closeRoomFiles } from '../../actions/roomFiles';
import styles from './styles';
import Message from '../../containers/message';
@connect(
state => ({
messages: state.roomFiles.messages,
user: state.login.user,
baseUrl: state.settings.Site_Url || state.server ? state.server.server : ''
}),
dispatch => ({
openRoomFiles: rid => dispatch(openRoomFiles(rid)),
closeRoomFiles: () => dispatch(closeRoomFiles())
})
)
export default class RoomFilesView extends LoggedView {
static propTypes = {
navigation: PropTypes.object,
messages: PropTypes.array,
user: PropTypes.object,
baseUrl: PropTypes.string,
openRoomFiles: PropTypes.func,
closeRoomFiles: PropTypes.func
}
constructor(props) {
super('RoomFilesView', props);
}
componentDidMount() {
this.props.openRoomFiles(this.props.navigation.state.params.rid);
}
componentWillUnmount() {
this.props.closeRoomFiles();
}
renderEmpty = () => (
No files
)
renderItem = ({ item }) => (
)
render() {
if (this.props.messages.length === 0) {
return this.renderEmpty();
}
return (
item._id}
/>
);
}
}