mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 14:18:49 +03:00
parent
7fc33a71fd
commit
0f62cba498
4 changed files with 19 additions and 8 deletions
|
@ -128,7 +128,7 @@ private:
|
|||
template<class Collection>
|
||||
void updateUserMetadata(const std::vector<Collection> &collection);
|
||||
|
||||
void retryInitialSync();
|
||||
void retryInitialSync(int status_code = -1);
|
||||
//! Update the room with the new notification count.
|
||||
void updateRoomNotificationCount(const QString &room_id, uint16_t notification_count);
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ signals:
|
|||
void getOwnProfileResponse(const QUrl &avatar_url, const QString &display_name);
|
||||
void getOwnCommunitiesResponse(const QList<QString> &own_communities);
|
||||
void initialSyncCompleted(const mtx::responses::Sync &response);
|
||||
void initialSyncFailed();
|
||||
void initialSyncFailed(int status_code = -1);
|
||||
void syncCompleted(const mtx::responses::Sync &response);
|
||||
void syncFailed(const QString &msg);
|
||||
void joinFailed(const QString &msg);
|
||||
|
|
|
@ -361,7 +361,7 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client,
|
|||
});
|
||||
|
||||
initialSyncTimer_ = new QTimer(this);
|
||||
connect(initialSyncTimer_, &QTimer::timeout, this, &ChatPage::retryInitialSync);
|
||||
connect(initialSyncTimer_, &QTimer::timeout, this, [this]() { retryInitialSync(); });
|
||||
|
||||
syncTimeoutTimer_ = new QTimer(this);
|
||||
connect(syncTimeoutTimer_, &QTimer::timeout, this, [this]() {
|
||||
|
@ -965,19 +965,30 @@ ChatPage::setGroupViewState(bool isEnabled)
|
|||
}
|
||||
|
||||
void
|
||||
ChatPage::retryInitialSync()
|
||||
ChatPage::retryInitialSync(int status_code)
|
||||
{
|
||||
initialSyncTimer_->stop();
|
||||
|
||||
if (client_->getHomeServer().isEmpty()) {
|
||||
deleteConfigs();
|
||||
resetUI();
|
||||
emit showLoginPage("Sync error. Please try again.");
|
||||
return;
|
||||
}
|
||||
|
||||
qWarning() << "Retrying initial sync";
|
||||
// Retry on Bad-Gateway & Gateway-Timeout errors
|
||||
if (status_code == -1 || status_code == 504 || status_code == 502 || status_code == 524) {
|
||||
qWarning() << "retrying initial sync";
|
||||
|
||||
client_->initialSync();
|
||||
initialSyncTimer_->start(INITIAL_SYNC_RETRY_TIMEOUT);
|
||||
} else {
|
||||
// Drop into the login screen.
|
||||
deleteConfigs();
|
||||
resetUI();
|
||||
|
||||
emit showLoginPage(QString("Sync error %1. Please try again.").arg(status_code));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -401,7 +401,7 @@ MatrixClient::initialSync() noexcept
|
|||
|
||||
if (status == 0 || status >= 400) {
|
||||
qDebug() << "Error code received" << status;
|
||||
emit initialSyncFailed();
|
||||
emit initialSyncFailed(status);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue