Skip to content

Commit

Permalink
Minor refactoring for MessageList (#1043)
Browse files Browse the repository at this point in the history
Minor refactoring of MessageList
  • Loading branch information
borisyankov committed Aug 15, 2017
1 parent adcd1ea commit 8c126f1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 23 deletions.
10 changes: 9 additions & 1 deletion src/message/MessageContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ import MessageFull from './MessageFull';
import MessageBrief from './MessageBrief';
import { isUrlInAppLink, getFullUrl, getMessageIdFromLink, getNarrowFromLink } from '../utils/url';
import openLink from '../utils/openLink';
import { getAuth, getUsers, getFlags, getSubscriptions, getCurrentRoute } from '../selectors';
import {
getAuth,
getUsers,
getFlags,
getSubscriptions,
getCurrentRoute,
getActiveNarrow,
} from '../selectors';
import boundActions from '../boundActions';
import { constructActionButtons, executeActionSheetAction } from './messageActionSheet';
import type { ShowActionSheetTypes } from './messageActionSheet';
Expand Down Expand Up @@ -110,6 +117,7 @@ class MessageContainer extends PureComponent {
export default connect(
state => ({
auth: getAuth(state),
narrow: getActiveNarrow(state),
currentRoute: getCurrentRoute(state),
users: getUsers(state),
flags: getFlags(state),
Expand Down
10 changes: 1 addition & 9 deletions src/message/MessageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,19 @@ type Props = {
narrow: Narrow,
};

class MessageList extends PureComponent {
export default class MessageList extends PureComponent {
props: Props;

static contextTypes = {
styles: () => null,
};

state: {
actionSheetButtons: [string, string],
};

autoScrollToBottom = false;

static defaultProps = {
onScroll: nullFunction,
};

state = { actionSheetButtons: ['', ''] };

componentWillReceiveProps(nextProps: Props) {
this.autoScrollToBottom = this.props.caughtUpNewer && nextProps.caughtUpNewer;
}
Expand Down Expand Up @@ -101,5 +95,3 @@ class MessageList extends PureComponent {
);
}
}

export default MessageList;
6 changes: 0 additions & 6 deletions src/message/MessageListFlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,12 @@ class MessageList extends PureComponent {
styles: () => null,
};

state: {
actionSheetButtons: [string, string],
};

autoScrollToBottom = false;

static defaultProps = {
onScroll: nullFunction,
};

state = { actionSheetButtons: ['', ''] };

componentWillReceiveProps(nextProps) {
this.autoScrollToBottom = this.props.caughtUpNewer && nextProps.caughtUpNewer;
}
Expand Down
4 changes: 1 addition & 3 deletions src/message/headers/MessageHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const styles = StyleSheet.create({
},
});

class MessageHeader extends PureComponent {
export default class MessageHeader extends PureComponent {
props: {
auth: Auth,
actions: Actions,
Expand Down Expand Up @@ -111,5 +111,3 @@ class MessageHeader extends PureComponent {
return null;
}
}

export default MessageHeader;
3 changes: 2 additions & 1 deletion src/message/headers/MessageHeaderContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { connectActionSheet } from '@expo/react-native-action-sheet';

import MessageHeader from './MessageHeader';
import boundActions from '../../boundActions';
import { getAuth, getSubscriptions } from '../../selectors';
import { getAuth, getActiveNarrow, getSubscriptions } from '../../selectors';

export default connect(
state => ({
auth: getAuth(state),
narrow: getActiveNarrow(state),
subscriptions: getSubscriptions(state),
mute: state.mute,
}),
Expand Down
3 changes: 0 additions & 3 deletions src/message/renderMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export default ({ messages, narrow }: Props) => {
}
: item
}
narrow={narrow}
/>,
);
}
Expand All @@ -67,7 +66,6 @@ export default ({ messages, narrow }: Props) => {
key={item.timestamp}
isBrief={shouldGroupWithPrev}
message={item}
narrow={narrow}
/>,
);
prevItem = item;
Expand All @@ -80,7 +78,6 @@ export default ({ messages, narrow }: Props) => {
key={item.id}
isBrief={shouldGroupWithPrev}
message={item}
narrow={narrow}
/>,
);

Expand Down

0 comments on commit 8c126f1

Please sign in to comment.