From 347034770840c6e2eaae6a10e01ff7fbec2f0cea Mon Sep 17 00:00:00 2001 From: Abhinav Raut Date: Thu, 14 May 2026 21:17:17 +0530 Subject: [PATCH] Throttle conversation list refresh and keep list on fetch errors --- frontend/apps/main/src/stores/conversation.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/apps/main/src/stores/conversation.js b/frontend/apps/main/src/stores/conversation.js index 1aabd778..4a091181 100644 --- a/frontend/apps/main/src/stores/conversation.js +++ b/frontend/apps/main/src/stores/conversation.js @@ -10,8 +10,8 @@ import { subscribeToConversation, sendTypingIndicator } from '@main/websocket' import { playNotificationSound } from '@shared-ui/composables/useNotificationSound' import MessageCache from '../utils/conversation-message-cache' import { getI18n } from '../i18n' -import { useDebounceFn } from '@vueuse/core' import { CONVERSATION_LIST_TYPE, CONVERSATION_DEFAULT_STATUSES, TAG_ACTION } from '@/constants/conversation' +import { useDebounceFn, useThrottleFn } from '@vueuse/core' import api from '../api' export const useConversationStore = defineStore('conversation', () => { @@ -488,8 +488,11 @@ export const useConversationStore = defineStore('conversation', () => { const response = await makeConversationListRequest(listType, teamID, viewID, filters, page) processConversationListResponse(response) } catch (error) { - conversations.errorMessage = handleHTTPError(error).message - conversations.total = 0 + // If list already exists, do not tear it down on errors. + if (conversations.data.length === 0) { + conversations.errorMessage = handleHTTPError(error).message + conversations.total = 0 + } } finally { conversations.loading = false } @@ -704,12 +707,11 @@ export const useConversationStore = defineStore('conversation', () => { pendingNotificationUUIDs.add(uuid) } - // Debounced to prevent apis calls during many WS events in a short time. - const debouncedFetchFirstPage = useDebounceFn(fetchFirstPageConversations, 1000) + const throttledFetchFirstPage = useThrottleFn(fetchFirstPageConversations, 2000) const debouncedFetchParticipants = useDebounceFn(fetchParticipants, 400) function refreshConversationList () { - debouncedFetchFirstPage() + throttledFetchFirstPage() } function updateConversationLastMessage (uuid, message) {