Skip to content

Commit beb5127

Browse files
committed
fix: fix bug with no refreshing date in chat on visibillity event
1 parent 44cb19b commit beb5127

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/components/Chat/Chat.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<free-tokens-dialog v-model="isShowFreeTokensDialog" />
44
<a-chat
55
ref="chatRef"
6+
:key="dateRefreshKey"
67
:messages="messages"
78
:show-new-chat-placeholder="showNewChatPlaceholder"
89
:partners="partners"
@@ -333,6 +334,9 @@ const showSpinner = useChatsSpinner()
333334
334335
const isMenuOpen = ref(false)
335336
337+
// Key for forcing date refresh when app becomes visible after being in background
338+
const dateRefreshKey = ref(0)
339+
336340
const attachments = useAttachments(props.partnerId)()
337341
const handleAttachments = (files: FileData[]) => {
338342
const maxFileSizeExceeded = files.some(({ file }) => file.size >= UPLOAD_MAX_FILE_SIZE)
@@ -521,7 +525,16 @@ onMounted(async () => {
521525
isScrolledToBottom.value = chatRef.value.isScrolledToBottom()
522526
})
523527
visibilityId.value = Visibility.change((event, state) => {
524-
if (state === 'visible' && isScrolledToBottom.value) markAsRead()
528+
if (state === 'visible') {
529+
// Force refresh dates when returning to visible state
530+
dateRefreshKey.value = Date.now()
531+
532+
nextTick(() => {
533+
chatRef.value?.maintainScrollPosition()
534+
})
535+
536+
if (isScrolledToBottom.value) markAsRead()
537+
}
525538
})
526539
527540
const draftMessage = store.getters['draftMessage/draftReplyTold'](props.partnerId)

0 commit comments

Comments
 (0)