Snapshot context actions under client lock
This commit is contained in:
committed by
Brandon McGinty
parent
7785f0a5b5
commit
95c7394b01
@@ -490,11 +490,21 @@ func (b *Barnard) adminACLItems() []uiterm.TreeItem {
|
||||
}
|
||||
|
||||
func (b *Barnard) adminContextActionItems() []uiterm.TreeItem {
|
||||
if b.Client == nil || len(b.Client.ContextActions) == 0 {
|
||||
if b.Client == nil {
|
||||
return []uiterm.TreeItem{adminItem{label: "No context actions available"}}
|
||||
}
|
||||
var actions []*gumble.ContextAction
|
||||
b.Client.Do(func() {
|
||||
actions = make([]*gumble.ContextAction, 0, len(b.Client.ContextActions))
|
||||
for _, action := range b.Client.ContextActions {
|
||||
actions = append(actions, action)
|
||||
}
|
||||
})
|
||||
if len(actions) == 0 {
|
||||
return []uiterm.TreeItem{adminItem{label: "No context actions available"}}
|
||||
}
|
||||
items := []uiterm.TreeItem{}
|
||||
for _, action := range b.Client.ContextActions {
|
||||
for _, action := range actions {
|
||||
ca := action
|
||||
label := ca.Label
|
||||
if label == "" {
|
||||
@@ -830,7 +840,8 @@ func (b *Barnard) executeContextCommand(fields []string) {
|
||||
b.AddOutputLine("Admin: usage /admin context <action> [server|user|channel] [target]")
|
||||
return
|
||||
}
|
||||
action := b.Client.ContextActions[fields[1]]
|
||||
var action *gumble.ContextAction
|
||||
b.Client.Do(func() { action = b.Client.ContextActions[fields[1]] })
|
||||
if action == nil {
|
||||
b.AddOutputLine("Admin: context action not found")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user