diff options
author | Hawkheart <aidan.noll@gmail.com> | 2018-03-20 02:59:00 -0400 |
---|---|---|
committer | mujx <mujx@users.noreply.github.com> | 2018-03-20 08:59:00 +0200 |
commit | 42733eeb86b034f458ae354213b40b58911e4847 (patch) | |
tree | a2b4a000be9ce7a221048327eaa581de20cb8094 /src/timeline/TimelineView.cc | |
parent | More stylistic changes & dark theme tweaks (diff) | |
download | nheko-42733eeb86b034f458ae354213b40b58911e4847.tar.xz |
TimelineView: remove unneeded date separators when deleting a redacted message (#279)
fixes #276
Diffstat (limited to 'src/timeline/TimelineView.cc')
-rw-r--r-- | src/timeline/TimelineView.cc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/timeline/TimelineView.cc b/src/timeline/TimelineView.cc index c4d31f3a..ce6b061a 100644 --- a/src/timeline/TimelineView.cc +++ b/src/timeline/TimelineView.cc @@ -730,15 +730,28 @@ TimelineView::removeEvent(const QString &event_id) auto removedItem = eventIds_[event_id]; // Find the next and the previous widgets in the timeline - auto prevItem = qobject_cast<TimelineItem *>(relativeWidget(removedItem, -1)); - auto nextItem = qobject_cast<TimelineItem *>(relativeWidget(removedItem, 1)); + auto prevWidget = relativeWidget(removedItem, -1); + auto nextWidget = relativeWidget(removedItem, 1); + + // See if they are timeline items + auto prevItem = qobject_cast<TimelineItem *>(prevWidget); + auto nextItem = qobject_cast<TimelineItem *>(nextWidget); + + // ... or a date separator + auto prevLabel = qobject_cast<QLabel *>(prevWidget); // If it's a TimelineItem add an avatar. - if (prevItem) + if (prevItem) { prevItem->addAvatar(); + } - if (nextItem) + if (nextItem) { nextItem->addAvatar(); + } else if (prevLabel) { + // If there's no chat message after this, and we have a label before us, delete the + // label. + prevLabel->deleteLater(); + } // Finally remove the event. removedItem->deleteLater(); |