This commit is contained in:
erinn 2022-01-13 14:42:31 -08:00
parent 24bcd72e75
commit 1df0ba54f7
2 changed files with 12 additions and 0 deletions

4
lib.go
View File

@ -228,6 +228,10 @@ func _startCwtch(appDir string, torPath string) {
LaunchServers()
// Send global settings to the UI...
if application == nil {
log.Errorf("startCwtch: primary application object has gone away. assuming application is closing.")
return
}
application.GetPrimaryBus().Publish(event.NewEvent(utils.UpdateGlobalSettings, map[event.Field]string{event.Data: string(settingsJson)}))
log.Infof("libcwtch-go application launched")
application.GetPrimaryBus().Publish(event.NewEvent(utils.CwtchStarted, map[event.Field]string{}))

View File

@ -88,6 +88,10 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
case event.NewPeer:
onion := e.Data[event.Identity]
profile := eh.app.GetPeer(e.Data[event.Identity])
if profile == nil {
log.Errorf("NewPeer: skipping profile initialization. this should only happen when the app is rapidly opened+closed (eg during testing)")
break
}
log.Debug("New Peer Event: %v", e)
if e.Data["Reload"] != event.True {
@ -426,6 +430,10 @@ func unwrap(original *EventProfileEnvelope) *event.Event {
func (eh *EventHandler) startHandlingPeer(onion string) {
eventBus := eh.app.GetEventBus(onion)
// if eventBus == nil {
// log.Errorf("startHandlingPeer: eventBus was nil; skipping contact initialization. this should only happen when the app is rapidly opened+closed (eg during testing)")
// return
// }
q := event.NewQueue()
// eventBus.Subscribe(event.NetworkStatus, q)