diff --git a/.eslintrc b/.eslintrc
index cadce991e..c8d864c5a 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -111,7 +111,8 @@
"quotes": [2, "single"],
"semi": [2, "always"],
"prefer-const": 2,
- "object-shorthand": 2
+ "object-shorthand": 2,
+ "consistent-return": 0
},
"globals": {}
}
diff --git a/app/components/MessageBox.js b/app/components/MessageBox.js
index 11c73b2e3..32a7fef03 100644
--- a/app/components/MessageBox.js
+++ b/app/components/MessageBox.js
@@ -50,7 +50,6 @@ export default class MessageBox extends React.PureComponent {
returnKeyType='send'
onSubmitEditing={this.submit}
blurOnSubmit={false}
- autoFocus
placeholder='New message'
/>
diff --git a/app/components/RoomItem.js b/app/components/RoomItem.js
index 4e1fcf7cb..e06cae178 100644
--- a/app/components/RoomItem.js
+++ b/app/components/RoomItem.js
@@ -1,20 +1,36 @@
import React from 'react';
import PropTypes from 'prop-types';
-import { Text, StyleSheet } from 'react-native';
+import { View, Text, StyleSheet } from 'react-native';
const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ flexDirection: 'row',
+ alignItems: 'center'
+ },
+ number: {
+ width: 20,
+ lineHeight: 20,
+ borderRadius: 5,
+ backgroundColor: 'green',
+ color: '#fff',
+ textAlign: 'center',
+ overflow: 'hidden',
+ marginRight: 15
+ },
roomItem: {
lineHeight: 18,
borderTopWidth: 2,
borderColor: '#aaa',
- padding: 14
+ padding: 14,
+ flexGrow: 1
}
});
export default class RoomItem extends React.PureComponent {
static propTypes = {
onPressItem: PropTypes.func.isRequired,
- title: PropTypes.string.isRequired,
+ item: PropTypes.object.isRequired,
id: PropTypes.string.isRequired
}
@@ -22,9 +38,22 @@ export default class RoomItem extends React.PureComponent {
this.props.onPressItem(this.props.id);
};
+ renderNumber = (item) => {
+ if (item.unread) {
+ return (
+
+ { item.unread }
+
+ );
+ }
+ }
+
render() {
return (
- { this.props.title }
+
+ { this.props.item.name }
+ {this.renderNumber(this.props.item)}
+
);
}
}
diff --git a/app/views/roomsList.js b/app/views/roomsList.js
index 6e1c5f899..37624c8b2 100644
--- a/app/views/roomsList.js
+++ b/app/views/roomsList.js
@@ -62,8 +62,7 @@ export default class RoomsListView extends React.Component {
navigation = this.props.navigation;
- const currentServer = realm.objects('servers').filtered('current = true')[0];
- if (currentServer) {
+ if (RocketChat.currentServer) {
connect(() => {
// navigation.navigate('Login');
});
@@ -77,7 +76,18 @@ export default class RoomsListView extends React.Component {
}
getState = () => ({
- dataSource: realm.objects('subscriptions').filtered('_server.id = $0', RocketChat.currentServer).sorted('name')
+ dataSource: realm.objects('subscriptions').filtered('_server.id = $0', RocketChat.currentServer).sorted('name').slice()
+ .sort((a, b) => {
+ if (a.unread < b.unread) {
+ return 1;
+ }
+
+ if (a.unread > b.unread) {
+ return -1;
+ }
+
+ return 0;
+ })
})
updateState = () => {
@@ -93,7 +103,7 @@ export default class RoomsListView extends React.Component {
);