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 {
|
||||
pushRules := c.PushRules().GetActions(roomView.Room, evt).Should()
|
||||
mainView.NotifyMessage(roomView.Room, message, pushRules)
|
||||
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()
|
||||
|
||||
pushRules := c.PushRules().GetActions(roomView.Room, evt).Should()
|
||||
mainView.NotifyMessage(roomView.Room, message, pushRules)
|
||||
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()
|
||||
}
|
||||
|
@ -33,15 +33,17 @@ import (
|
||||
// replace parts of this default syncer (e.g. the ProcessResponse method). The default syncer uses the observer
|
||||
// pattern to notify callers about incoming events. See GomuksSyncer.OnEventType for more information.
|
||||
type GomuksSyncer struct {
|
||||
Session *config.Session
|
||||
listeners map[string][]gomatrix.OnEventListener // event type to listeners array
|
||||
Session *config.Session
|
||||
listeners map[string][]gomatrix.OnEventListener // event type to listeners array
|
||||
FirstSyncDone bool
|
||||
}
|
||||
|
||||
// NewGomuksSyncer returns an instantiated GomuksSyncer
|
||||
func NewGomuksSyncer(session *config.Session) *GomuksSyncer {
|
||||
return &GomuksSyncer{
|
||||
Session: session,
|
||||
listeners: make(map[string][]gomatrix.OnEventListener),
|
||||
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