Use timeout of 0 on first event call

This commit is contained in:
Martchus 2018-10-25 18:24:31 +02:00
parent 049234286c
commit bb6825aa4c
1 changed files with 8 additions and 0 deletions

View File

@ -995,6 +995,10 @@ void SyncthingConnection::requestDiskEvents(int limit)
if (m_lastDiskEventId) {
query.addQueryItem(QStringLiteral("since"), QString::number(m_lastDiskEventId));
}
// force to return immediately after the first call
if (!m_hasDiskEvents) {
query.addQueryItem(QStringLiteral("timeout"), QStringLiteral("0"));
}
QObject::connect(
m_diskEventsReply = requestData(QStringLiteral("events/disk"), query), &QNetworkReply::finished, this, &SyncthingConnection::readDiskEvents);
}
@ -1036,6 +1040,10 @@ void SyncthingConnection::requestEvents()
if (m_lastEventId) {
query.addQueryItem(QStringLiteral("since"), QString::number(m_lastEventId));
}
// force to return immediately after the first call
if (!m_hasEvents) {
query.addQueryItem(QStringLiteral("timeout"), QStringLiteral("0"));
}
QObject::connect(m_eventsReply = requestData(QStringLiteral("events"), query), &QNetworkReply::finished, this, &SyncthingConnection::readEvents);
}