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 {
|
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"}}
|
return []uiterm.TreeItem{adminItem{label: "No context actions available"}}
|
||||||
}
|
}
|
||||||
items := []uiterm.TreeItem{}
|
items := []uiterm.TreeItem{}
|
||||||
for _, action := range b.Client.ContextActions {
|
for _, action := range actions {
|
||||||
ca := action
|
ca := action
|
||||||
label := ca.Label
|
label := ca.Label
|
||||||
if label == "" {
|
if label == "" {
|
||||||
@@ -830,7 +840,8 @@ func (b *Barnard) executeContextCommand(fields []string) {
|
|||||||
b.AddOutputLine("Admin: usage /admin context <action> [server|user|channel] [target]")
|
b.AddOutputLine("Admin: usage /admin context <action> [server|user|channel] [target]")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
action := b.Client.ContextActions[fields[1]]
|
var action *gumble.ContextAction
|
||||||
|
b.Client.Do(func() { action = b.Client.ContextActions[fields[1]] })
|
||||||
if action == nil {
|
if action == nil {
|
||||||
b.AddOutputLine("Admin: context action not found")
|
b.AddOutputLine("Admin: context action not found")
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user