Skip to content

Commit dcae1dc

Browse files
committed
connection: emit networkError in all cases
1 parent 0e10076 commit dcae1dc

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

Quotient/connection.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,7 @@ void Connection::assumeIdentity(const QString& mxId, const QString& accessToken)
211211
d->completeSetup(job->userId());
212212
});
213213
connect(job, &BaseJob::failure, this, [this, job] {
214-
if (job->error() == BaseJob::StatusCode::NetworkError)
215-
emit networkError(job->errorString(), job->rawDataSample(),
216-
job->maxRetries(), -1);
217-
else
214+
if (job->error() != BaseJob::StatusCode::NetworkError)
218215
emit loginError(job->errorString(), job->rawDataSample());
219216
});
220217
});
@@ -448,11 +445,6 @@ void Connection::sync(int timeout)
448445
d->syncJob = nullptr;
449446
emit syncDone();
450447
});
451-
connect(job, &SyncJob::retryScheduled, this,
452-
[this, job](int retriesTaken, int nextInMilliseconds) {
453-
emit networkError(job->errorString(), job->rawDataSample(),
454-
retriesTaken, nextInMilliseconds);
455-
});
456448
connect(job, &SyncJob::failure, this, [this, job] {
457449
// SyncJob persists with retries on transient errors; if it fails,
458450
// there's likely something serious enough to stop the loop.
@@ -1624,6 +1616,11 @@ BaseJob* Connection::run(BaseJob* job, RunningPolicy runningPolicy)
16241616
// Reparent to protect from #397, #398 and to prevent BaseJob* from being
16251617
// garbage-collected if made by or returned to QML/JavaScript.
16261618
job->setParent(this);
1619+
connect(job, &BaseJob::retryScheduled, this,
1620+
[this, job](int retriesTaken, int nextInMilliseconds) {
1621+
emit networkError(job->errorString(), job->rawDataSample(),
1622+
retriesTaken, nextInMilliseconds);
1623+
});
16271624
connect(job, &BaseJob::failure, this, &Connection::requestFailed);
16281625
job->initiate(d->data.get(), runningPolicy & BackgroundRequest);
16291626
return job;

Quotient/connection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,12 +766,12 @@ public Q_SLOTS:
766766
void stateChanged();
767767
void loginError(QString message, QString details);
768768

769-
//! \brief A network request (job) started by callApi() has failed
769+
//! \brief A network request (job) started by run() (including callApi()) has failed
770770
//! \param request the pointer to the failed job
771771
//! \sa callApi
772772
void requestFailed(Quotient::BaseJob* request);
773773

774-
//! \brief A network request (job) failed due to network problems
774+
//! \brief A network request (job) started by run() (including callAPI()) failed due to network problems
775775
//!
776776
//! This is _only_ emitted when the job will retry on its own;
777777
//! once it gives up, requestFailed() will be emitted.

0 commit comments

Comments
 (0)