mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 14:18:49 +03:00
Prevent FOUC
This commit is contained in:
parent
bc4b47a5e3
commit
6e1285bb0e
5 changed files with 34 additions and 2 deletions
|
@ -96,6 +96,7 @@ private:
|
||||||
TextInputWidget *text_input_;
|
TextInputWidget *text_input_;
|
||||||
TypingDisplay *typingDisplay_;
|
TypingDisplay *typingDisplay_;
|
||||||
|
|
||||||
|
QTimer *consensusTimer_;
|
||||||
QTimer *sync_timer_;
|
QTimer *sync_timer_;
|
||||||
int sync_interval_;
|
int sync_interval_;
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,9 @@ public slots:
|
||||||
// Add old events at the top of the timeline.
|
// Add old events at the top of the timeline.
|
||||||
void addBackwardsEvents(const QString &room_id, const RoomMessages &msgs);
|
void addBackwardsEvents(const QString &room_id, const RoomMessages &msgs);
|
||||||
|
|
||||||
|
// Whether or not the initial batch has been loaded.
|
||||||
|
bool hasLoaded();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void updateLastTimelineMessage(const QString &user, const DescInfo &info);
|
void updateLastTimelineMessage(const QString &user, const DescInfo &info);
|
||||||
|
|
||||||
|
@ -163,3 +166,9 @@ TimelineView::isDuplicate(const QString &event_id)
|
||||||
{
|
{
|
||||||
return eventIds_.contains(event_id);
|
return eventIds_.contains(event_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
TimelineView::hasLoaded()
|
||||||
|
{
|
||||||
|
return scroll_layout_->count() > 1 || isTimelineFinished;
|
||||||
|
}
|
||||||
|
|
|
@ -47,6 +47,9 @@ public:
|
||||||
void sync(const Rooms &rooms);
|
void sync(const Rooms &rooms);
|
||||||
void clearAll();
|
void clearAll();
|
||||||
|
|
||||||
|
// Check if all the timelines have been loaded.
|
||||||
|
bool hasLoaded() const;
|
||||||
|
|
||||||
static QString chooseRandomColor();
|
static QString chooseRandomColor();
|
||||||
static QString displayName(const QString &userid);
|
static QString displayName(const QString &userid);
|
||||||
|
|
||||||
|
|
|
@ -213,6 +213,15 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent)
|
||||||
this,
|
this,
|
||||||
SLOT(removeRoom(const QString &)));
|
SLOT(removeRoom(const QString &)));
|
||||||
|
|
||||||
|
consensusTimer_ = new QTimer(this);
|
||||||
|
connect(consensusTimer_, &QTimer::timeout, this, [=]() {
|
||||||
|
if (view_manager_->hasLoaded()) {
|
||||||
|
// Remove the spinner overlay.
|
||||||
|
emit contentLoaded();
|
||||||
|
consensusTimer_->stop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
AvatarProvider::init(client);
|
AvatarProvider::init(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,8 +563,8 @@ ChatPage::loadStateFromCache()
|
||||||
// Initialize room list from the restored state and settings.
|
// Initialize room list from the restored state and settings.
|
||||||
room_list_->setInitialRooms(settingsManager_, state_manager_);
|
room_list_->setInitialRooms(settingsManager_, state_manager_);
|
||||||
|
|
||||||
// Remove the spinner overlay.
|
// Check periodically if the timelines have been loaded.
|
||||||
emit contentLoaded();
|
consensusTimer_->start(500);
|
||||||
|
|
||||||
sync_timer_->start(sync_interval_);
|
sync_timer_->start(sync_interval_);
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,3 +256,13 @@ TimelineViewManager::displayName(const QString &userid)
|
||||||
|
|
||||||
return userid;
|
return userid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
TimelineViewManager::hasLoaded() const
|
||||||
|
{
|
||||||
|
for (const auto &view : views_)
|
||||||
|
if (!view->hasLoaded())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue