chore: Minor fix
This commit is contained in:
+12
-8
@@ -1,6 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, computed, watch, nextTick } from 'vue';
|
||||
import { useDocumentVisibility } from '@vueuse/core';
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { debounce } from '@chatwoot/utils';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ARTICLE_EDITOR_MENU_OPTIONS } from 'dashboard/constants/editor';
|
||||
@@ -24,6 +23,10 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
refreshTick: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits([
|
||||
@@ -36,7 +39,6 @@ const emit = defineEmits([
|
||||
]);
|
||||
|
||||
const { t } = useI18n();
|
||||
const visibility = useDocumentVisibility();
|
||||
|
||||
const isNewArticle = computed(() => !props.article?.id);
|
||||
|
||||
@@ -56,12 +58,14 @@ watch(
|
||||
}
|
||||
);
|
||||
|
||||
// Sync local state when user returns to tab (fresh data from re-fetch)
|
||||
watch(visibility, state => {
|
||||
if (state === 'visible') {
|
||||
nextTick(syncLocalState);
|
||||
// Parent increments refreshTick after article re-fetch completes.
|
||||
// Syncing on this signal avoids visibility/fetch timing races.
|
||||
watch(
|
||||
() => props.refreshTick,
|
||||
() => {
|
||||
syncLocalState();
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
const debouncedSave = debounce(value => emit('saveArticle', value), 500, false);
|
||||
|
||||
|
||||
+5
-2
@@ -28,6 +28,7 @@ const portal = computed(() => portalBySlug.value(portalSlug));
|
||||
|
||||
const isUpdating = ref(false);
|
||||
const isSaved = ref(false);
|
||||
const refreshTick = ref(0);
|
||||
|
||||
const articleLink = computed(() => {
|
||||
const { slug: categorySlug, locale: categoryLocale } = article.value.category;
|
||||
@@ -86,11 +87,12 @@ const goBackToArticles = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const fetchArticleDetails = () => {
|
||||
store.dispatch('articles/show', {
|
||||
const fetchArticleDetails = async () => {
|
||||
await store.dispatch('articles/show', {
|
||||
id: articleSlug,
|
||||
portalSlug,
|
||||
});
|
||||
refreshTick.value += 1;
|
||||
};
|
||||
|
||||
const previewArticle = () => {
|
||||
@@ -113,6 +115,7 @@ onMounted(fetchArticleDetails);
|
||||
:article="article"
|
||||
:is-updating="isUpdating"
|
||||
:is-saved="isSaved"
|
||||
:refresh-tick="refreshTick"
|
||||
@save-article="saveArticle"
|
||||
@preview-article="previewArticle"
|
||||
@go-back="goBackToArticles"
|
||||
|
||||
Reference in New Issue
Block a user