summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-20 11:28:02 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-20 11:28:02 +0200
commit524e405f645edb6231f9b16fafc1f9ca36af8237 (patch)
tree471692764999bc32a3e1e5404b1466a2b3a46847 /common
parent256fe3fc561f1690e5c29640b9081e805ceb5532 (diff)
downloadsink-524e405f645edb6231f9b16fafc1f9ca36af8237.tar.gz
sink-524e405f645edb6231f9b16fafc1f9ca36af8237.zip
Avoid notifcations for requests that do nothing, progress with folderid
Diffstat (limited to 'common')
-rw-r--r--common/changereplay.h2
-rw-r--r--common/synchronizer.cpp19
-rw-r--r--common/synchronizer.h2
3 files changed, 13 insertions, 10 deletions
diff --git a/common/changereplay.h b/common/changereplay.h
index c509735..22e26a5 100644
--- a/common/changereplay.h
+++ b/common/changereplay.h
@@ -54,7 +54,7 @@ public slots:
54protected: 54protected:
55 virtual KAsync::Job<void> replay(const QByteArray &type, const QByteArray &key, const QByteArray &value) = 0; 55 virtual KAsync::Job<void> replay(const QByteArray &type, const QByteArray &key, const QByteArray &value) = 0;
56 virtual bool canReplay(const QByteArray &type, const QByteArray &key, const QByteArray &value) = 0; 56 virtual bool canReplay(const QByteArray &type, const QByteArray &key, const QByteArray &value) = 0;
57 virtual void reportProgress(int progress, int total){}; 57 virtual void reportProgress(int progress, int total, const QByteArrayList &applicableEntities = {}){};
58 Sink::Storage::DataStore mStorage; 58 Sink::Storage::DataStore mStorage;
59 KAsync::Job<void> replayNextRevision(); 59 KAsync::Job<void> replayNextRevision();
60 60
diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp
index b9decbd..3ef7eb7 100644
--- a/common/synchronizer.cpp
+++ b/common/synchronizer.cpp
@@ -315,11 +315,17 @@ void Synchronizer::emitProgressNotification(Notification::NoticationType type, i
315 emit notify(n); 315 emit notify(n);
316} 316}
317 317
318void Synchronizer::reportProgress(int progress, int total) 318void Synchronizer::reportProgress(int progress, int total, const QByteArrayList &entities)
319{ 319{
320 if (progress > 0 && total > 0) { 320 if (progress > 0 && total > 0) {
321 SinkLogCtx(mLogCtx) << "Progress: " << progress << " out of " << total; 321 SinkLogCtx(mLogCtx) << "Progress: " << progress << " out of " << total << mCurrentRequest.requestId << mCurrentRequest.applicableEntities;
322 emitProgressNotification(Notification::Progress, progress, total, mCurrentRequest.requestId, mCurrentRequest.applicableEntities); 322 const auto applicableEntities = [&] {
323 if (entities.isEmpty()) {
324 return mCurrentRequest.applicableEntities;
325 }
326 return entities;
327 }();
328 emitProgressNotification(Notification::Progress, progress, total, mCurrentRequest.requestId, applicableEntities);
323 } 329 }
324} 330}
325 331
@@ -371,6 +377,7 @@ KAsync::Job<void> Synchronizer::processRequest(const SyncRequest &request)
371 } else if (request.requestType == Synchronizer::SyncRequest::Synchronization) { 377 } else if (request.requestType == Synchronizer::SyncRequest::Synchronization) {
372 return KAsync::start([this, request] { 378 return KAsync::start([this, request] {
373 SinkLogCtx(mLogCtx) << "Synchronizing: " << request.query; 379 SinkLogCtx(mLogCtx) << "Synchronizing: " << request.query;
380 setBusy(true, "Synchronization has started.", request.requestId);
374 emitNotification(Notification::Info, ApplicationDomain::SyncInProgress, {}, {}, request.applicableEntities); 381 emitNotification(Notification::Info, ApplicationDomain::SyncInProgress, {}, {}, request.applicableEntities);
375 }).then(synchronizeWithSource(request.query)).then([this] { 382 }).then(synchronizeWithSource(request.query)).then([this] {
376 //Commit after every request, so implementations only have to commit more if they add a lot of data. 383 //Commit after every request, so implementations only have to commit more if they add a lot of data.
@@ -408,6 +415,7 @@ KAsync::Job<void> Synchronizer::processRequest(const SyncRequest &request)
408 return KAsync::null(); 415 return KAsync::null();
409 } else { 416 } else {
410 return KAsync::start([this, request] { 417 return KAsync::start([this, request] {
418 setBusy(true, "ChangeReplay has started.", request.requestId);
411 SinkLogCtx(mLogCtx) << "Replaying changes."; 419 SinkLogCtx(mLogCtx) << "Replaying changes.";
412 }) 420 })
413 .then(replayNextRevision()) 421 .then(replayNextRevision())
@@ -479,11 +487,6 @@ KAsync::Job<void> Synchronizer::processSyncQueue()
479 mMessageQueue->startTransaction(); 487 mMessageQueue->startTransaction();
480 mEntityStore->startTransaction(Sink::Storage::DataStore::ReadOnly); 488 mEntityStore->startTransaction(Sink::Storage::DataStore::ReadOnly);
481 mSyncInProgress = true; 489 mSyncInProgress = true;
482 if (request.requestType == Synchronizer::SyncRequest::Synchronization) {
483 setBusy(true, "Synchronization has started.", request.requestId);
484 } else if (request.requestType == Synchronizer::SyncRequest::ChangeReplay) {
485 setBusy(true, "ChangeReplay has started.", request.requestId);
486 }
487 mCurrentRequest = request; 490 mCurrentRequest = request;
488 }) 491 })
489 .then(processRequest(request)) 492 .then(processRequest(request))
diff --git a/common/synchronizer.h b/common/synchronizer.h
index 935c139..cc082be 100644
--- a/common/synchronizer.h
+++ b/common/synchronizer.h
@@ -197,7 +197,7 @@ protected:
197 /** 197 /**
198 * Report progress for current task 198 * Report progress for current task
199 */ 199 */
200 virtual void reportProgress(int progress, int total) Q_DECL_OVERRIDE; 200 virtual void reportProgress(int progress, int total, const QByteArrayList &entities = {}) Q_DECL_OVERRIDE;
201 201
202protected: 202protected:
203 Sink::Log::Context mLogCtx; 203 Sink::Log::Context mLogCtx;