From c271e01dfc6eaf44de0d1e5c9b532853b656f95a Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Fri, 21 Feb 2025 15:42:59 +0100 Subject: [PATCH] ui: reload tags on project change --- .../shared/SessionFilters/SessionFilters.tsx | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/frontend/app/components/shared/SessionFilters/SessionFilters.tsx b/frontend/app/components/shared/SessionFilters/SessionFilters.tsx index 4e40105ff..84b95a585 100644 --- a/frontend/app/components/shared/SessionFilters/SessionFilters.tsx +++ b/frontend/app/components/shared/SessionFilters/SessionFilters.tsx @@ -23,28 +23,34 @@ function SessionFilters() { projectsStore.instance?.saveRequestPayloads ?? false; const activeProject = projectsStore.active + const reloadTags = async () => { + const tags = await tagWatchStore.getTags(); + if (tags) { + addOptionsToFilter( + FilterKey.TAGGED_ELEMENT, + tags.map((tag) => ({ + label: tag.name, + value: tag.tagId.toString(), + })) + ); + searchStore.refreshFilterOptions(); + } + } + useEffect(() => { // Add default location/screen filter if no filters are present if (searchStore.instance.filters.length === 0) { searchStore.addFilterByKeyAndValue(activeProject?.platform === 'web' ? FilterKey.LOCATION : FilterKey.VIEW_MOBILE , '', 'isAny') } + void reloadTags(); }, [projectsStore.activeSiteId, activeProject]) + useSessionSearchQueryHandler({ appliedFilter, loading: metaLoading, onBeforeLoad: async () => { - const tags = await tagWatchStore.getTags(); - if (tags) { - addOptionsToFilter( - FilterKey.TAGGED_ELEMENT, - tags.map((tag) => ({ - label: tag.name, - value: tag.tagId.toString(), - })) - ); - searchStore.refreshFilterOptions(); - } + await reloadTags(); }, });