only display changed network errors during validation of connection
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
parent
b45376d579
commit
6d1f028ed8
|
@ -117,7 +117,6 @@ void AccountState::setState(State state)
|
|||
|
||||
if (_state == SignedOut) {
|
||||
_connectionStatus = ConnectionValidator::Undefined;
|
||||
_connectionErrors.clear();
|
||||
} else if (oldState == SignedOut && _state == Disconnected) {
|
||||
// If we stop being voluntarily signed-out, try to connect and
|
||||
// auth right now!
|
||||
|
@ -297,8 +296,9 @@ void AccountState::checkConnectivity()
|
|||
return;
|
||||
}
|
||||
|
||||
auto *conValidator = new ConnectionValidator(AccountStatePtr(this));
|
||||
auto *conValidator = new ConnectionValidator(AccountStatePtr(this), _connectionErrors);
|
||||
_connectionValidator = conValidator;
|
||||
_connectionErrors.clear();
|
||||
connect(conValidator, &ConnectionValidator::connectionResult,
|
||||
this, &AccountState::slotConnectionValidatorResult);
|
||||
if (isConnected()) {
|
||||
|
|
|
@ -37,8 +37,9 @@ Q_LOGGING_CATEGORY(lcConnectionValidator, "nextcloud.sync.connectionvalidator",
|
|||
// This makes sure we get tried often enough without "ConnectionValidator already running"
|
||||
static qint64 timeoutToUseMsec = qMax(1000, ConnectionValidator::DefaultCallingIntervalMsec - 5 * 1000);
|
||||
|
||||
ConnectionValidator::ConnectionValidator(AccountStatePtr accountState, QObject *parent)
|
||||
ConnectionValidator::ConnectionValidator(AccountStatePtr accountState, const QStringList &previousErrors, QObject *parent)
|
||||
: QObject(parent)
|
||||
, _previousErrors(previousErrors)
|
||||
, _accountState(accountState)
|
||||
, _account(accountState->account())
|
||||
{
|
||||
|
@ -331,7 +332,7 @@ void ConnectionValidator::reportResult(Status status)
|
|||
emit connectionResult(status, _errors);
|
||||
|
||||
// notify user of errors
|
||||
if (!_errors.isEmpty()) {
|
||||
if (!_errors.isEmpty() && _previousErrors != _errors) {
|
||||
showSystrayErrorMessage();
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,9 @@ class ConnectionValidator : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConnectionValidator(AccountStatePtr accountState, QObject *parent = nullptr);
|
||||
explicit ConnectionValidator(AccountStatePtr accountState,
|
||||
const QStringList &previousErrors,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
enum Status {
|
||||
Undefined,
|
||||
|
@ -142,6 +144,7 @@ private:
|
|||
*/
|
||||
bool setAndCheckServerVersion(const QString &version);
|
||||
|
||||
const QStringList _previousErrors;
|
||||
QStringList _errors;
|
||||
AccountStatePtr _accountState;
|
||||
AccountPtr _account;
|
||||
|
|
Loading…
Reference in New Issue