From 91f32efbe492f0fbc1de7c2aa166ccb3914a9ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=83=E5=90=89/=EC=9B=90=EA=B8=B8/OneGil?= Date: Tue, 2 Jan 2024 23:39:23 +0800 Subject: [PATCH] fix(client): logic of hidden tabs and categories (#130) --- packages/client/src/composables/state-tab.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/client/src/composables/state-tab.ts b/packages/client/src/composables/state-tab.ts index 9e86af84c..3e4d23db5 100644 --- a/packages/client/src/composables/state-tab.ts +++ b/packages/client/src/composables/state-tab.ts @@ -55,29 +55,33 @@ export function useAllTabs() { }) const categorizedTabs = computed(() => { const { hiddenTabCategories, hiddenTabs, pinnedTabs } = devtoolsClientState.value.tabSettings + const pinnedHidden = hiddenTabCategories.includes('pinned') // TODO: custom tabs const tabs = allTabs.value.reduce((prev, [category, tabs]) => { const data: [CategorizedCategory, CategorizedTab[]] = [{ hidden: false, name: category }, []] - let hiddenCount = 0 + const categoryHidden = hiddenTabCategories.includes(category) tabs.forEach((tab) => { - const hidden = hiddenTabs.includes(tab.name) || hiddenTabCategories.includes(category) - if (hidden) - hiddenCount += 1 + const tabHidden = hiddenTabs.includes(tab.name) if (pinnedTabs.includes(tab.name)) { prev[0][1].push({ ...tab, - hidden, + hidden: tabHidden || pinnedHidden, }) } - else { data[1].push({ ...tab, hidden }) } + else { + const hidden = tabHidden || categoryHidden + data[1].push({ ...tab, hidden }) + } }) - if (hiddenCount === tabs.length) - data[0].hidden = true + data[0].hidden = data[1].every(t => t.hidden) prev.push(data) return prev }, [[{ name: 'pinned', hidden: false }, []]]) + // set pinned category hidden value + tabs[0][0].hidden = tabs[0][1].every(t => t.hidden) + // sort pinned tabs by pinned order tabs[0][1].sort((a, b) => pinnedTabs.indexOf(a.name) - pinnedTabs.indexOf(b.name)) return tabs