diff --git a/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticleEditorPage/ArticleEditor.vue b/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticleEditorPage/ArticleEditor.vue index f5b925fbe..1709d0f5f 100644 --- a/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticleEditorPage/ArticleEditor.vue +++ b/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticleEditorPage/ArticleEditor.vue @@ -36,6 +36,8 @@ const emit = defineEmits([ const { t } = useI18n(); +const isNewArticle = computed(() => !props.article?.id); + const saveAndSync = value => { emit('saveArticle', value); }; @@ -52,21 +54,32 @@ const quickSave = debounce( // 2.5 seconds is enough to know that the user has stopped typing and is taking a pause // so we can save the data to the backend and retrieve the updated data // this will update the local state with response data +// Only use to save for existing articles const saveAndSyncDebounced = debounce(saveAndSync, 2500, false); +// Debounced save for new articles +const quickSaveNewArticle = debounce(saveAndSync, 400, false); + +const handleSave = value => { + if (isNewArticle.value) { + quickSaveNewArticle(value); + } else { + quickSave(value); + saveAndSyncDebounced(value); + } +}; + const articleTitle = computed({ get: () => props.article.title, set: value => { - quickSave({ title: value }); - saveAndSyncDebounced({ title: value }); + handleSave({ title: value }); }, }); const articleContent = computed({ get: () => props.article.content, set: content => { - quickSave({ content }); - saveAndSyncDebounced({ content }); + handleSave({ content }); }, }); diff --git a/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticleEditorPage/ArticleEditorControls.vue b/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticleEditorPage/ArticleEditorControls.vue index d46fb5264..a910f4d8d 100644 --- a/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticleEditorPage/ArticleEditorControls.vue +++ b/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticleEditorPage/ArticleEditorControls.vue @@ -200,7 +200,8 @@ onMounted(() => { @@ -231,7 +232,8 @@ onMounted(() => { diff --git a/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticlePage/ArticleHeaderControls.vue b/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticlePage/ArticleHeaderControls.vue index 5e7feb9fa..6565fab82 100644 --- a/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticlePage/ArticleHeaderControls.vue +++ b/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticlePage/ArticleHeaderControls.vue @@ -3,6 +3,7 @@ import { ref, computed } from 'vue'; import { useI18n } from 'vue-i18n'; import { useRoute } from 'vue-router'; import { OnClickOutside } from '@vueuse/components'; +import { useUISettings } from 'dashboard/composables/useUISettings'; import { ARTICLE_TABS, CATEGORY_ALL, @@ -37,6 +38,7 @@ const emit = defineEmits([ const route = useRoute(); const { t } = useI18n(); +const { updateUISettings } = useUISettings(); const isCategoryMenuOpen = ref(false); const isLocaleMenuOpen = ref(false); @@ -111,13 +113,12 @@ const localeMenuItems = computed(() => { })); }); -const hasMoreThanOneLocaleMenuItems = computed(() => { - return localeMenuItems.value?.length > 1; -}); - const handleLocaleAction = ({ value }) => { emit('localeChange', value); isLocaleMenuOpen.value = false; + updateUISettings({ + last_active_locale_code: value, + }); }; const handleCategoryAction = ({ value }) => { @@ -143,7 +144,7 @@ const handleTabChange = value => { />
-
+