diff --git a/app/containers/MessageSeparator.tsx b/app/containers/MessageSeparator.tsx index 90fe044954d..3a07087d270 100644 --- a/app/containers/MessageSeparator.tsx +++ b/app/containers/MessageSeparator.tsx @@ -1,7 +1,7 @@ import { type ReactElement } from 'react'; import { StyleSheet, Text, View } from 'react-native'; -import dayjs from '../lib/dayjs'; +import { formatLongDate } from '../lib/dayjs'; import I18n from '../i18n'; import sharedStyles from '../views/Styles'; import { themes } from '../lib/constants/colors'; @@ -26,6 +26,11 @@ const styles = StyleSheet.create({ }, marginHorizontal: { marginHorizontal: 14 + }, + label: { + paddingHorizontal: 8, + paddingVertical: 2, + borderRadius: 16 } }); @@ -36,9 +41,11 @@ const MessageSeparator = ({ ts, unread }: { ts?: Date | string | null; unread?: return null; } - const date = ts ? dayjs(ts).format('LL') : null; + const date = ts ? formatLongDate(ts) : null; const unreadLine = { backgroundColor: themes[theme].buttonBackgroundDangerDefault }; const unreadText = { color: themes[theme].fontDanger }; + const lineBackground = { backgroundColor: themes[theme].strokeLight }; + if (ts && unread) { return ( @@ -51,9 +58,12 @@ const MessageSeparator = ({ ts, unread }: { ts?: Date | string | null; unread?: if (ts) { return ( - - {date} - + + + {date} + + ); } diff --git a/app/containers/message/components/__tests__/__snapshots__/Message.test.tsx.snap b/app/containers/message/components/__tests__/__snapshots__/Message.test.tsx.snap index 674d94dd4b5..5aa8b20583e 100644 --- a/app/containers/message/components/__tests__/__snapshots__/Message.test.tsx.snap +++ b/app/containers/message/components/__tests__/__snapshots__/Message.test.tsx.snap @@ -22711,7 +22711,7 @@ exports[`Story Snapshots: DateAndUnreadSeparators should match snapshot 1`] = ` ] } > - November 10, 2017 + November 10th, 2017 - - November 10, 2017 - + + November 10th, 2017 + + - November 10, 2017 + November 10th, 2017 - - November 10, 2017 - + + November 10th, 2017 + + { + const date = dayjs(ts); + return ORDINAL_DAY_LOCALES.includes(date.locale()) ? date.format('MMMM Do, YYYY') : date.format('LL'); +}; // WatermelonDB hands a message `ts` back as Date, ms number, or ISO string depending on the read path; // dayjs parses all three where Number(ts) / new Date(ts) each NaN on one. Normalize to ms since epoch.