diff --git a/frontend/apps/main/src/App.vue b/frontend/apps/main/src/App.vue index fa977eca..37814b4b 100644 --- a/frontend/apps/main/src/App.vue +++ b/frontend/apps/main/src/App.vue @@ -197,7 +197,8 @@ watch( if (path.startsWith('/inboxes') && path !== '/inboxes/search') { lastInboxPath.value = path } - } + }, + { immediate: true } ) const userStore = useUserStore() const conversationStore = useConversationStore() diff --git a/frontend/apps/main/src/stores/aiPrompt.js b/frontend/apps/main/src/stores/aiPrompt.js index c88c55dd..2725972c 100644 --- a/frontend/apps/main/src/stores/aiPrompt.js +++ b/frontend/apps/main/src/stores/aiPrompt.js @@ -9,22 +9,18 @@ export const useAiPromptStore = defineStore('aiPrompt', () => { const prompts = ref([]) const emitter = useEmitter() let inflight = null - const fetchPrompts = async () => { - if (prompts.value.length) return + const fetchPrompts = () => { + if (prompts.value.length) return Promise.resolve() if (inflight) return inflight - inflight = (async () => { - try { - const response = await api.getAiPrompts() - prompts.value = response?.data?.data || [] - } catch (error) { + inflight = api.getAiPrompts() + .then(response => { prompts.value = response?.data?.data || [] }) + .catch(error => { emitter.emit(EMITTER_EVENTS.SHOW_TOAST, { variant: 'destructive', description: handleHTTPError(error).message }) - } finally { - inflight = null - } - })() + }) + .finally(() => { inflight = null }) return inflight } return { diff --git a/frontend/apps/main/src/stores/conversation.js b/frontend/apps/main/src/stores/conversation.js index 44df8088..1b2904a4 100644 --- a/frontend/apps/main/src/stores/conversation.js +++ b/frontend/apps/main/src/stores/conversation.js @@ -1,5 +1,6 @@ import { defineStore } from 'pinia' import { computed, reactive, ref, watchEffect } from 'vue' +import { useRouter } from 'vue-router' import { handleHTTPError } from '@shared-ui/utils/http.js' import { TYPING_RECEIVE_TIMEOUT } from '@shared-ui/composables/useTypingIndicator.js' import { deepMerge } from '@shared-ui/utils/object.js' @@ -27,6 +28,8 @@ export const useConversationStore = defineStore('conversation', () => { const macros = ref({}) const drafts = ref(new Map()) const userStore = useUserStore() + const router = useRouter() + const isViewingConversation = (uuid) => router.currentRoute.value.params.uuid === uuid const selectedUUIDs = ref(new Set()) @@ -763,6 +766,7 @@ export const useConversationStore = defineStore('conversation', () => { } async function updateAssigneeLastSeen (uuid) { + if (!isViewingConversation(uuid)) return markConversationAsRead(uuid) api.updateAssigneeLastSeen(uuid).catch(() => { }) } diff --git a/frontend/apps/main/src/stores/customAttributes.js b/frontend/apps/main/src/stores/customAttributes.js index 43174be8..82ec8450 100644 --- a/frontend/apps/main/src/stores/customAttributes.js +++ b/frontend/apps/main/src/stores/customAttributes.js @@ -27,22 +27,18 @@ export const useCustomAttributeStore = defineStore('customAttributes', () => { })) }) let inflight = null - const fetchCustomAttributes = async () => { - if (attributes.value.length) return + const fetchCustomAttributes = () => { + if (attributes.value.length) return Promise.resolve() if (inflight) return inflight - inflight = (async () => { - try { - const response = await api.getCustomAttributes() - attributes.value = response?.data?.data || [] - } catch (error) { + inflight = api.getCustomAttributes() + .then(response => { attributes.value = response?.data?.data || [] }) + .catch(error => { emitter.emit(EMITTER_EVENTS.SHOW_TOAST, { variant: 'destructive', description: handleHTTPError(error).message }) - } finally { - inflight = null - } - })() + }) + .finally(() => { inflight = null }) return inflight } return {