@@ -114,9 +114,9 @@ function ReportActionsList({
114
114
const readActionSkipped = useRef ( false ) ;
115
115
const reportActionSize = useRef ( sortedReportActions . length ) ;
116
116
117
- // Considering that renderItem is enclosed within a useCallback, marking it as "read" twice will retain the value as "true," preventing the useCallback from re-executing.
118
- // However, if we create and listen to an object, it will lead to a new useCallback execution.
119
- const [ messageManuallyMarked , setMessageManuallyMarked ] = useState ( { read : false } ) ;
117
+ // This state is used to force a re-render when the user manually marks a message as unread
118
+ // by using a timestamp you can force re-renders without having to worry about if another message was marked as unread before
119
+ const [ messageManuallyMarkedUnread , setMessageManuallyMarkedUnread ] = useState ( 0 ) ;
120
120
const [ isFloatingMessageCounterVisible , setIsFloatingMessageCounterVisible ] = useState ( false ) ;
121
121
const animatedStyles = useAnimatedStyle ( ( ) => ( {
122
122
opacity : opacity . value ,
@@ -163,15 +163,14 @@ function ReportActionsList({
163
163
164
164
useEffect ( ( ) => {
165
165
const didManuallyMarkReportAsUnread = report . lastReadTime < DateUtils . getDBTime ( ) && ReportUtils . isUnread ( report ) ;
166
- if ( ! didManuallyMarkReportAsUnread ) {
167
- setMessageManuallyMarked ( { read : false } ) ;
168
- return ;
166
+ if ( didManuallyMarkReportAsUnread ) {
167
+ // Clearing the current unread marker so that it can be recalculated
168
+ currentUnreadMarker . current = null ;
169
+ setMessageManuallyMarkedUnread ( new Date ( ) . getTime ( ) ) ;
170
+ } else {
171
+ setMessageManuallyMarkedUnread ( 0 ) ;
169
172
}
170
173
171
- // Clearing the current unread marker so that it can be recalculated
172
- currentUnreadMarker . current = null ;
173
- setMessageManuallyMarked ( { read : true } ) ;
174
-
175
174
// We only care when a new lastReadTime is set in the report
176
175
// eslint-disable-next-line react-hooks/exhaustive-deps
177
176
} , [ report . lastReadTime ] ) ;
@@ -230,7 +229,7 @@ function ReportActionsList({
230
229
const isCurrentMessageUnread = isMessageUnread ( reportAction , report . lastReadTime ) ;
231
230
shouldDisplayNewMarker = isCurrentMessageUnread && ! isMessageUnread ( nextMessage , report . lastReadTime ) ;
232
231
233
- if ( ! messageManuallyMarked . read ) {
232
+ if ( ! messageManuallyMarkedUnread ) {
234
233
shouldDisplayNewMarker = shouldDisplayNewMarker && reportAction . actorAccountID !== Report . getCurrentUserAccountID ( ) ;
235
234
}
236
235
const canDisplayMarker = scrollingVerticalOffset . current < MSG_VISIBLE_THRESHOLD ? reportAction . created < userActiveSince . current : true ;
@@ -272,7 +271,7 @@ function ReportActionsList({
272
271
/>
273
272
) ;
274
273
} ,
275
- [ report , hasOutstandingIOU , sortedReportActions , mostRecentIOUReportActionID , messageManuallyMarked ] ,
274
+ [ report , hasOutstandingIOU , sortedReportActions , mostRecentIOUReportActionID , messageManuallyMarkedUnread ] ,
276
275
) ;
277
276
278
277
// Native mobile does not render updates flatlist the changes even though component did update called.
0 commit comments