1
0
Fork 0
forked from Mirrors/gomuks

Don't run UI code in HandleMessage when headless

This commit is contained in:
FIGBERT 2023-08-13 02:01:15 -07:00
parent fb10f59801
commit 3b333aef02
No known key found for this signature in database
GPG key ID: 67F1598D607A844B
2 changed files with 19 additions and 9 deletions

View file

@ -36,6 +36,7 @@ func Init(conf Config, updates chan fmt.Stringer) error {
}
gmx := initialize.NewGomuks(ui.NewGomuksUI, configDir, dataDir, cacheDir, downloadDir)
gmx.Matrix().(*matrix.Container).SetHeadless()
err = gmx.StartHeadless()
if err != nil {
return err

View file

@ -53,15 +53,16 @@ import (
//
// It is used for all Matrix calls from the UI and Matrix event handlers.
type Container struct {
client *mautrix.Client
crypto ifc.Crypto
syncer *GomuksSyncer
gmx ifc.Gomuks
ui ifc.GomuksUI
config *config.Config
history *HistoryManager
running bool
stop chan bool
client *mautrix.Client
crypto ifc.Crypto
syncer *GomuksSyncer
gmx ifc.Gomuks
ui ifc.GomuksUI
config *config.Config
history *HistoryManager
running bool
stop chan bool
headless bool
typing int64
}
@ -77,6 +78,10 @@ func NewContainer(gmx ifc.Gomuks) *Container {
return c
}
func (c *Container) SetHeadless() {
c.headless = true
}
// Client returns the underlying mautrix Client.
func (c *Container) Client() *mautrix.Client {
return c.client
@ -689,6 +694,10 @@ func (c *Container) HandleMessage(source mautrix.EventSource, mxEvent *event.Eve
return
}
if c.headless {
return
}
mainView := c.ui.MainView()
roomView := mainView.GetRoom(evt.RoomID)