summary refs log tree commit diff
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-08-31 18:34:54 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-08-31 18:34:54 +0300
commite9a8e51208e168d1bad3220004b31117d27f4ed9 (patch)
treed250fb59aeea7ba485d2b440d804528b27ada81c
parentRetry initial sync on generic network errors (#422) (diff)
downloadnheko-e9a8e51208e168d1bad3220004b31117d27f4ed9.tar.xz
Guard against flickering for items added to the top of the timeline
-rw-r--r--src/timeline/TimelineView.cpp8
-rw-r--r--src/timeline/TimelineView.h11
2 files changed, 12 insertions, 7 deletions
diff --git a/src/timeline/TimelineView.cpp b/src/timeline/TimelineView.cpp
index e6c36165..887d4d4f 100644
--- a/src/timeline/TimelineView.cpp
+++ b/src/timeline/TimelineView.cpp
@@ -634,11 +634,11 @@ TimelineView::addTimelineItem(QWidget *item, TimelineDirection direction)
                                 auto separator = new DateSeparator(newDate, this);
 
                                 if (separator)
-                                        pushTimelineItem(separator);
+                                        pushTimelineItem(separator, direction);
                         }
                 }
 
-                pushTimelineItem(item);
+                pushTimelineItem(item, direction);
         } else {
                 if (scroll_layout_->count() > 0) {
                         const auto firstItem = scroll_layout_->itemAt(0)->widget();
@@ -650,12 +650,12 @@ TimelineView::addTimelineItem(QWidget *item, TimelineDirection direction)
                                         auto separator = new DateSeparator(oldDate);
 
                                         if (separator)
-                                                scroll_layout_->insertWidget(0, separator);
+                                                pushTimelineItem(separator, direction);
                                 }
                         }
                 }
 
-                scroll_layout_->insertWidget(0, item);
+                pushTimelineItem(item, direction);
         }
 }
 
diff --git a/src/timeline/TimelineView.h b/src/timeline/TimelineView.h
index 46facd7e..c1d36cf8 100644
--- a/src/timeline/TimelineView.h
+++ b/src/timeline/TimelineView.h
@@ -194,17 +194,22 @@ private:
         void getMessages();
         //! HACK: Fixing layout flickering when adding to the bottom
         //! of the timeline.
-        void pushTimelineItem(QWidget *item)
+        void pushTimelineItem(QWidget *item, TimelineDirection dir)
         {
                 setUpdatesEnabled(false);
                 item->hide();
-                scroll_layout_->addWidget(item);
+
+                if (dir == TimelineDirection::Top)
+                        scroll_layout_->insertWidget(0, item);
+                else
+                        scroll_layout_->addWidget(item);
+
                 QTimer::singleShot(0, this, [item, this]() {
                         item->show();
                         item->adjustSize();
                         setUpdatesEnabled(true);
                 });
-        };
+        }
 
         //! Decides whether or not to show or hide the scroll down button.
         void toggleScrollDownButton();