Merge branch 'syncListeners' of dan/ui into master

This commit is contained in:
Sarah Jamie Lewis 2019-07-24 13:52:19 -07:00 committed by Gogs
commit 8fe6648100
3 changed files with 12 additions and 5 deletions

View File

@ -11,13 +11,14 @@ import (
"strconv"
)
func AppEventListener(gcd *gothings.GrandCentralDispatcher) {
func AppEventListener(gcd *gothings.GrandCentralDispatcher, subscribed chan bool) {
q := event.NewEventQueue(1000)
the.AppBus.Subscribe(event.NewPeer, q.EventChannel)
the.AppBus.Subscribe(event.PeerError, q.EventChannel)
the.AppBus.Subscribe(event.AppError, q.EventChannel)
the.AppBus.Subscribe(event.ACNStatus, q.EventChannel)
the.AppBus.Subscribe(event.ReloadDone, q.EventChannel)
subscribed <- true
for {
e := q.Next()
@ -68,6 +69,11 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher) {
the.Peer = the.CwtchApp.GetPeer(onion)
the.EventBus = the.CwtchApp.GetEventBus(onion)
incSubscribed := make(chan bool)
go IncomingListener(&gcd.UIState, incSubscribed)
<-incSubscribed
go PresencePoller(&gcd.UIState)
gcd.UpdateMyProfile(the.Peer.GetProfile().Name, the.Peer.GetProfile().Onion, cwutil.RandomProfileImage(the.Peer.GetProfile().Onion))
if e.Data[event.Status] != "running" {
the.CwtchApp.LaunchPeers()
@ -110,8 +116,6 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher) {
})
}
}
go IncomingListener(&gcd.UIState)
go PresencePoller(&gcd.UIState)
// load ui preferences
gcd.RequestSettings()

View File

@ -11,7 +11,7 @@ import (
"time"
)
func IncomingListener(uiState *gothings.InterfaceState) {
func IncomingListener(uiState *gothings.InterfaceState, subscribed chan bool) {
q := event.NewEventQueue(1000)
the.EventBus.Subscribe(event.NewMessageFromPeer, q.EventChannel)
the.EventBus.Subscribe(event.NewMessageFromGroup, q.EventChannel)
@ -21,6 +21,7 @@ func IncomingListener(uiState *gothings.InterfaceState) {
the.EventBus.Subscribe(event.JoinServer, q.EventChannel)
the.EventBus.Subscribe(event.ServerStateChange, q.EventChannel)
the.EventBus.Subscribe(event.PeerStateChange, q.EventChannel)
subscribed <- true
for {
e := q.Next()

View File

@ -229,7 +229,9 @@ func loadNetworkingAndFiles(gcd *gothings.GrandCentralDispatcher, service bool,
if !service {
the.AppBus = the.CwtchApp.GetPrimaryBus()
go characters.AppEventListener(gcd)
subscribed := make(chan bool)
go characters.AppEventListener(gcd, subscribed)
<-subscribed
}
if !service && !clientUI {