Possibly speed up syncs with filters
This commit is contained in:
parent
38364646a7
commit
1321e1a06a
@ -134,5 +134,24 @@ func (s *GomuksSyncer) OnFailedSync(res *gomatrix.RespSync, err error) (time.Dur
|
|||||||
|
|
||||||
// GetFilterJSON returns a filter with a timeline limit of 50.
|
// GetFilterJSON returns a filter with a timeline limit of 50.
|
||||||
func (s *GomuksSyncer) GetFilterJSON(userID string) json.RawMessage {
|
func (s *GomuksSyncer) GetFilterJSON(userID string) json.RawMessage {
|
||||||
return json.RawMessage(`{"room":{"timeline":{"limit":50}}}`)
|
return json.RawMessage(`{
|
||||||
|
"room": {
|
||||||
|
"include_leave": true,
|
||||||
|
"state": {
|
||||||
|
"types": ["m.room.member"]
|
||||||
|
},
|
||||||
|
"timeline": {
|
||||||
|
"types": ["m.room.message"],
|
||||||
|
"limit": 50
|
||||||
|
},
|
||||||
|
"ephemeral": {
|
||||||
|
"types": ["m.typing"]
|
||||||
|
},
|
||||||
|
"account_data": {"types": []}
|
||||||
|
},
|
||||||
|
"account_data": {
|
||||||
|
"types": ["m.push_rules"]
|
||||||
|
},
|
||||||
|
"presence": {"types": []}
|
||||||
|
}`)
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ func (view *MainView) InputKeyHandler(roomView *widget.RoomView, key *tcell.Even
|
|||||||
msgView := roomView.MessageView()
|
msgView := roomView.MessageView()
|
||||||
if k == tcell.KeyPgUp || k == tcell.KeyUp {
|
if k == tcell.KeyPgUp || k == tcell.KeyUp {
|
||||||
if msgView.IsAtTop() {
|
if msgView.IsAtTop() {
|
||||||
go view.LoadMoreHistory(roomView.Room.ID)
|
go view.LoadHistory(roomView.Room.ID, false)
|
||||||
} else {
|
} else {
|
||||||
msgView.MoveUp(k == tcell.KeyPgUp)
|
msgView.MoveUp(k == tcell.KeyPgUp)
|
||||||
}
|
}
|
||||||
@ -262,7 +262,7 @@ func (view *MainView) addRoom(index int, room string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
debug.Printf("Failed to load history of %s: %v", roomView.Room.GetTitle(), err)
|
debug.Printf("Failed to load history of %s: %v", roomView.Room.GetTitle(), err)
|
||||||
} else if count <= 0 {
|
} else if count <= 0 {
|
||||||
go view.LoadInitialHistory(room)
|
go view.LoadHistory(room, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,14 +333,6 @@ func (view *MainView) AddServiceMessage(roomView *widget.RoomView, text string)
|
|||||||
view.parent.Render()
|
view.parent.Render()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (view *MainView) LoadMoreHistory(room string) {
|
|
||||||
view.LoadHistory(room, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (view *MainView) LoadInitialHistory(room string) {
|
|
||||||
view.LoadHistory(room, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (view *MainView) LoadHistory(room string, initial bool) {
|
func (view *MainView) LoadHistory(room string, initial bool) {
|
||||||
defer view.gmx.Recover()
|
defer view.gmx.Recover()
|
||||||
roomView := view.rooms[room]
|
roomView := view.rooms[room]
|
||||||
@ -364,8 +356,10 @@ func (view *MainView) LoadHistory(room string, initial bool) {
|
|||||||
|
|
||||||
if initial {
|
if initial {
|
||||||
batch = view.config.Session.NextBatch
|
batch = view.config.Session.NextBatch
|
||||||
|
debug.Print("Loading initial history for", room)
|
||||||
|
} else {
|
||||||
|
debug.Print("Loading more history for", room, "starting from", batch)
|
||||||
}
|
}
|
||||||
debug.Print("Loading history for", room, "starting from", batch, "(initial:", initial, ")")
|
|
||||||
history, prevBatch, err := view.matrix.GetHistory(roomView.Room.ID, batch, 50)
|
history, prevBatch, err := view.matrix.GetHistory(roomView.Room.ID, batch, 50)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
view.AddServiceMessage(roomView, "Failed to fetch history")
|
view.AddServiceMessage(roomView, "Failed to fetch history")
|
||||||
|
Loading…
Reference in New Issue
Block a user