From 37d1fca1ad56c88627f2da571c52687e319bced9 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Mon, 8 Dec 2025 10:22:51 +0800 Subject: [PATCH] only update on changes --- .../layout/app/drawer/ReorderLibraries.vue | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/next-ui/src/components/layout/app/drawer/ReorderLibraries.vue b/next-ui/src/components/layout/app/drawer/ReorderLibraries.vue index b8ab2eb3..123b6f3a 100644 --- a/next-ui/src/components/layout/app/drawer/ReorderLibraries.vue +++ b/next-ui/src/components/layout/app/drawer/ReorderLibraries.vue @@ -114,6 +114,16 @@ const localUnpinned = ref([]) void refresh().then(() => { localPinned.value = pinned.value localUnpinned.value = unpinned.value + + // start watching after initial values are set + watch([localPinned, localUnpinned], ([newPinned, newUnpinned]) => { + const newSettings: Record = {} + newPinned.forEach((it, index) => (newSettings[it.id] = { order: index, unpinned: false })) + newUnpinned.forEach( + (it, index) => (newSettings[it.id] = { order: newPinned.length + index, unpinned: true }), + ) + mutate({ [CLIENT_SETTING_USER.NEXTUI_LIBRARIES]: { value: JSON.stringify(newSettings) } }) + }) }) const draggableConfig = { @@ -125,15 +135,6 @@ const draggableConfig = { } const { mutate } = useUpdateClientSettingsUser() - -watch([localPinned, localUnpinned], ([newPinned, newUnpinned]) => { - const newSettings: Record = {} - newPinned.forEach((it, index) => (newSettings[it.id] = { order: index, unpinned: false })) - newUnpinned.forEach( - (it, index) => (newSettings[it.id] = { order: newPinned.length + index, unpinned: true }), - ) - mutate({ [CLIENT_SETTING_USER.NEXTUI_LIBRARIES]: { value: JSON.stringify(newSettings) } }) -})