mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Remove ui flickering when adding new timeline events
This commit is contained in:
parent
47d1546adf
commit
3cae6c3983
4 changed files with 14 additions and 15 deletions
2
Makefile
2
Makefile
|
@ -9,7 +9,7 @@ debug:
|
||||||
@cmake --build build
|
@cmake --build build
|
||||||
|
|
||||||
release-debug:
|
release-debug:
|
||||||
@cmake -DBUILD_TESTS=OFF -H. -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo
|
@cmake -DBUILD_TESTS=OFF -H. -GNinja -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||||
@cmake --build build
|
@cmake --build build
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
|
|
@ -145,7 +145,7 @@ private:
|
||||||
bool isTimelineFinished = false;
|
bool isTimelineFinished = false;
|
||||||
bool isInitialSync = true;
|
bool isInitialSync = true;
|
||||||
|
|
||||||
const int SCROLL_BAR_GAP = 400;
|
const int SCROLL_BAR_GAP = 200;
|
||||||
|
|
||||||
QTimer *paginationTimer_;
|
QTimer *paginationTimer_;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
|
@ -413,6 +414,8 @@ ChatPage::syncCompleted(const SyncResponse &response)
|
||||||
|
|
||||||
if (it.key() == current_room_)
|
if (it.key() == current_room_)
|
||||||
changeTopRoomInfo(it.key());
|
changeTopRoomInfo(it.key());
|
||||||
|
|
||||||
|
QApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto leave = response.rooms().leave();
|
auto leave = response.rooms().leave();
|
||||||
|
@ -472,6 +475,8 @@ ChatPage::initialSyncCompleted(const SyncResponse &response)
|
||||||
if (!url.toString().isEmpty())
|
if (!url.toString().isEmpty())
|
||||||
AvatarProvider::setAvatarUrl(uid, url);
|
AvatarProvider::setAvatarUrl(uid, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
@ -96,9 +97,6 @@ TimelineView::sliderRangeChanged(int min, int max)
|
||||||
newPosition = max;
|
newPosition = max;
|
||||||
|
|
||||||
scroll_area_->verticalScrollBar()->setValue(newPosition);
|
scroll_area_->verticalScrollBar()->setValue(newPosition);
|
||||||
|
|
||||||
scroll_widget_->adjustSize();
|
|
||||||
scroll_widget_->update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -174,9 +172,6 @@ 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();
|
||||||
|
@ -199,6 +194,8 @@ TimelineView::addBackwardsEvents(const QString &room_id, const RoomMessages &msg
|
||||||
for (const auto &item : items)
|
for (const auto &item : items)
|
||||||
addTimelineItem(item, TimelineDirection::Top);
|
addTimelineItem(item, TimelineDirection::Top);
|
||||||
|
|
||||||
|
QApplication::processEvents();
|
||||||
|
|
||||||
prev_batch_token_ = msgs.end();
|
prev_batch_token_ = msgs.end();
|
||||||
isPaginationInProgress_ = false;
|
isPaginationInProgress_ = false;
|
||||||
|
|
||||||
|
@ -352,6 +349,8 @@ TimelineView::addEvents(const Timeline &timeline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QApplication::processEvents();
|
||||||
|
|
||||||
if (isInitialSync) {
|
if (isInitialSync) {
|
||||||
prev_batch_token_ = timeline.previousBatch();
|
prev_batch_token_ = timeline.previousBatch();
|
||||||
isInitialSync = false;
|
isInitialSync = false;
|
||||||
|
@ -468,9 +467,6 @@ 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
|
||||||
|
@ -494,8 +490,7 @@ 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();
|
QApplication::processEvents();
|
||||||
scroll_widget_->update();
|
|
||||||
|
|
||||||
lastSender_ = user_id;
|
lastSender_ = user_id;
|
||||||
|
|
||||||
|
@ -515,8 +510,7 @@ 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();
|
QApplication::processEvents();
|
||||||
scroll_widget_->update();
|
|
||||||
|
|
||||||
lastSender_ = user_id;
|
lastSender_ = user_id;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue