From 1f3f8464ea89bc3aaf60ad9e8cb163ae7755524a Mon Sep 17 00:00:00 2001 From: Nivedin <53208152+nivedin@users.noreply.github.com> Date: Wed, 7 Jun 2023 23:46:09 +0530 Subject: [PATCH] fix: team environment lost when route changes (#3113) Co-authored-by: Liyas Thomas --- .../src/components/environments/Selector.vue | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/packages/hoppscotch-common/src/components/environments/Selector.vue b/packages/hoppscotch-common/src/components/environments/Selector.vue index 955e9af2..604c1344 100644 --- a/packages/hoppscotch-common/src/components/environments/Selector.vue +++ b/packages/hoppscotch-common/src/components/environments/Selector.vue @@ -97,7 +97,7 @@ {{ t("state.loading") }} -
+
{ + !teamListAdapter.isInitialized && teamListAdapter.initialize() +}) + +const switchToTeamWorkspace = (team: GetMyTeamsQuery["myTeams"][number]) => { + REMEMBERED_TEAM_ID.value = team.id + changeWorkspace({ + teamID: team.id, + teamName: team.name, + type: "team", + }) +} + +watch( + () => myTeams.value, + (newTeams) => { + if (newTeams && !teamListFetched.value) { + teamListFetched.value = true + if (REMEMBERED_TEAM_ID.value) { + const team = newTeams.find((t) => t.id === REMEMBERED_TEAM_ID.value) + if (team) switchToTeamWorkspace(team) + } + } + } +) + const selectedEnv = computed(() => { if (selectedEnvironmentIndex.value.type === "MY_ENV") { return {