From 139b7d1ac3dcca8703df29f9952edb7d3c8b3b8d Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 16 Jul 2019 19:23:11 -0700 Subject: [PATCH] unread: Move a UI-specific helper to the appropriate bit of UI. This is basically part of the UI logic; it's a choice for how to represent this information visually. Move it to the relevant spot of our UI code. Then as a bonus, inline it and use that to simplify the logic. --- src/common/UnreadCount.js | 4 ++-- src/utils/unread.js | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/common/UnreadCount.js b/src/common/UnreadCount.js index 101b22de35e..52226e62900 100644 --- a/src/common/UnreadCount.js +++ b/src/common/UnreadCount.js @@ -4,7 +4,6 @@ import { StyleSheet, Text, View } from 'react-native'; import type { ViewStyleProp } from 'react-native/Libraries/StyleSheet/StyleSheet'; import { BRAND_COLOR } from '../styles'; -import { unreadToLimitedCount } from '../utils/unread'; import { foregroundColorFromBackground } from '../utils/color'; const styles = StyleSheet.create({ @@ -83,10 +82,11 @@ export default class UnreadCount extends PureComponent { const textColor = foregroundColorFromBackground(color); const textStyle = [styles.text, inverse && styles.textInverse, { color: textColor }]; + const countString = limited && count >= 100 ? '99+' : count.toString(); return ( - {limited ? unreadToLimitedCount(count) : count} + {countString} ); diff --git a/src/utils/unread.js b/src/utils/unread.js index 018cf0ed27e..d794ae2729d 100644 --- a/src/utils/unread.js +++ b/src/utils/unread.js @@ -15,6 +15,3 @@ export const filterUnreadMessagesInRange = ( .filter(msg => msg.id >= fromId && msg.id <= toId); return filterUnreadMessageIds(messagesInRange.map(x => x.id), flags); }; - -export const unreadToLimitedCount = (count: number): string => - count < 100 ? count.toString() : '99+';