Update first & last sender after message deletion

fixes #282
This commit is contained in:
Konstantinos Sideris 2018-03-27 21:07:39 +03:00
parent 284d200361
commit 0a09ce0f75
2 changed files with 17 additions and 0 deletions

View file

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

View file

@ -753,6 +753,20 @@ TimelineView::removeEvent(const QString &event_id)
prevLabel->deleteLater(); 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. // Finally remove the event.
removedItem->deleteLater(); removedItem->deleteLater();
eventIds_.remove(event_id); eventIds_.remove(event_id);