Skip to content

Commit

Permalink
fix: mark conversation as read when messages are already cached
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavxd committed Feb 26, 2025
1 parent 44723fb commit 7160136
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frontend/src/stores/conversation.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,10 @@ export const useConversationStore = defineStore('conversation', () => {
async function fetchMessages (uuid, fetchNextPage = false) {
// Messages are already cached?
let hasMessages = messages.data.getAllPagesMessages(uuid)
if (hasMessages.length > 0 && !fetchNextPage)
if (hasMessages.length > 0 && !fetchNextPage) {
markConversationAsRead(uuid)
return
}

// Fetch messages from server.
messages.loading = true
Expand All @@ -293,7 +295,6 @@ export const useConversationStore = defineStore('conversation', () => {
const response = await api.getConversationMessages(uuid, { page: page, page_size: MESSAGE_LIST_PAGE_SIZE })
const result = response.data?.data || {}
const newMessages = result.results || []
// Mark conversation as read
markConversationAsRead(uuid)
// Cache messages
messages.data.addMessages(uuid, newMessages, result.page, result.total_pages)
Expand Down

0 comments on commit 7160136

Please sign in to comment.