mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
TimelineView: remove unneeded date separators when deleting a redacted message (#279)
fixes #276
This commit is contained in:
parent
d2d65b6662
commit
42733eeb86
1 changed files with 17 additions and 4 deletions
|
@ -730,15 +730,28 @@ TimelineView::removeEvent(const QString &event_id)
|
||||||
auto removedItem = eventIds_[event_id];
|
auto removedItem = eventIds_[event_id];
|
||||||
|
|
||||||
// Find the next and the previous widgets in the timeline
|
// Find the next and the previous widgets in the timeline
|
||||||
auto prevItem = qobject_cast<TimelineItem *>(relativeWidget(removedItem, -1));
|
auto prevWidget = relativeWidget(removedItem, -1);
|
||||||
auto nextItem = qobject_cast<TimelineItem *>(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 it's a TimelineItem add an avatar.
|
||||||
if (prevItem)
|
if (prevItem) {
|
||||||
prevItem->addAvatar();
|
prevItem->addAvatar();
|
||||||
|
}
|
||||||
|
|
||||||
if (nextItem)
|
if (nextItem) {
|
||||||
nextItem->addAvatar();
|
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.
|
// Finally remove the event.
|
||||||
removedItem->deleteLater();
|
removedItem->deleteLater();
|
||||||
|
|
Loading…
Reference in a new issue