mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
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
|
||||
|
|
|
@ -62,6 +62,7 @@ type Container struct {
|
|||
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