Read room on open

This commit is contained in:
Guilherme Gazzo 2017-11-13 22:13:27 -02:00
parent 8e67e75a09
commit 8cbccdfb23
No known key found for this signature in database
GPG Key ID: 1F85C9AD922D0829
2 changed files with 13 additions and 17 deletions

View File

@ -10,6 +10,7 @@ const get = function* get({ rid }) {
} }
try { try {
yield RocketChat.loadMessagesForRoom(rid, null); yield RocketChat.loadMessagesForRoom(rid, null);
yield RocketChat.readMessages(rid);
yield put(messagesSuccess()); yield put(messagesSuccess());
} catch (err) { } catch (err) {
console.log(err); console.log(err);

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Text, View, StyleSheet, Button, InteractionManager, SafeAreaView } from 'react-native'; import { Text, View, StyleSheet, Button } from 'react-native';
import { ListView } from 'realm/react-native'; import { ListView } from 'realm/react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
@ -19,9 +19,6 @@ const styles = StyleSheet.create({
flex: 1, flex: 1,
backgroundColor: '#fff' backgroundColor: '#fff'
}, },
safeAreaView: {
flex: 1
},
list: { list: {
flex: 1, flex: 1,
transform: [{ scaleY: -1 }] transform: [{ scaleY: -1 }]
@ -196,20 +193,18 @@ export default class RoomView extends React.Component {
render() { render() {
return ( return (
<KeyboardView contentContainerStyle={styles.container} keyboardVerticalOffset={64}> <KeyboardView style={styles.container} keyboardVerticalOffset={64}>
{this.renderBanner()} {this.renderBanner()}
<SafeAreaView style={styles.safeAreaView}> <ListView
<ListView enableEmptySections
enableEmptySections style={styles.list}
style={styles.list} onEndReachedThreshold={10}
onEndReachedThreshold={10} renderFooter={this.renderHeader}
renderFooter={this.renderHeader} onEndReached={this.onEndReached}
onEndReached={this.onEndReached} dataSource={this.state.dataSource}
dataSource={this.state.dataSource} renderRow={item => this.renderItem({ item })}
renderRow={item => this.renderItem({ item })} initialListSize={10}
initialListSize={10} />
/>
</SafeAreaView>
{this.renderFooter()} {this.renderFooter()}
</KeyboardView> </KeyboardView>
); );