From aafa01c8129b751b3f89d51d55c37b34a9936999 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Tue, 21 Nov 2017 15:09:22 -0200 Subject: [PATCH] lint --- app/actions/actionsTypes.js | 2 +- app/actions/room.js | 8 ++++---- app/containers/MessageBox.js | 7 ++++--- app/lib/rocketchat.js | 4 ++-- app/sagas/rooms.js | 8 ++++---- app/views/RoomView.js | 4 +++- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/app/actions/actionsTypes.js b/app/actions/actionsTypes.js index 4250f88bc..effed1822 100644 --- a/app/actions/actionsTypes.js +++ b/app/actions/actionsTypes.js @@ -27,7 +27,7 @@ export const FORGOT_PASSWORD = createRequestTypes('FORGOT_PASSWORD', [ 'INIT' ]); export const ROOMS = createRequestTypes('ROOMS'); -export const ROOM = createRequestTypes('ROOM', ['ADD_USER_TYPING', 'REMOVE_USER_TYPING', 'USER_TYPING', 'OPEN', 'IM_TYPING']); +export const ROOM = createRequestTypes('ROOM', ['ADD_USER_TYPING', 'REMOVE_USER_TYPING', 'SOMEONE_TYPING', 'OPEN', 'USER_TYPING']); export const APP = createRequestTypes('APP', ['READY', 'INIT']); export const MESSAGES = createRequestTypes('MESSAGES', [ ...defaultTypes, diff --git a/app/actions/room.js b/app/actions/room.js index c98648a09..14e346fc3 100644 --- a/app/actions/room.js +++ b/app/actions/room.js @@ -8,9 +8,9 @@ export function removeUserTyping(username) { }; } -export function typing(data) { +export function someoneTyping(data) { return { - type: types.ROOM.USER_TYPING, + type: types.ROOM.SOMEONE_TYPING, ...data }; } @@ -29,9 +29,9 @@ export function openRoom(room) { }; } -export function imTyping(status = true) { +export function userTyping(status = true) { return { - type: types.ROOM.IM_TYPING, + type: types.ROOM.USER_TYPING, status }; } diff --git a/app/containers/MessageBox.js b/app/containers/MessageBox.js index ce8474e0c..65740a51c 100644 --- a/app/containers/MessageBox.js +++ b/app/containers/MessageBox.js @@ -4,7 +4,7 @@ import { View, TextInput, StyleSheet, SafeAreaView } from 'react-native'; import Icon from 'react-native-vector-icons/MaterialIcons'; import ImagePicker from 'react-native-image-picker'; import { connect } from 'react-redux'; -import { imTyping } from '../actions/room'; +import { userTyping } from '../actions/room'; import RocketChat from '../lib/rocketchat'; import { editRequest } from '../actions/messages'; @@ -41,7 +41,7 @@ const styles = StyleSheet.create({ editing: state.messages.editing }), dispatch => ({ editRequest: message => dispatch(editRequest(message)), - typing: status => dispatch(imTyping(status)) + typing: status => dispatch(userTyping(status)) })) export default class MessageBox extends React.Component { static propTypes = { @@ -49,7 +49,8 @@ export default class MessageBox extends React.Component { rid: PropTypes.string.isRequired, editRequest: PropTypes.func.isRequired, message: PropTypes.object, - editing: PropTypes.bool + editing: PropTypes.bool, + typing: PropTypes.bool } componentWillReceiveProps(nextProps) { diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 376a62798..b58f49841 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -8,7 +8,7 @@ import reduxStore from './createStore'; import settingsType from '../constants/settings'; import realm from './realm'; import * as actions from '../actions'; -import { typing } from '../actions/room'; +import { someoneTyping } from '../actions/room'; import { disconnect, connectSuccess } from '../actions/connect'; export { Accounts } from 'react-native-meteor'; @@ -79,7 +79,7 @@ const RocketChat = { if (ev !== 'typing') { return; } - return reduxStore.dispatch(typing({ _rid, username: ddpMessage.fields.args[0], typing: ddpMessage.fields.args[1] })); + return reduxStore.dispatch(someoneTyping({ _rid, username: ddpMessage.fields.args[0], typing: ddpMessage.fields.args[1] })); } if (ddpMessage.collection === 'stream-notify-user') { const [type, data] = ddpMessage.fields.args; diff --git a/app/sagas/rooms.js b/app/sagas/rooms.js index 6742577e0..4a4f88ef4 100644 --- a/app/sagas/rooms.js +++ b/app/sagas/rooms.js @@ -22,7 +22,7 @@ const watchRoomsRequest = function* watchRoomsRequest() { const cancelTyping = function* cancelTyping(username) { while (true) { const { typing, timeout } = yield race({ - typing: take(types.ROOM.USER_TYPING), + typing: take(types.ROOM.SOMEONE_TYPING), timeout: yield call(delay, 5000) }); if (timeout || (typing.username === username && !typing.typing)) { @@ -33,7 +33,7 @@ const cancelTyping = function* cancelTyping(username) { const usersTyping = function* usersTyping({ rid }) { while (true) { - const { _rid, username, typing } = yield take(types.ROOM.USER_TYPING); + const { _rid, username, typing } = yield take(types.ROOM.SOMEONE_TYPING); if (_rid === rid) { yield (typing ? put(addUserTyping(username)) : put(removeUserTyping(username))); if (typing) { @@ -70,7 +70,7 @@ const watchRoomOpen = function* watchRoomOpen({ room }) { subscriptions.forEach(sub => sub.stop()); }; -const watchImTyping = function* watchImTyping({ status }) { +const watchuserTyping = function* watchuserTyping({ status }) { const auth = yield select(state => state.login.isAuthenticated); if (!auth) { yield take(types.LOGIN.SUCCESS); @@ -90,7 +90,7 @@ const watchImTyping = function* watchImTyping({ status }) { }; const root = function* root() { - yield takeLatest(types.ROOM.IM_TYPING, watchImTyping); + yield takeLatest(types.ROOM.USER_TYPING, watchuserTyping); yield takeLatest(types.LOGIN.SUCCESS, watchRoomsRequest); yield takeLatest(types.ROOM.OPEN, watchRoomOpen); }; diff --git a/app/views/RoomView.js b/app/views/RoomView.js index 307824611..8faf11248 100644 --- a/app/views/RoomView.js +++ b/app/views/RoomView.js @@ -71,7 +71,9 @@ export default class RoomView extends React.Component { server: PropTypes.string, Site_Url: PropTypes.string, Message_TimeFormat: PropTypes.string, - loading: PropTypes.bool + loading: PropTypes.bool, + usersTyping: PropTypes.array, + username: PropTypes.string }; constructor(props) {