fix: team collection resetting on unmount within app lifecycle (#3396)
* fix: team collection resetting on unmount within app lifecycle * chore: linting * refactor: eliminate redundancy * chore: update comment about the watcher purpose --------- Co-authored-by: jamesgeorge007 <jamesgeorge998001@gmail.com>
This commit is contained in:
@@ -377,22 +377,26 @@ const updateSelectedTeam = (team: SelectedTeam) => {
|
|||||||
const workspace = workspaceService.currentWorkspace
|
const workspace = workspaceService.currentWorkspace
|
||||||
|
|
||||||
// Used to switch collection type and team when user switch workspace in the global workspace switcher
|
// 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
|
// 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 environment
|
// If there is no teamID, switch to my collections
|
||||||
watch(
|
watch(
|
||||||
() => {
|
() => {
|
||||||
const space = workspace.value
|
const space = workspace.value
|
||||||
|
return space.type === "personal" ? undefined : space.teamID
|
||||||
if (space.type === "personal") return undefined
|
|
||||||
else return space.teamID
|
|
||||||
},
|
},
|
||||||
(teamID) => {
|
(teamID) => {
|
||||||
if (!teamID) {
|
if (teamID) {
|
||||||
switchToMyCollections()
|
|
||||||
} else if (teamID) {
|
|
||||||
const team = myTeams.value?.find((t) => t.id === teamID)
|
const team = myTeams.value?.find((t) => t.id === teamID)
|
||||||
if (team) updateSelectedTeam(team)
|
if (team) {
|
||||||
|
updateSelectedTeam(team)
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return switchToMyCollections()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user