From a55ea42d7f5900bd5fc8fad047040c7865824f33 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 15 Jun 2019 01:11:51 +0300 Subject: Unbreak things --- interface/gomuks.go | 2 +- interface/matrix.go | 1 + interface/ui.go | 8 ++------ 3 files changed, 4 insertions(+), 7 deletions(-) (limited to 'interface') diff --git a/interface/gomuks.go b/interface/gomuks.go index f2565fb..5937a6b 100644 --- a/interface/gomuks.go +++ b/interface/gomuks.go @@ -27,5 +27,5 @@ type Gomuks interface { Config() *config.Config Start() - Stop() + Stop(save bool) } diff --git a/interface/matrix.go b/interface/matrix.go index f312df1..6a1a977 100644 --- a/interface/matrix.go +++ b/interface/matrix.go @@ -45,6 +45,7 @@ type MatrixContainer interface { GetHistory(room *rooms.Room, limit int) ([]*mautrix.Event, error) GetEvent(room *rooms.Room, eventID string) (*mautrix.Event, error) GetRoom(roomID string) *rooms.Room + GetOrCreateRoom(roomID string) *rooms.Room Download(mxcURL string) ([]byte, string, string, error) GetDownloadURL(homeserver, fileID string) string diff --git a/interface/ui.go b/interface/ui.go index 781f803..48a6007 100644 --- a/interface/ui.go +++ b/interface/ui.go @@ -43,14 +43,13 @@ type MainView interface { GetRoom(roomID string) RoomView AddRoom(room *rooms.Room) RemoveRoom(room *rooms.Room) - SetRooms(rooms map[string]*rooms.Room) + SetRooms(rooms *rooms.RoomCache) UpdateTags(room *rooms.Room) SetTyping(roomID string, users []string) NotifyMessage(room *rooms.Room, message Message, should pushrules.PushActionArrayShould) - InitialSyncDone() } type RoomView interface { @@ -68,13 +67,10 @@ type RoomView interface { type Message interface { ID() string - TxnID() string - SenderID() string - Timestamp() time.Time + Time() time.Time NotificationSenderName() string NotificationContent() string - SetState(state mautrix.OutgoingEventState) SetIsHighlight(highlight bool) SetID(id string) } -- cgit v1.2.3-70-g09d2 From 0f08c49df40f77e90e4b5ef7604c74631065faa3 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 15 Jun 2019 17:51:36 +0300 Subject: Fix bumping unloaded rooms in room list when receiving messages --- interface/ui.go | 1 + matrix/matrix.go | 13 ++++++++++++- ui/view-main.go | 6 +++++- 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'interface') diff --git a/interface/ui.go b/interface/ui.go index 48a6007..ad2458a 100644 --- a/interface/ui.go +++ b/interface/ui.go @@ -44,6 +44,7 @@ type MainView interface { AddRoom(room *rooms.Room) RemoveRoom(room *rooms.Room) SetRooms(rooms *rooms.RoomCache) + Bump(room *rooms.Room) UpdateTags(room *rooms.Room) diff --git a/matrix/matrix.go b/matrix/matrix.go index 8c19b24..1a75f96 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -315,7 +315,7 @@ func (c *Container) HandleMessage(source EventSource, evt *mautrix.Event) { debug.Printf("Failed to add event %s to history: %v", evt.ID, err) } - if !c.config.AuthCache.InitialSyncDone || !room.Loaded() { + if !c.config.AuthCache.InitialSyncDone { room.LastReceivedMessage = time.Unix(evt.Timestamp/1000, evt.Timestamp%1000*1000) return } @@ -328,6 +328,17 @@ func (c *Container) HandleMessage(source EventSource, evt *mautrix.Event) { return } + if !room.Loaded() { + pushRules := c.PushRules().GetActions(room, evt).Should() + shouldNotify := pushRules.Notify || !pushRules.NotifySpecified + if !shouldNotify { + room.LastReceivedMessage = time.Unix(evt.Timestamp/1000, evt.Timestamp%1000*1000) + room.AddUnread(evt.ID, shouldNotify, pushRules.Highlight) + mainView.Bump(room) + return + } + } + // TODO switch to roomView.AddEvent message := roomView.ParseEvent(evt) if message != nil { diff --git a/ui/view-main.go b/ui/view-main.go index 5d2e1f9..ea24644 100644 --- a/ui/view-main.go +++ b/ui/view-main.go @@ -387,8 +387,12 @@ func sendNotification(room *rooms.Room, sender, text string, critical, sound boo notification.Send(sender, text, critical, sound) } -func (view *MainView) NotifyMessage(room *rooms.Room, message ifc.Message, should pushrules.PushActionArrayShould) { +func (view *MainView) Bump(room *rooms.Room) { view.roomList.Bump(room) +} + +func (view *MainView) NotifyMessage(room *rooms.Room, message ifc.Message, should pushrules.PushActionArrayShould) { + view.Bump(room) uiMsg, ok := message.(*messages.UIMessage) if ok && uiMsg.SenderID == view.config.UserID { return -- cgit v1.2.3-70-g09d2