diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-03-24 13:27:13 +0200 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-03-24 14:16:11 +0200 |
commit | 1321e1a06ac8d8db13014e9c94aa52e1ffa32c1a (patch) | |
tree | 81efb610c32cd343b916c91df68fb0d3c25aee51 /ui | |
parent | 38364646a73a5e666f2db6a34025e2a5a0e3999a (diff) |
Possibly speed up syncs with filters
Diffstat (limited to 'ui')
-rw-r--r-- | ui/view-main.go | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/ui/view-main.go b/ui/view-main.go index 1f14943..5515004 100644 --- a/ui/view-main.go +++ b/ui/view-main.go @@ -191,7 +191,7 @@ func (view *MainView) InputKeyHandler(roomView *widget.RoomView, key *tcell.Even msgView := roomView.MessageView() if k == tcell.KeyPgUp || k == tcell.KeyUp { if msgView.IsAtTop() { - go view.LoadMoreHistory(roomView.Room.ID) + go view.LoadHistory(roomView.Room.ID, false) } else { msgView.MoveUp(k == tcell.KeyPgUp) } @@ -262,7 +262,7 @@ func (view *MainView) addRoom(index int, room string) { if err != nil { debug.Printf("Failed to load history of %s: %v", roomView.Room.GetTitle(), err) } 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() } -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) { defer view.gmx.Recover() roomView := view.rooms[room] @@ -364,8 +356,10 @@ func (view *MainView) LoadHistory(room string, initial bool) { if initial { 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) if err != nil { view.AddServiceMessage(roomView, "Failed to fetch history") |