summary refs log tree commit diff
path: root/src/TimelineView.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-08-06 18:53:31 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-08-06 18:53:31 +0300
commit146aaa87465765cd9d3153d95b0791c587902d62 (patch)
tree6850d0b1bb9de9c95f3b99d7b1a4e3f622f4e6f8 /src/TimelineView.cc
parentAvoid header conflict (second attempt) (diff)
downloadnheko-146aaa87465765cd9d3153d95b0791c587902d62.tar.xz
Display the most recent message instead of the topic
closes #11
Diffstat (limited to 'src/TimelineView.cc')
-rw-r--r--src/TimelineView.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/TimelineView.cc b/src/TimelineView.cc

index 5968f9cf..be2fc067 100644 --- a/src/TimelineView.cc +++ b/src/TimelineView.cc
@@ -179,6 +179,10 @@ void TimelineView::addBackwardsEvents(const QString &room_id, const RoomMessages prev_batch_token_ = msgs.end(); isPaginationInProgress_ = false; isPaginationScrollPending_ = true; + + // Exclude the top stretch. + if (!msgs.chunk().isEmpty() && scroll_layout_->count() > 1) + notifyForLastEvent(); } TimelineItem *TimelineView::parseMessageEvent(const QJsonObject &event, TimelineDirection direction) @@ -295,6 +299,10 @@ int TimelineView::addEvents(const Timeline &timeline) client_->messages(room_id_, prev_batch_token_); } + // Exclude the top stretch. + if (!timeline.events().isEmpty() && scroll_layout_->count() > 1) + notifyForLastEvent(); + return message_count; } @@ -441,3 +449,14 @@ void TimelineView::addUserTextMessage(const QString &body, int txn_id) pending_msgs_.push_back(message); } + +void TimelineView::notifyForLastEvent() +{ + auto lastItem = scroll_layout_->itemAt(scroll_layout_->count() - 1); + auto *lastTimelineItem = qobject_cast<TimelineItem *>(lastItem->widget()); + + if (lastTimelineItem) + emit updateLastTimelineMessage(room_id_, lastTimelineItem->descriptionMessage()); + else + qWarning() << "Cast to TimelineView failed" << room_id_; +}