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