mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Reduce timeline flickering
This commit is contained in:
parent
76ddfb792b
commit
ac8e42b926
2 changed files with 24 additions and 18 deletions
|
@ -143,7 +143,6 @@ private:
|
||||||
bool isInitialized = false;
|
bool isInitialized = false;
|
||||||
bool isTimelineFinished = false;
|
bool isTimelineFinished = false;
|
||||||
bool isInitialSync = true;
|
bool isInitialSync = true;
|
||||||
bool isPaginationScrollPending_ = false;
|
|
||||||
|
|
||||||
const int SCROLL_BAR_GAP = 400;
|
const int SCROLL_BAR_GAP = 400;
|
||||||
|
|
||||||
|
|
|
@ -85,9 +85,6 @@ TimelineView::sliderRangeChanged(int min, int max)
|
||||||
if (max - scroll_area_->verticalScrollBar()->value() < SCROLL_BAR_GAP)
|
if (max - scroll_area_->verticalScrollBar()->value() < SCROLL_BAR_GAP)
|
||||||
scroll_area_->verticalScrollBar()->setValue(max);
|
scroll_area_->verticalScrollBar()->setValue(max);
|
||||||
|
|
||||||
if (isPaginationScrollPending_) {
|
|
||||||
isPaginationScrollPending_ = false;
|
|
||||||
|
|
||||||
int currentHeight = scroll_widget_->size().height();
|
int currentHeight = scroll_widget_->size().height();
|
||||||
int diff = currentHeight - oldHeight_;
|
int diff = currentHeight - oldHeight_;
|
||||||
int newPosition = oldPosition_ + diff;
|
int newPosition = oldPosition_ + diff;
|
||||||
|
@ -98,7 +95,6 @@ TimelineView::sliderRangeChanged(int min, int max)
|
||||||
|
|
||||||
scroll_area_->verticalScrollBar()->setValue(newPosition);
|
scroll_area_->verticalScrollBar()->setValue(newPosition);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelineView::fetchHistory()
|
TimelineView::fetchHistory()
|
||||||
|
@ -173,6 +169,9 @@ TimelineView::addBackwardsEvents(const QString &room_id, const RoomMessages &msg
|
||||||
isTimelineFinished = false;
|
isTimelineFinished = false;
|
||||||
QList<TimelineItem *> items;
|
QList<TimelineItem *> items;
|
||||||
|
|
||||||
|
scroll_widget_->adjustSize();
|
||||||
|
scroll_widget_->update();
|
||||||
|
|
||||||
// Parse in reverse order to determine where we should not show sender's
|
// Parse in reverse order to determine where we should not show sender's
|
||||||
// name.
|
// name.
|
||||||
auto ii = msgs.chunk().size();
|
auto ii = msgs.chunk().size();
|
||||||
|
@ -197,7 +196,6 @@ TimelineView::addBackwardsEvents(const QString &room_id, const RoomMessages &msg
|
||||||
|
|
||||||
prev_batch_token_ = msgs.end();
|
prev_batch_token_ = msgs.end();
|
||||||
isPaginationInProgress_ = false;
|
isPaginationInProgress_ = false;
|
||||||
isPaginationScrollPending_ = true;
|
|
||||||
|
|
||||||
// Exclude the top stretch.
|
// Exclude the top stretch.
|
||||||
if (!msgs.chunk().isEmpty() && scroll_layout_->count() > 1)
|
if (!msgs.chunk().isEmpty() && scroll_layout_->count() > 1)
|
||||||
|
@ -465,6 +463,9 @@ TimelineView::addTimelineItem(TimelineItem *item, TimelineDirection direction)
|
||||||
scroll_layout_->addWidget(item);
|
scroll_layout_->addWidget(item);
|
||||||
else
|
else
|
||||||
scroll_layout_->insertWidget(1, item);
|
scroll_layout_->insertWidget(1, item);
|
||||||
|
|
||||||
|
scroll_widget_->adjustSize();
|
||||||
|
scroll_widget_->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -488,6 +489,9 @@ TimelineView::addUserMessage(matrix::events::MessageEventType ty, const QString
|
||||||
TimelineItem *view_item = new TimelineItem(ty, user_id, body, with_sender, scroll_widget_);
|
TimelineItem *view_item = new TimelineItem(ty, user_id, body, with_sender, scroll_widget_);
|
||||||
scroll_layout_->addWidget(view_item);
|
scroll_layout_->addWidget(view_item);
|
||||||
|
|
||||||
|
scroll_widget_->adjustSize();
|
||||||
|
scroll_widget_->update();
|
||||||
|
|
||||||
lastSender_ = user_id;
|
lastSender_ = user_id;
|
||||||
|
|
||||||
PendingMessage message(txn_id, body, "", view_item);
|
PendingMessage message(txn_id, body, "", view_item);
|
||||||
|
@ -506,6 +510,9 @@ TimelineView::addUserMessage(const QString &url, const QString &filename, int tx
|
||||||
TimelineItem *view_item = new TimelineItem(image, user_id, with_sender, scroll_widget_);
|
TimelineItem *view_item = new TimelineItem(image, user_id, with_sender, scroll_widget_);
|
||||||
scroll_layout_->addWidget(view_item);
|
scroll_layout_->addWidget(view_item);
|
||||||
|
|
||||||
|
scroll_widget_->adjustSize();
|
||||||
|
scroll_widget_->update();
|
||||||
|
|
||||||
lastSender_ = user_id;
|
lastSender_ = user_id;
|
||||||
|
|
||||||
PendingMessage message(txn_id, url, "", view_item);
|
PendingMessage message(txn_id, url, "", view_item);
|
||||||
|
|
Loading…
Reference in a new issue