From 6fdfa628453b11e80d1bb8c3c560cd3bb3b35ed2 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sat, 5 Oct 2024 19:53:19 -0700 Subject: [PATCH] refac --- .../workspace/Knowledge/Collection.svelte | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/lib/components/workspace/Knowledge/Collection.svelte b/src/lib/components/workspace/Knowledge/Collection.svelte index c34b2aecb..df5e08624 100644 --- a/src/lib/components/workspace/Knowledge/Collection.svelte +++ b/src/lib/components/workspace/Knowledge/Collection.svelte @@ -308,15 +308,19 @@ // Helper function to maintain file paths within zip const syncDirectoryHandler = async () => { - const res = await resetKnowledgeById(localStorage.token, id).catch((e) => { - toast.error(e); - }); + if ((knowledge?.files ?? []).length > 0) { + const res = await resetKnowledgeById(localStorage.token, id).catch((e) => { + toast.error(e); + }); - if (res) { - knowledge = res; - toast.success($i18n.t('Knowledge reset successfully.')); + if (res) { + knowledge = res; + toast.success($i18n.t('Knowledge reset successfully.')); - // Upload directory + // Upload directory + uploadDirectoryHandler(); + } + } else { uploadDirectoryHandler(); } };