Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: team collection resetting on unmount within app lifecycle (#3396)

Andrew Bastin40f72278a996
diff --git a/packages/hoppscotch-common/src/components/collections/index.vue b/packages/hoppscotch-common/src/components/collections/index.vue
index a7bd98fe9..1d015572e 100644
--- a/packages/hoppscotch-common/src/components/collections/index.vue
+++ b/packages/hoppscotch-common/src/components/collections/index.vue
@@ -377,22 +377,26 @@ const updateSelectedTeam = (team: SelectedTeam) => {
const workspace = workspaceService.currentWorkspace
// Used to switch collection type and team when user switch workspace in the global workspace switcher
-// Check if there is a teamID in the workspace, if yes, switch to team collection and select the team
-// If there is no teamID, switch to my environment
+// Check if there is a teamID in the workspace, if yes, switch to team collections and select the team
+// If there is no teamID, switch to my collections
watch(
() => {
const space = workspace.value
-
- if (space.type === "personal") return undefined
- else return space.teamID
+ return space.type === "personal" ? undefined : space.teamID
},
(teamID) => {
- if (!teamID) {
- switchToMyCollections()
- } else if (teamID) {
+ if (teamID) {
const team = myTeams.value?.find((t) => t.id === teamID)
- if (team) updateSelectedTeam(team)
+ if (team) {
+ updateSelectedTeam(team)
+ }
+ return
}
+
+ return switchToMyCollections()
+ },
+ {
+ immediate: true,
}
)