Skip to content

Commit

Permalink
Revert "[PAY-3593] Revert "[PAY-3592] Always mark chat as read (temp … (
Browse files Browse the repository at this point in the history
  • Loading branch information
dharit-tan authored Jan 16, 2025
1 parent 4c04c6d commit 8bf5600
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions packages/common/src/store/pages/chat/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,21 +547,10 @@ function* doMarkChatAsRead(action: ReturnType<typeof markChatAsRead>) {
// Use non-optimistic chat here so that the calculation of whether to mark
// the chat as read or not are consistent with values in backend
const chat = yield* select((state) => getNonOptimisticChat(state, chatId))
if (chat?.is_blast) {
return
}
if (
!chat ||
!chat?.last_read_at ||
dayjs(chat?.last_read_at).isBefore(chat?.last_message_at)
) {
yield* call([sdk.chats, sdk.chats.read], { chatId })
yield* put(markChatAsReadSucceeded({ chatId }))
} else {
// Mark the write as 'failed' in this case (just means we already marked this as read somehow)
// to delete the optimistic read status
yield* put(markChatAsReadFailed({ chatId }))
}
if (chat?.is_blast) return

yield* call([sdk.chats, sdk.chats.read], { chatId })
yield* put(markChatAsReadSucceeded({ chatId }))
} catch (e) {
yield* put(markChatAsReadFailed({ chatId }))
const reportToSentry = yield* getContext('reportToSentry')
Expand Down

0 comments on commit 8bf5600

Please sign in to comment.