From a0f0e5aabee5b3bad68afb7eab092b684275e6fa Mon Sep 17 00:00:00 2001
From: "Thomas F. K. Jorna" <thomasfkjorna@gmail.com>
Date: Tue, 3 Aug 2021 13:18:38 +0200
Subject: fix: make tags update correctly and show them on refresh

---
 components/tweaks.tsx | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

(limited to 'components/tweaks.tsx')

diff --git a/components/tweaks.tsx b/components/tweaks.tsx
index cb1fec0..5561a1b 100644
--- a/components/tweaks.tsx
+++ b/components/tweaks.tsx
@@ -1299,7 +1299,11 @@ export const TagPanel = (props: TagPanelProps) => {
   })
   // .concat[{ value: 'placeholder', label: 'New filter' }]
 
-  const [selectedItems, setSelectedItems] = useState<typeof tagArray>([])
+  const [selectedItems, setSelectedItems] = useState<typeof tagArray>(
+    filter.tags.map((tag) => {
+      return { value: tag, label: tag }
+    }),
+  )
 
   return (
     <CUIAutoComplete
@@ -1312,7 +1316,7 @@ export const TagPanel = (props: TagPanelProps) => {
       onSelectedItemsChange={(changes) => {
         if (changes.selectedItems) {
           setSelectedItems(changes.selectedItems)
-          setFilter({ ...filter, tags: selectedItems.map((item) => item.value) })
+          setFilter({ ...filter, tags: changes.selectedItems.map((item) => item.value) })
         }
       }}
       listItemStyleProps={{ overflow: 'hidden' }}
@@ -1349,7 +1353,11 @@ export const TagColorPanel = (props: TagColorPanelProps) => {
     return { value: tag, label: tag }
   })
 
-  const [selectedItems, setSelectedItems] = useState<typeof tagArray>([])
+  const [selectedItems, setSelectedItems] = useState<typeof tagArray>(
+    Object.keys(tagColors).map((tag) => {
+      return { value: tag, label: tag }
+    }),
+  )
 
   return (
     <Box>
-- 
cgit v1.2.3

