mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 04:55:48 +03:00
Make sure we do not renotify notifications when we have received the same etag as during the last check
Do this regardless of what the server's response is Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
804cb1d4d6
commit
291f0c8c85
2 changed files with 12 additions and 0 deletions
|
@ -78,6 +78,17 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In theory the server should five us a 304 Not Modified if there are no new notifications.
|
||||||
|
// But in practice, the server doesn't always do that. So we need to compare the ETag headers.
|
||||||
|
const auto postFetchEtagHeader = _accountState->notificationsEtagResponseHeader();
|
||||||
|
if (_preFetchEtagHeader == postFetchEtagHeader) {
|
||||||
|
qCInfo(lcServerNotification) << "Notifications ETag header is the same as before, no new notifications.";
|
||||||
|
deleteLater();
|
||||||
|
emit jobFinished();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_preFetchEtagHeader = postFetchEtagHeader;
|
||||||
|
|
||||||
auto notifies = json.object().value("ocs").toObject().value("data").toArray();
|
auto notifies = json.object().value("ocs").toObject().value("data").toArray();
|
||||||
|
|
||||||
auto *ai = qvariant_cast<AccountState *>(sender()->property(propertyAccountStateC));
|
auto *ai = qvariant_cast<AccountState *>(sender()->property(propertyAccountStateC));
|
||||||
|
|
|
@ -30,6 +30,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
QPointer<JsonApiJob> _notificationJob;
|
QPointer<JsonApiJob> _notificationJob;
|
||||||
AccountState *_accountState;
|
AccountState *_accountState;
|
||||||
|
QString _preFetchEtagHeader;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue