From 7be1c0a8719141ec162651e46845d2141f13c4b2 Mon Sep 17 00:00:00 2001 From: mateusz-winiarczyk <mateusz.winiarczyk@appunite.com> Date: Thu, 4 Apr 2024 20:01:06 +0200 Subject: [PATCH] fix(drawers): fix openning plugin and overlay drawers when ids are in url parameters --- src/redux/root/init.thunks.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/redux/root/init.thunks.ts b/src/redux/root/init.thunks.ts index 23aa9368..e28be3dc 100644 --- a/src/redux/root/init.thunks.ts +++ b/src/redux/root/init.thunks.ts @@ -1,10 +1,11 @@ import { PROJECT_ID } from '@/constants'; -import { openSearchDrawerWithSelectedTab } from '@/redux/drawer/drawer.slice'; +import { openOverlaysDrawer, openSearchDrawerWithSelectedTab } from '@/redux/drawer/drawer.slice'; import { AppDispatch } from '@/redux/store'; import { QueryData } from '@/types/query'; import { getDefaultSearchTab } from '@/components/FunctionalArea/TopBar/SearchBar/SearchBar.utils'; import { PluginsManager } from '@/services/pluginsManager'; import { createAsyncThunk } from '@reduxjs/toolkit'; +import { ZERO } from '@/constants/common'; import { getAllBackgroundsByProjectId } from '../backgrounds/backgrounds.thunks'; import { getConfiguration, getConfigurationOptions } from '../configuration/configuration.thunks'; import { @@ -25,6 +26,7 @@ import { setPerfectMatch } from '../search/search.slice'; import { getSearchData } from '../search/search.thunks'; import { getStatisticsById } from '../statistics/statistics.thunks'; import { getSessionValid } from '../user/user.thunks'; +import { openPluginsDrawer, setCurrentDrawerPluginHash } from '../plugins/plugins.slice'; interface InitializeAppParams { queryData: QueryData; @@ -44,6 +46,13 @@ export const fetchInitialAppData = createAsyncThunk< setHashedPlugin: PluginsManager.setHashedPlugin, }), ); + + const hash = queryData.pluginsId[ZERO]; + + if (hash) { + dispatch(openPluginsDrawer()); + dispatch(setCurrentDrawerPluginHash(hash)); + } } /** Fetch all data required for rendering map */ @@ -90,5 +99,9 @@ export const fetchInitialAppData = createAsyncThunk< /** fetch overlays */ if (queryData.overlaysId) { dispatch(getInitOverlays({ overlaysId: queryData.overlaysId })); + + if (!queryData.searchValue) { + dispatch(openOverlaysDrawer()); + } } }); -- GitLab