Skip to content

Commit

Permalink
added check for duplicate workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
elraphty committed Feb 17, 2025
1 parent c930350 commit c40ca71
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions handlers/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,16 +505,34 @@ func (oh *workspaceHandler) GetUserDropdownWorkspaces(w http.ResponseWriter, r *
hasRole := oh.configUserHasAccess(user.OwnerPubKey, uuid, db.ViewReport)
hasBountyRoles := oh.configUserHasManageBountyRoles(user.OwnerPubKey, uuid)

alreadyAdded := false

if workspace.OwnerPubKey == user.OwnerPubKey {
alreadyAdded = true
}

// don't add deleted workspaces to the list
if !workspace.Deleted && hasBountyRoles {
if hasRole {

// check if workspace has already been added to the list
for _, existingWorkspace := range workspaces {
if existingWorkspace.Uuid == workspace.Uuid {
alreadyAdded = true
}
}

if hasRole && !alreadyAdded {
budget := oh.db.GetWorkspaceBudget(uuid)
workspace.Budget = budget.TotalBudget
} else {
workspace.Budget = 0
}

workspace.BountyCount = bountyCount
workspaces = append(workspaces, workspace)

if !alreadyAdded {
workspaces = append(workspaces, workspace)
}
}
}

Expand Down

0 comments on commit c40ca71

Please sign in to comment.