Update first & last sender after message deletion

fixes #282
pull/1/head
Konstantinos Sideris 7 years ago
parent 284d200361
commit 0a09ce0f75
  1. 3
      include/timeline/TimelineView.h
  2. 14
      src/timeline/TimelineView.cc

@ -154,8 +154,11 @@ private:
TimelineEvent findFirstViewableEvent(const std::vector<TimelineEvent> &events);
TimelineEvent findLastViewableEvent(const std::vector<TimelineEvent> &events);
//! Mark the last event as read.
void readLastEvent() const;
//! Whether or not the scrollbar is visible (non-zero height).
bool isScrollbarActivated() { return scroll_area_->verticalScrollBar()->value() != 0; }
//! Retrieve the event id of the last item.
QString getLastEventId() const;
QString getEventSender(const mtx::events::collections::TimelineEvents &event) const;
mtx::events::EventType getEventType(

@ -753,6 +753,20 @@ TimelineView::removeEvent(const QString &event_id)
prevLabel->deleteLater();
}
// If we deleted the last item in the timeline...
if (!nextItem && prevItem)
lastSender_ = prevItem->descriptionMessage().userid;
// If we deleted the first item in the timeline...
if (!prevItem && nextItem)
firstSender_ = nextItem->descriptionMessage().userid;
// If we deleted the only item in the timeline...
if (!prevItem && !nextItem) {
firstSender_.clear();
lastSender_.clear();
}
// Finally remove the event.
removedItem->deleteLater();
eventIds_.remove(event_id);

Loading…
Cancel
Save