chore: sync article content on tab visibility change
This commit is contained in:
+8
-1
@@ -1,5 +1,6 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { ref, computed, onMounted, watch } from 'vue';
|
||||
import { useDocumentVisibility } from '@vueuse/core';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useAlert, useTrack } from 'dashboard/composables';
|
||||
@@ -13,6 +14,7 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
const store = useStore();
|
||||
const { t } = useI18n();
|
||||
const visibility = useDocumentVisibility();
|
||||
|
||||
const { articleSlug, portalSlug } = route.params;
|
||||
|
||||
@@ -98,6 +100,11 @@ const previewArticle = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// Re-fetch article when user returns to this tab
|
||||
watch(visibility, state => {
|
||||
if (state === 'visible') fetchArticleDetails();
|
||||
});
|
||||
|
||||
onMounted(fetchArticleDetails);
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user