Skip to content
Commits on Source (2)
import BaseModel from '../common/BaseModel';
import {observable} from 'mobx';
/**
* Conversation model
*/
export default class ConversationModel extends BaseModel {
@observable unread = false;
@observable online = false;
//TODO: move decryption logic here
}
......@@ -71,6 +71,7 @@ export default class ConversationScreen extends Component {
let conversation;
if (params.conversation) {
conversation = params.conversation;
conversation.unread = false;
} else {
// open conversation with params.target user (minor guid go first)
if (params.target > this.props.user.me.guid) {
......
import {
observable,
action,
inject
} from 'mobx';
import {
Alert
} from 'react-native';
import messengerService from './MessengerService';
import crypto from './../common/services/crypto.service';
import socket from '../common/services/socket.service';
......@@ -18,7 +13,6 @@ import logService from '../common/services/log.service';
* Messenger Conversation Store
*/
class MessengerConversationStore {
/**
* Messages observable
*/
......
......@@ -90,9 +90,7 @@ class MessengerListStore {
@action
touchConversation = (guid) => {
// search conversation
const index = this.conversations.findIndex((conv) => {
return conv.guid == guid;
})
const index = this.conversations.findIndex(conv => conv.guid === guid);
if (index !== -1) {
const conv = this.conversations[index];
......@@ -136,7 +134,7 @@ class MessengerListStore {
try {
// is a search?
if (this.search && this.newsearch) {
if (this.search && (this.newsearch || reload)) {
this.newsearch = false;
response = await messengerService.searchConversations(this.search, rows, this);
} else {
......
import React, {
Component
} from 'react';
import React, {Component} from 'react';
import {
Text,
View,
Alert,
Image,
Platform,
FlatList,
StyleSheet,
ActivityIndicator,
Dimensions,
} from 'react-native';
import {
inject,
observer
} from 'mobx-react/native'
import {inject, observer} from 'mobx-react/native';
import _ from 'lodash';
......@@ -26,9 +19,7 @@ import Icon from 'react-native-vector-icons/MaterialIcons';
import ConversationView from './conversation/ConversationView';
import SearchView from '../common/components/SearchView';
import { CommonStyle } from '../styles/Common';
import { ComponentsStyle } from '../styles/Components';
import Colors from '../styles/Colors';
import {ComponentsStyle} from '../styles/Components';
import MessengerTabIcon from './MessengerTabIcon';
import ErrorLoading from '../common/components/ErrorLoading';
import i18n from '../common/services/i18n.service';
......@@ -36,24 +27,23 @@ import i18n from '../common/services/i18n.service';
/**
* Messenger Conversarion List Screen
*/
export default
@inject('messengerList')
@observer
export default class MessengerScreen extends Component {
class MessengerScreen extends Component {
state = {
active: false,
}
};
static navigationOptions = {
tabBarIcon: ({ tintColor }) => (
<MessengerTabIcon tintColor={tintColor} />
)
}
tabBarIcon: ({tintColor}) => <MessengerTabIcon tintColor={tintColor} />,
};
/**
* On component will mount
*/
componentDidMount() {
// load list
this.props.messengerList.loadList();
// listen socket on app start
......@@ -185,41 +175,41 @@ export default class MessengerScreen extends Component {
*/
searchChange = (search) => {
this.searchDebouncer(search);
}
};
/**
* Clear and reload
*/
refresh = () => {
this.props.messengerList.refresh();
}
};
/**
* Load more rows
*/
loadMore = () => {
this.props.messengerList.loadList()
}
this.props.messengerList.loadList();
};
/**
* render row
* @param {object} row
*/
renderMessage = (row) => {
renderMessage = row => {
return (
<ConversationView
item={row.item}
styles={styles}
navigation={this.props.navigation}
testID={row.item.username.toUpperCase()}
/>
/>
);
}
};
}
// styles
const styles = StyleSheet.create({
listView: {
listView: {
//paddingTop: 20,
flex: 1
},
......