diff --git a/app/lib/methods/helpers/mergeSubscriptionsRooms.js b/app/lib/methods/helpers/mergeSubscriptionsRooms.js index 310d8a3bf..024a246d6 100644 --- a/app/lib/methods/helpers/mergeSubscriptionsRooms.js +++ b/app/lib/methods/helpers/mergeSubscriptionsRooms.js @@ -15,11 +15,9 @@ export const merge = (subscription, room) => { if (room) { if (room._updatedAt) { subscription.lastMessage = normalizeMessage(room.lastMessage); - if (subscription.lastMessage) { - subscription.roomUpdatedAt = subscription.lastMessage.ts; - } else { - subscription.roomUpdatedAt = room._updatedAt; - } + const updatedAt = room?._updatedAt ? new Date(room._updatedAt) : null; + const lastMessageTs = subscription?.lastMessage?.ts ? new Date(subscription.lastMessage.ts) : null; + subscription.roomUpdatedAt = Math.max(updatedAt, lastMessageTs); subscription.description = room.description; subscription.topic = room.topic; subscription.announcement = room.announcement; diff --git a/app/presentation/RoomItem/RoomItem.js b/app/presentation/RoomItem/RoomItem.js index 8d9d0eba9..13b2fdd27 100644 --- a/app/presentation/RoomItem/RoomItem.js +++ b/app/presentation/RoomItem/RoomItem.js @@ -39,7 +39,6 @@ const RoomItem = ({ tunread, tunreadUser, tunreadGroup, - roomUpdatedAt, testID, swipeEnabled, onPress, @@ -88,7 +87,6 @@ const RoomItem = ({ alert={alert} /> { - if (!roomUpdatedAt) { + if (!date) { return null; } return ( @@ -39,7 +39,6 @@ const UpdatedAt = React.memo(({ }); UpdatedAt.propTypes = { - roomUpdatedAt: PropTypes.instanceOf(Date), date: PropTypes.string, theme: PropTypes.string, hideUnreadStatus: PropTypes.bool, diff --git a/app/presentation/RoomItem/index.js b/app/presentation/RoomItem/index.js index d38c1f687..eb61a060f 100644 --- a/app/presentation/RoomItem/index.js +++ b/app/presentation/RoomItem/index.js @@ -136,7 +136,7 @@ class RoomItemContainer extends React.Component { const name = getRoomTitle(item); const avatar = getRoomAvatar(item); const isRead = getIsRead(item); - const date = item.lastMessage?.ts && formatDate(item.lastMessage.ts); + const date = item.roomUpdatedAt && formatDate(item.roomUpdatedAt); const alert = (item.alert || item.tunread?.length); let accessibilityLabel = name; @@ -178,7 +178,6 @@ class RoomItemContainer extends React.Component { status={status} hideUnreadStatus={item.hideUnreadStatus} alert={alert} - roomUpdatedAt={item.roomUpdatedAt} lastMessage={item.lastMessage} showLastMessage={showLastMessage} username={username} diff --git a/storybook/stories/RoomItem.js b/storybook/stories/RoomItem.js index 293ec8a6a..2a5d09917 100644 --- a/storybook/stories/RoomItem.js +++ b/storybook/stories/RoomItem.js @@ -17,8 +17,7 @@ const lastMessage = { msg: longText }; const updatedAt = { - date: '10:00', - roomUpdatedAt: new Date('2020-01-01') + date: '10:00' }; const RoomItem = props => (