forked from Mirrors/gomuks
Don't run UI code in HandleMessage when headless
This commit is contained in:
parent
fb10f59801
commit
3b333aef02
2 changed files with 19 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue