From c8dc0c075497ca8f174b738ee4253ca282cbec8c Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 6 Aug 2018 21:17:01 +0900 Subject: Room: addedMessages passes timeline indices --- lib/room.cpp | 13 ++++++------- lib/room.h | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/room.cpp b/lib/room.cpp index e8f67f3f..27f54ddb 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -1599,12 +1599,11 @@ void Room::Private::addNewMessageEvents(RoomEvents&& events) { RoomEventsRange eventsSpan { it, nextPending }; emit q->aboutToAddNewMessages(eventsSpan); - if (auto insertedSize = moveEventsToTimeline(eventsSpan, Newer)) - { - totalInserted += insertedSize; - q->onAddNewTimelineEvents(timeline.cend() - insertedSize); - } - emit q->addedMessages(); + auto insertedSize = moveEventsToTimeline(eventsSpan, Newer); + totalInserted += insertedSize; + auto firstInserted = timeline.cend() - insertedSize; + q->onAddNewTimelineEvents(firstInserted); + emit q->addedMessages(firstInserted->index(), timeline.back().index()); } if (nextPending == newEnd) break; @@ -1669,7 +1668,7 @@ void Room::Private::addHistoricalMessageEvents(RoomEvents&& events) qCDebug(MAIN) << "Room" << displayname << "received" << insertedSize << "past events; the oldest event is now" << timeline.front(); q->onAddHistoricalTimelineEvents(from); - emit q->addedMessages(); + emit q->addedMessages(timeline.front().index(), from->index()); if (from <= q->readMarker()) updateUnreadCount(from, timeline.crend()); diff --git a/lib/room.h b/lib/room.h index 12884eb4..35263eaf 100644 --- a/lib/room.h +++ b/lib/room.h @@ -350,7 +350,7 @@ namespace QMatrixClient signals: void aboutToAddHistoricalMessages(RoomEventsRange events); void aboutToAddNewMessages(RoomEventsRange events); - void addedMessages(); + void addedMessages(int fromIndex, int toIndex); void pendingEventAboutToAdd(); void pendingEventAdded(); void pendingEventAboutToMerge(RoomEvent* serverEvent, -- cgit v1.2.3