From 97ae7c641bfa076189fbca748d64bf2102f070a8 Mon Sep 17 00:00:00 2001 From: Mehdi Achour Date: Tue, 7 Nov 2017 21:00:02 +0100 Subject: [PATCH] refactor: use an enum for subject types --- .../notification-list-item.component.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/notification-list-item.component.js b/src/components/notification-list-item.component.js index c01f9f0aa..9dfc975cc 100644 --- a/src/components/notification-list-item.component.js +++ b/src/components/notification-list-item.component.js @@ -54,20 +54,27 @@ const IconStyled = styled(Icon).attrs({ type: 'octicon', })``; +const SubjectType = { + commit: 'Commit', + pull: 'PullRequest', +}; + export class NotificationListItem extends Component { props: Props; getComponentType = () => { const { notification } = this.props; - return notification.subject.type === 'Commit' ? View : TouchableOpacity; + return notification.subject.type === SubjectType.commit + ? View + : TouchableOpacity; }; getIconName = type => { switch (type) { - case 'Commit': + case SubjectType.commit: return 'git-commit'; - case 'PullRequest': + case SubjectType.pull: return 'git-pull-request'; default: return 'issue-opened'; @@ -77,7 +84,7 @@ export class NotificationListItem extends Component { getTitleComponentProps = () => { const { notification, navigationAction } = this.props; - return notification.subject.type === 'Commit' + return notification.subject.type === SubjectType.commit ? {} : { onPress: () => navigationAction(notification),