From 40cb3e536bb9d8807498de163a446f984c70e68e Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Wed, 14 Feb 2018 19:26:15 -0200 Subject: [PATCH] fix lint --- __tests__/__snapshots__/RoomItem.js.snap | 750 ++++++--- .../__snapshots__/Storyshots.test.js.snap | 1481 +++++++++++------ app/lib/rocketchat.js | 8 +- app/presentation/RoomItem.js | 23 +- app/views/RoomView/index.js | 10 +- app/views/RoomsListView/index.js | 6 +- 6 files changed, 1548 insertions(+), 730 deletions(-) diff --git a/__tests__/__snapshots__/RoomItem.js.snap b/__tests__/__snapshots__/RoomItem.js.snap index 23643947..14e65d1d 100644 --- a/__tests__/__snapshots__/RoomItem.js.snap +++ b/__tests__/__snapshots__/RoomItem.js.snap @@ -33,10 +33,12 @@ exports[`render channel 1`] = ` style={ Array [ Object { - "alignItems": "center", + "alignItems": "flex-start", + "borderBottomColor": "#ddd", + "borderBottomWidth": 0.5, "flexDirection": "row", "paddingHorizontal": 16, - "paddingVertical": 10, + "paddingVertical": 12, }, undefined, ] @@ -53,8 +55,8 @@ exports[`render channel 1`] = ` Object { "backgroundColor": "#00BCD4", "borderRadius": 4, - "height": 40, - "width": 40, + "height": 56, + "width": 56, }, undefined, ] @@ -75,7 +77,7 @@ exports[`render channel 1`] = ` "color": "#ffffff", }, Object { - "fontSize": 20, + "fontSize": 28, }, ], Object { @@ -93,44 +95,89 @@ exports[`render channel 1`] = ` style={ Object { "flex": 1, + "height": "100%", "marginLeft": 16, "marginRight": 4, } } > - - general - - - Nov 10 - + + general + + + Nov 10 + + + + + + + @@ -170,10 +217,12 @@ exports[`render no icon 1`] = ` style={ Array [ Object { - "alignItems": "center", + "alignItems": "flex-start", + "borderBottomColor": "#ddd", + "borderBottomWidth": 0.5, "flexDirection": "row", "paddingHorizontal": 16, - "paddingVertical": 10, + "paddingVertical": 12, }, undefined, ] @@ -190,8 +239,8 @@ exports[`render no icon 1`] = ` Object { "backgroundColor": "#3F51B5", "borderRadius": 4, - "height": 40, - "width": 40, + "height": 56, + "width": 56, }, undefined, ] @@ -212,7 +261,7 @@ exports[`render no icon 1`] = ` "color": "#ffffff", }, Object { - "fontSize": 20, + "fontSize": 28, }, ], Object { @@ -230,44 +279,89 @@ exports[`render no icon 1`] = ` style={ Object { "flex": 1, + "height": "100%", "marginLeft": 16, "marginRight": 4, } } > - - name - - - Nov 10 - + + name + + + Nov 10 + + + + + + + @@ -307,10 +401,12 @@ exports[`render private group 1`] = ` style={ Array [ Object { - "alignItems": "center", + "alignItems": "flex-start", + "borderBottomColor": "#ddd", + "borderBottomWidth": 0.5, "flexDirection": "row", "paddingHorizontal": 16, - "paddingVertical": 10, + "paddingVertical": 12, }, undefined, ] @@ -327,8 +423,8 @@ exports[`render private group 1`] = ` Object { "backgroundColor": "#FF9800", "borderRadius": 4, - "height": 40, - "width": 40, + "height": 56, + "width": 56, }, undefined, ] @@ -349,7 +445,7 @@ exports[`render private group 1`] = ` "color": "#ffffff", }, Object { - "fontSize": 20, + "fontSize": 28, }, ], Object { @@ -367,44 +463,89 @@ exports[`render private group 1`] = ` style={ Object { "flex": 1, + "height": "100%", "marginLeft": 16, "marginRight": 4, } } > - - private-group - - - Nov 10 - + + private-group + + + Nov 10 + + + + + + + @@ -445,10 +586,12 @@ exports[`render unread +999 1`] = ` style={ Array [ Object { - "alignItems": "center", + "alignItems": "flex-start", + "borderBottomColor": "#ddd", + "borderBottomWidth": 0.5, "flexDirection": "row", "paddingHorizontal": 16, - "paddingVertical": 10, + "paddingVertical": 12, }, undefined, ] @@ -465,8 +608,8 @@ exports[`render unread +999 1`] = ` Object { "backgroundColor": "#3F51B5", "borderRadius": 4, - "height": 40, - "width": 40, + "height": 56, + "width": 56, }, undefined, ] @@ -482,7 +625,7 @@ exports[`render unread +999 1`] = ` "color": "#ffffff", }, Object { - "fontSize": 20, + "fontSize": 28, }, ] } @@ -495,65 +638,112 @@ exports[`render unread +999 1`] = ` style={ Object { "flex": 1, + "height": "100%", "marginLeft": 16, "marginRight": 4, } } > - - name - - - Nov 10 - - - + name + + + Nov 10 + + + - 999+ - + > + + + + + 999+ + + + @@ -592,10 +782,12 @@ exports[`render unread 1`] = ` style={ Array [ Object { - "alignItems": "center", + "alignItems": "flex-start", + "borderBottomColor": "#ddd", + "borderBottomWidth": 0.5, "flexDirection": "row", "paddingHorizontal": 16, - "paddingVertical": 10, + "paddingVertical": 12, }, undefined, ] @@ -612,8 +804,8 @@ exports[`render unread 1`] = ` Object { "backgroundColor": "#3F51B5", "borderRadius": 4, - "height": 40, - "width": 40, + "height": 56, + "width": 56, }, undefined, ] @@ -629,7 +821,7 @@ exports[`render unread 1`] = ` "color": "#ffffff", }, Object { - "fontSize": 20, + "fontSize": 28, }, ] } @@ -642,65 +834,112 @@ exports[`render unread 1`] = ` style={ Object { "flex": 1, + "height": "100%", "marginLeft": 16, "marginRight": 4, } } > - - name - - - Nov 10 - - - + name + + + Nov 10 + + + - 1 - + > + + + + + 1 + + + @@ -739,10 +978,12 @@ exports[`renders correctly 1`] = ` style={ Array [ Object { - "alignItems": "center", + "alignItems": "flex-start", + "borderBottomColor": "#ddd", + "borderBottomWidth": 0.5, "flexDirection": "row", "paddingHorizontal": 16, - "paddingVertical": 10, + "paddingVertical": 12, }, undefined, ] @@ -759,8 +1000,8 @@ exports[`renders correctly 1`] = ` Object { "backgroundColor": "#3F51B5", "borderRadius": 4, - "height": 40, - "width": 40, + "height": 56, + "width": 56, }, undefined, ] @@ -776,7 +1017,7 @@ exports[`renders correctly 1`] = ` "color": "#ffffff", }, Object { - "fontSize": 20, + "fontSize": 28, }, ] } @@ -789,44 +1030,89 @@ exports[`renders correctly 1`] = ` style={ Object { "flex": 1, + "height": "100%", "marginLeft": 16, "marginRight": 4, } } > - - name - - - Nov 10 - + + name + + + Nov 10 + + + + + + + diff --git a/__tests__/__snapshots__/Storyshots.test.js.snap b/__tests__/__snapshots__/Storyshots.test.js.snap index 7a0a3c1b..eb5aadef 100644 --- a/__tests__/__snapshots__/Storyshots.test.js.snap +++ b/__tests__/__snapshots__/Storyshots.test.js.snap @@ -189,10 +189,12 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` style={ Array [ Object { - "alignItems": "center", + "alignItems": "flex-start", + "borderBottomColor": "#ddd", + "borderBottomWidth": 0.5, "flexDirection": "row", "paddingHorizontal": 16, - "paddingVertical": 10, + "paddingVertical": 12, }, undefined, ] @@ -209,8 +211,8 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` Object { "backgroundColor": "#8BC34A", "borderRadius": 4, - "height": 40, - "width": 40, + "height": 56, + "width": 56, }, undefined, ] @@ -226,7 +228,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` "color": "#ffffff", }, Object { - "fontSize": 20, + "fontSize": 28, }, ] } @@ -239,44 +241,89 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` style={ Object { "flex": 1, + "height": "100%", "marginLeft": 16, "marginRight": 4, } } > - - rocket.cat - - - Nov 10 - + + rocket.cat + + + Nov 10 + + + + + + + @@ -311,10 +358,12 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` style={ Array [ Object { - "alignItems": "center", + "alignItems": "flex-start", + "borderBottomColor": "#ddd", + "borderBottomWidth": 0.5, "flexDirection": "row", "paddingHorizontal": 16, - "paddingVertical": 10, + "paddingVertical": 12, }, undefined, ] @@ -331,8 +380,8 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` Object { "backgroundColor": "#8BC34A", "borderRadius": 4, - "height": 40, - "width": 40, + "height": 56, + "width": 56, }, undefined, ] @@ -348,7 +397,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` "color": "#ffffff", }, Object { - "fontSize": 20, + "fontSize": 28, }, ] } @@ -361,46 +410,91 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` style={ Object { "flex": 1, + "height": "100%", "marginLeft": 16, "marginRight": 4, } } > - - rocket.cat - - - Nov 10 - + + rocket.cat + + + Nov 10 + + + + + + + @@ -435,10 +529,12 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` style={ Array [ Object { - "alignItems": "center", + "alignItems": "flex-start", + "borderBottomColor": "#ddd", + "borderBottomWidth": 0.5, "flexDirection": "row", "paddingHorizontal": 16, - "paddingVertical": 10, + "paddingVertical": 12, }, undefined, ] @@ -455,8 +551,8 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` Object { "backgroundColor": "#8BC34A", "borderRadius": 4, - "height": 40, - "width": 40, + "height": 56, + "width": 56, }, undefined, ] @@ -472,7 +568,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` "color": "#ffffff", }, Object { - "fontSize": 20, + "fontSize": 28, }, ] } @@ -485,65 +581,112 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` style={ Object { "flex": 1, + "height": "100%", "marginLeft": 16, "marginRight": 4, } } > - - rocket.cat - - - Nov 10 - - - + rocket.cat + + + Nov 10 + + + - 1 - + > + + + + + 1 + + + - - Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries - - - Nov 10 - - - + Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries + + + Nov 10 + + + - 9 - + > + + + + + 9 + + + - - Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries - - - Nov 10 - - - + Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries + + + Nov 10 + + + - 99 - + > + + + + + 99 + + + - - Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries - - - Nov 10 - - - + Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries + + + Nov 10 + + + - 100 - + > + + + + + 100 + + + - - Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries - - - Nov 10 - - - + Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries + + + Nov 10 + + + - 999+ - + > + + + + + 999+ + + + - - Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries - - - Nov 10 - - - + Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries + + + Nov 10 + + + - @ 999+ - + > + + + + + @ 999+ + + + - - W - - - Nov 10 - + + W + + + Nov 10 + + + + + + + @@ -1411,10 +1846,12 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` style={ Array [ Object { - "alignItems": "center", + "alignItems": "flex-start", + "borderBottomColor": "#ddd", + "borderBottomWidth": 0.5, "flexDirection": "row", "paddingHorizontal": 16, - "paddingVertical": 10, + "paddingVertical": 12, }, undefined, ] @@ -1431,8 +1868,8 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` Object { "backgroundColor": "#9C27B0", "borderRadius": 4, - "height": 40, - "width": 40, + "height": 56, + "width": 56, }, undefined, ] @@ -1448,7 +1885,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` "color": "#ffffff", }, Object { - "fontSize": 20, + "fontSize": 28, }, ] } @@ -1461,44 +1898,89 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` style={ Object { "flex": 1, + "height": "100%", "marginLeft": 16, "marginRight": 4, } } > - - WW - - - Nov 10 - + + WW + + + Nov 10 + + + + + + + @@ -1533,10 +2015,12 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` style={ Array [ Object { - "alignItems": "center", + "alignItems": "flex-start", + "borderBottomColor": "#ddd", + "borderBottomWidth": 0.5, "flexDirection": "row", "paddingHorizontal": 16, - "paddingVertical": 10, + "paddingVertical": 12, }, undefined, ] @@ -1553,8 +2037,8 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` Object { "backgroundColor": undefined, "borderRadius": 4, - "height": 40, - "width": 40, + "height": 56, + "width": 56, }, undefined, ] @@ -1570,7 +2054,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` "color": "#ffffff", }, Object { - "fontSize": 20, + "fontSize": 28, }, ] } @@ -1583,44 +2067,89 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = ` style={ Object { "flex": 1, + "height": "100%", "marginLeft": 16, "marginRight": 4, } } > - - - - - Nov 10 - + + + + + Nov 10 + + + + + + + diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 0e1b1211..b0ab7fea 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -92,7 +92,7 @@ const RocketChat = { reduxStore.dispatch(connectFailure()); }); - // this.ddp.on('connected', () => this.ddp.subscribe('activeUsers', null, false)); + this.ddp.on('connected', () => this.ddp.subscribe('activeUsers', null, false)); this.ddp.on('users', (ddpMessage) => { if (ddpMessage.collection === 'users') { @@ -128,9 +128,6 @@ const RocketChat = { const sub = database.objects('subscriptions').filtered('rid == $0', data._id)[0]; database.write(() => { sub.roomUpdatedAt = data._updatedAt; - if (data.lastMessage) { - // data.lastMessage.url = data.lastMessage.url || []; - } sub.lastMessage = data.lastMessage; sub.ro = data.ro; }); @@ -432,9 +429,6 @@ const RocketChat = { const room = rooms.find(({ _id }) => _id === subscription.rid); if (room) { subscription.roomUpdatedAt = room._updatedAt; - // if (room.lastMessage) { - // room.lastMessage.url = room.lastMessage.url || []; - // } subscription.lastMessage = room.lastMessage; subscription.ro = room.ro; } diff --git a/app/presentation/RoomItem.js b/app/presentation/RoomItem.js index c3b74203..17eb4257 100644 --- a/app/presentation/RoomItem.js +++ b/app/presentation/RoomItem.js @@ -100,6 +100,7 @@ export default class RoomItem extends React.PureComponent { static propTypes = { type: PropTypes.string.isRequired, name: PropTypes.string.isRequired, + StoreLastMessage: PropTypes.bool, _updatedAt: PropTypes.instanceOf(Date), lastMessage: PropTypes.object, favorite: PropTypes.bool, @@ -115,6 +116,18 @@ export default class RoomItem extends React.PureComponent { return ; } + get lastMessage() { + const { + lastMessage + } = this.props; + + if (!this.props.StoreLastMessage) { + return ''; + } + + return lastMessage ? `${ lastMessage.u.username }: ${ emojify(lastMessage.msg, { output: 'unicode' }) }` : 'No Message'; + } + formatDate = date => moment(date).calendar(null, { lastDay: '[Yesterday]', sameDay: 'h:mm A', @@ -124,13 +137,11 @@ export default class RoomItem extends React.PureComponent { render() { const { - favorite, alert, unread, userMentions, name, lastMessage, _updatedAt + favorite, alert, unread, userMentions, name, _updatedAt } = this.props; const date = this.formatDate(_updatedAt); - console.log('do we have a last message?', lastMessage); - let accessibilityLabel = name; if (unread === 1) { accessibilityLabel += `, ${ unread } alert`; @@ -154,11 +165,7 @@ export default class RoomItem extends React.PureComponent { {_updatedAt ? { date } : null} - - - {!this.props.StoreLastMessage ? '' : lastMessage ? `${ lastMessage.u.username }: ${ emojify(lastMessage.msg, { output: 'unicode' }) }` : 'No Message'} - - + {this.lastMessage} {renderNumber(unread, userMentions)} diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index 4d32ca07..c0172d9b 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -90,11 +90,11 @@ export default class RoomView extends React.Component { this.rooms.addListener(this.updateRoom); } - componentWillReceiveProps(nextProps) { - if (this.props.layoutAnimation !== nextProps.layoutAnimation) { - LayoutAnimation.spring(); - } - } + // componentWillReceiveProps(nextProps) { + // // if (this.props.layoutAnimation !== nextProps.layoutAnimation) { + // // LayoutAnimation.spring(); + // // } + // } shouldComponentUpdate(nextProps, nextState) { return !(equal(this.props, nextProps) && equal(this.state, nextState)); } diff --git a/app/views/RoomsListView/index.js b/app/views/RoomsListView/index.js index 7cabb482..a495be77 100644 --- a/app/views/RoomsListView/index.js +++ b/app/views/RoomsListView/index.js @@ -3,7 +3,7 @@ import { ListView } from 'realm/react-native'; import React from 'react'; import PropTypes from 'prop-types'; import Icon from 'react-native-vector-icons/Ionicons'; -import { Platform, View, TextInput, SafeAreaView } from 'react-native'; +import { Platform, View, TextInput, SafeAreaView, LayoutAnimation } from 'react-native'; import { connect } from 'react-redux'; import * as actions from '../../actions'; import * as server from '../../actions/connect'; @@ -69,7 +69,9 @@ export default class RoomsListView extends React.Component { this.search(props.searchText); } } - + componentWillUpdate() { + LayoutAnimation.easeInEaseOut(); + } componentWillUnmount() { this.data.removeAllListeners(); }