Route network UI callbacks through UI queue
This commit is contained in:
committed by
Brandon McGinty
parent
12761f29ca
commit
d50c6726ad
@@ -120,9 +120,11 @@ func (b *Barnard) OnConnect(e *gumble.ConnectEvent) {
|
||||
b.recordingStarting = false
|
||||
b.RecordingMutex.Unlock()
|
||||
|
||||
b.Ui.SetActive(uiViewInput)
|
||||
b.UiTree.Rebuild()
|
||||
b.Ui.Refresh()
|
||||
b.postUI(func() {
|
||||
b.Ui.SetActive(uiViewInput)
|
||||
b.UiTree.Rebuild()
|
||||
b.Ui.Refresh()
|
||||
})
|
||||
|
||||
var users []*gumble.User
|
||||
b.Client.Do(func() {
|
||||
@@ -146,7 +148,6 @@ func (b *Barnard) OnConnect(e *gumble.ConnectEvent) {
|
||||
if wmsg != "" {
|
||||
b.AddOutputLine(fmt.Sprintf("Welcome message: %s", wmsg))
|
||||
}
|
||||
b.Ui.Refresh()
|
||||
|
||||
// Auto-start transmission if requested
|
||||
if b.AutoTransmit && b.Stream != nil && !b.Tx {
|
||||
@@ -197,8 +198,10 @@ func (b *Barnard) OnDisconnect(e *gumble.DisconnectEvent) {
|
||||
}
|
||||
b.Tx = false
|
||||
b.Connected = false
|
||||
b.UiTree.Rebuild()
|
||||
b.Ui.Refresh()
|
||||
b.postUI(func() {
|
||||
b.UiTree.Rebuild()
|
||||
b.Ui.Refresh()
|
||||
})
|
||||
go b.reconnectGoroutine()
|
||||
}
|
||||
|
||||
@@ -285,8 +288,10 @@ func (b *Barnard) OnUserChange(e *gumble.UserChangeEvent) {
|
||||
b.AddOutputLine(formatUserStats(e.User))
|
||||
}
|
||||
b.updateUserChannel(e)
|
||||
b.RebuildUserChannelTreePreservingSelection()
|
||||
b.Ui.Refresh()
|
||||
b.postUI(func() {
|
||||
b.RebuildUserChannelTreePreservingSelection()
|
||||
b.Ui.Refresh()
|
||||
})
|
||||
}
|
||||
|
||||
type userChangeNotification struct {
|
||||
@@ -386,8 +391,10 @@ func (b *Barnard) OnChannelChange(e *gumble.ChannelChangeEvent) {
|
||||
b.AddOutputLine(fmt.Sprintf("Channel permissions for %s: %s", e.Channel.Name, permissionList(*permission)))
|
||||
}
|
||||
}
|
||||
b.RebuildUserChannelTreePreservingSelection()
|
||||
b.Ui.Refresh()
|
||||
b.postUI(func() {
|
||||
b.RebuildUserChannelTreePreservingSelection()
|
||||
b.Ui.Refresh()
|
||||
})
|
||||
}
|
||||
|
||||
func formatUserStats(user *gumble.User) string {
|
||||
@@ -465,34 +472,27 @@ func (b *Barnard) OnPermissionDenied(e *gumble.PermissionDeniedEvent) {
|
||||
}
|
||||
|
||||
func (b *Barnard) OnUserList(e *gumble.UserListEvent) {
|
||||
b.adminUserList = e.UserList
|
||||
b.AddOutputLine(fmt.Sprintf("Admin: received %d registered users", len(e.UserList)))
|
||||
b.UiAdmin.Rebuild()
|
||||
b.Ui.Refresh()
|
||||
b.postUI(func() { b.adminUserList = e.UserList; b.UiAdmin.Rebuild(); b.Ui.Refresh() })
|
||||
}
|
||||
|
||||
func (b *Barnard) OnACL(e *gumble.ACLEvent) {
|
||||
b.adminACL = e.ACL
|
||||
if e.ACL != nil && e.ACL.Channel != nil {
|
||||
b.AddOutputLine(fmt.Sprintf("Admin: received ACLs for %s", e.ACL.Channel.Name))
|
||||
}
|
||||
b.UiAdmin.Rebuild()
|
||||
b.Ui.Refresh()
|
||||
b.postUI(func() { b.adminACL = e.ACL; b.UiAdmin.Rebuild(); b.Ui.Refresh() })
|
||||
}
|
||||
|
||||
func (b *Barnard) OnBanList(e *gumble.BanListEvent) {
|
||||
b.adminBanList = e.BanList
|
||||
b.AddOutputLine(fmt.Sprintf("Admin: received %d bans", len(e.BanList)))
|
||||
b.UiAdmin.Rebuild()
|
||||
b.Ui.Refresh()
|
||||
b.postUI(func() { b.adminBanList = e.BanList; b.UiAdmin.Rebuild(); b.Ui.Refresh() })
|
||||
}
|
||||
|
||||
func (b *Barnard) OnContextActionChange(e *gumble.ContextActionChangeEvent) {
|
||||
if e.ContextAction != nil {
|
||||
b.AddOutputLine(fmt.Sprintf("Admin: context action updated: %s", e.ContextAction.Name))
|
||||
}
|
||||
b.UiAdmin.Rebuild()
|
||||
b.Ui.Refresh()
|
||||
b.postUI(func() { b.UiAdmin.Rebuild(); b.Ui.Refresh() })
|
||||
}
|
||||
|
||||
func (b *Barnard) OnServerConfig(e *gumble.ServerConfigEvent) {
|
||||
|
||||
Reference in New Issue
Block a user