Move loaded history pointer to message view
When it was in the history manager, it wouldn't get unloaded when the room was unloaded. Hopefully fixes #136
This commit is contained in:
@ -51,6 +51,7 @@ type MessageView struct {
|
||||
|
||||
// Used for locking
|
||||
loadingMessages int32
|
||||
historyLoadPtr uint64
|
||||
|
||||
_widestSender uint32
|
||||
_prevWidestSender uint32
|
||||
@ -109,6 +110,7 @@ func (view *MessageView) Unload() {
|
||||
view.ScrollOffset = 0
|
||||
view._widestSender = 5
|
||||
view.prevMsgCount = -1
|
||||
view.historyLoadPtr = 0
|
||||
view.messagesLock.Unlock()
|
||||
view.msgBufferLock.Unlock()
|
||||
view.messageIDLock.Unlock()
|
||||
|
@ -461,13 +461,15 @@ func (view *MainView) LoadHistory(roomID id.RoomID) {
|
||||
// Update the "Loading more messages..." text
|
||||
view.parent.Render()
|
||||
|
||||
history, err := view.matrix.GetHistory(roomView.Room, 50)
|
||||
history, newLoadPtr, err := view.matrix.GetHistory(roomView.Room, 50, msgView.historyLoadPtr)
|
||||
if err != nil {
|
||||
roomView.AddServiceMessage("Failed to fetch history")
|
||||
debug.Print("Failed to fetch history for", roomView.Room.ID, err)
|
||||
view.parent.Render()
|
||||
return
|
||||
}
|
||||
//debug.Printf("Load pointer %d -> %d", msgView.historyLoadPtr, newLoadPtr)
|
||||
msgView.historyLoadPtr = newLoadPtr
|
||||
for _, evt := range history {
|
||||
roomView.AddHistoryEvent(evt)
|
||||
}
|
||||
|
Reference in New Issue
Block a user