Fix: Avoid unnecessary upsertTags API calls on conversation changes.

refactor: rename `LibreDesk` -> `Libredesk`
This commit is contained in:
Abhinav Raut
2025-02-12 03:17:47 +05:30
parent bb4c161540
commit 7efe811e52
11 changed files with 38 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
# LibreDesk frontend
# Libredesk frontend
This template should help get you started developing with Vue 3 in Vite.

View File

@@ -17,9 +17,10 @@
<div class="flex flex-col gap-1 mb-5">
<p class="font-medium">Initiated at</p>
<Skeleton v-if="conversationStore.conversation.loading" class="w-32 h-4" />
<p v-else>
<p v-if="conversation.created_at">
{{ format(conversation.created_at, 'PPpp') }}
</p>
<p v-else>-</p>
</div>
<div class="flex flex-col gap-1 mb-5">

View File

@@ -115,6 +115,7 @@
</ComboBox>
<SelectTag
v-if="conversationStore.current"
v-model="conversationStore.current.tags"
:items="tags"
placeholder="Select tags"
@@ -138,8 +139,8 @@
<AccordionContent class="p-4">
<div
v-if="
conversationStore.current.previous_conversations.length === 0 ||
conversationStore.conversation.loading
conversationStore.current?.previous_conversations?.length === 0 ||
conversationStore.conversation?.loading
"
class="text-center text-sm text-muted-foreground py-4"
>
@@ -206,15 +207,35 @@ const conversationStore = useConversationStore()
const usersStore = useUsersStore()
const teamsStore = useTeamStore()
const tags = ref([])
let isConversationChange = false
// Watch for changes in the current conversation and set the flag
watch(
() => conversationStore.current,
(newConversation, oldConversation) => {
// Set the flag when the conversation changes
if (newConversation?.uuid !== oldConversation?.uuid) {
isConversationChange = true
}
},
{ immediate: true }
)
onMounted(async () => {
await fetchTags()
})
// Watch for changes in the tags and upsert the tags
watch(
() => conversationStore.current?.tags,
(newTags, oldTags) => {
// Check if the tags are the same.
// Skip if the tags change is due to a conversation change.
if (isConversationChange) {
isConversationChange = false
return
}
// Skip if the tags are the same (deep comparison)
if (
Array.isArray(newTags) &&
Array.isArray(oldTags) &&

View File

@@ -31,7 +31,7 @@
<Skeleton class="w-32 h-4" />
</span>
<span v-else>
{{ conversation.contact.email }}
{{ conversation?.contact?.email }}
</span>
</p>
<p class="text-sm text-muted-foreground flex gap-2 mt-1">

View File

@@ -437,7 +437,7 @@ const router = createRouter({
})
router.beforeEach((to, from, next) => {
document.title = to.meta.title + ' - LibreDesk'
document.title = to.meta.title + ' - Libredesk'
next()
})

View File

@@ -185,6 +185,7 @@ export const useConversationStore = defineStore('conversation', () => {
const conversationsList = computed(() => {
if (!conversations.data) return []
// Sort conversations based on the selected sort field
return [...conversations.data].sort((a, b) => {
const field = sortFieldMap[conversations.sortField]?.field
if (!a[field] && !b[field]) return 0
@@ -223,7 +224,7 @@ export const useConversationStore = defineStore('conversation', () => {
}
const current = computed(() => {
return conversation.data
return conversation.data || {}
})
const currentBCC = computed(() => {

View File

@@ -1,7 +1,7 @@
<template>
<div class="min-h-screen flex flex-col bg-background">
<header class="p-6">
<h1 class="text-2xl font-bold text-foreground">LibreDesk</h1>
<h1 class="text-2xl font-bold text-foreground">Libredesk</h1>
</header>
<main class="flex-1 flex items-center justify-center p-4">
@@ -13,7 +13,7 @@
>
<CardContent class="p-8 space-y-6">
<div class="space-y-2 text-center">
<CardTitle class="text-3xl font-bold text-foreground">LibreDesk</CardTitle>
<CardTitle class="text-3xl font-bold text-foreground">Libredesk</CardTitle>
<p class="text-muted-foreground">Sign in to your account</p>
</div>

View File

@@ -1,7 +1,7 @@
<template>
<div class="min-h-screen flex flex-col bg-background">
<header class="p-6">
<h1 class="text-2xl font-bold text-foreground">LibreDesk</h1>
<h1 class="text-2xl font-bold text-foreground">Libredesk</h1>
</header>
<main class="flex-1 flex items-center justify-center p-4">

View File

@@ -1,7 +1,7 @@
<template>
<div class="min-h-screen flex flex-col bg-background">
<header class="p-6">
<h1 class="text-2xl font-bold text-foreground">LibreDesk</h1>
<h1 class="text-2xl font-bold text-foreground">Libredesk</h1>
</header>
<main class="flex-1 flex items-center justify-center p-4">

View File

@@ -485,7 +485,7 @@ VALUES
('app.lang', '"en"'::jsonb),
('app.root_url', '"http://localhost:9000"'::jsonb),
('app.logo_url', '"http://localhost:9000/logo.png"'::jsonb),
('app.site_name', '"LibreDesk"'::jsonb),
('app.site_name', '"Libredesk"'::jsonb),
('app.favicon_url', '"http://localhost:9000/favicon.ico"'::jsonb),
('app.max_file_upload_size', '20'::jsonb),
('app.allowed_file_upload_extensions', '["*"]'::jsonb),
@@ -557,5 +557,5 @@ VALUES('email_notification'::public."template_type", '<p>Hello {{ .agent.full_na
<div >
Best regards,<br>
LibreDesk
Libredesk
</div>', false, 'Conversation assigned', 'New conversation assigned to you', true);

View File

@@ -31,7 +31,7 @@
{{ define "footer" }}
</div>
<footer class="container">
Powered by <a target="_blank" rel="noreferrer" href="https://libredesk.io/">LibreDesk</a>
Powered by <a target="_blank" rel="noreferrer" href="https://libredesk.io/">Libredesk</a>
</footer>
</body>
</html>