Stop sending notifications from first sync
This commit is contained in:
parent
70343b4536
commit
c6e9f498a4
@ -36,6 +36,7 @@ import (
|
||||
// It is used for all Matrix calls from the UI and Matrix event handlers.
|
||||
type Container struct {
|
||||
client *gomatrix.Client
|
||||
syncer *GomuksSyncer
|
||||
gmx ifc.Gomuks
|
||||
ui ifc.GomuksUI
|
||||
config *config.Config
|
||||
@ -172,13 +173,13 @@ func (c *Container) OnLogout() {
|
||||
func (c *Container) OnLogin() {
|
||||
c.client.Store = c.config.Session
|
||||
|
||||
syncer := NewGomuksSyncer(c.config.Session)
|
||||
syncer.OnEventType("m.room.message", c.HandleMessage)
|
||||
syncer.OnEventType("m.room.member", c.HandleMembership)
|
||||
syncer.OnEventType("m.typing", c.HandleTyping)
|
||||
syncer.OnEventType("m.push_rules", c.HandlePushRules)
|
||||
syncer.OnEventType("m.tag", c.HandleTag)
|
||||
c.client.Syncer = syncer
|
||||
c.syncer = NewGomuksSyncer(c.config.Session)
|
||||
c.syncer.OnEventType("m.room.message", c.HandleMessage)
|
||||
c.syncer.OnEventType("m.room.member", c.HandleMembership)
|
||||
c.syncer.OnEventType("m.typing", c.HandleTyping)
|
||||
c.syncer.OnEventType("m.push_rules", c.HandlePushRules)
|
||||
c.syncer.OnEventType("m.tag", c.HandleTag)
|
||||
c.client.Syncer = c.syncer
|
||||
|
||||
c.UpdateRoomList()
|
||||
}
|
||||
@ -222,8 +223,10 @@ func (c *Container) HandleMessage(evt *gomatrix.Event) {
|
||||
|
||||
message := mainView.ProcessMessageEvent(roomView, evt)
|
||||
if message != nil {
|
||||
if c.syncer.FirstSyncDone {
|
||||
pushRules := c.PushRules().GetActions(roomView.Room, evt).Should()
|
||||
mainView.NotifyMessage(roomView.Room, message, pushRules)
|
||||
}
|
||||
roomView.AddMessage(message, widget.AppendMessage)
|
||||
c.ui.Render()
|
||||
}
|
||||
@ -283,8 +286,10 @@ func (c *Container) HandleMembership(evt *gomatrix.Event) {
|
||||
// TODO This should probably also be in a different place
|
||||
roomView.UpdateUserList()
|
||||
|
||||
if c.syncer.FirstSyncDone {
|
||||
pushRules := c.PushRules().GetActions(roomView.Room, evt).Should()
|
||||
mainView.NotifyMessage(roomView.Room, message, pushRules)
|
||||
}
|
||||
roomView.AddMessage(message, widget.AppendMessage)
|
||||
c.ui.Render()
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import (
|
||||
type GomuksSyncer struct {
|
||||
Session *config.Session
|
||||
listeners map[string][]gomatrix.OnEventListener // event type to listeners array
|
||||
FirstSyncDone bool
|
||||
}
|
||||
|
||||
// NewGomuksSyncer returns an instantiated GomuksSyncer
|
||||
@ -42,6 +43,7 @@ func NewGomuksSyncer(session *config.Session) *GomuksSyncer {
|
||||
return &GomuksSyncer{
|
||||
Session: session,
|
||||
listeners: make(map[string][]gomatrix.OnEventListener),
|
||||
FirstSyncDone: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,6 +89,8 @@ func (s *GomuksSyncer) ProcessResponse(res *gomatrix.RespSync, since string) (er
|
||||
}
|
||||
}
|
||||
|
||||
s.FirstSyncDone = true
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user