From 1d0bf08a1cc1c1091f195500546a1feec9c84997 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 19 Nov 2018 14:13:51 +0100 Subject: [PATCH] Do not fetch activities if they are not enabled Fixes #788 Fixes #834 If the activity app is not enabled we should not try to fetch the activities at all. Signed-off-by: Roeland Jago Douma --- src/gui/activitylistmodel.cpp | 16 +++++++++++++--- src/gui/activitylistmodel.h | 1 + src/libsync/capabilities.cpp | 4 ++++ src/libsync/capabilities.h | 3 +++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/gui/activitylistmodel.cpp b/src/gui/activitylistmodel.cpp index d8bbbeea8..d4f993b55 100644 --- a/src/gui/activitylistmodel.cpp +++ b/src/gui/activitylistmodel.cpp @@ -291,18 +291,28 @@ void ActivityListModel::combineActivityLists() endInsertRows(); } +bool ActivityListModel::canFetchActivities() const { + return _accountState->isConnected() && _accountState->account()->capabilities().hasActivities(); +} + void ActivityListModel::fetchMore(const QModelIndex &) { - if (_accountState->isConnected()) { - _activityLists = ActivityList(); + _activityLists = ActivityList(); + if (canFetchActivities()) { startFetchJob(); + } else { + combineActivityLists(); } } void ActivityListModel::slotRefreshActivity() { _activityLists.clear(); - startFetchJob(); + if (canFetchActivities()) { + startFetchJob(); + } else { + combineActivityLists(); + } } void ActivityListModel::slotRemoveAccount() diff --git a/src/gui/activitylistmodel.h b/src/gui/activitylistmodel.h index 952dc82d5..9b66da135 100644 --- a/src/gui/activitylistmodel.h +++ b/src/gui/activitylistmodel.h @@ -67,6 +67,7 @@ signals: private: void startFetchJob(); void combineActivityLists(); + bool canFetchActivities() const; ActivityList _activityLists; ActivityList _syncFileItemLists; diff --git a/src/libsync/capabilities.cpp b/src/libsync/capabilities.cpp index 89942885c..39df7d167 100644 --- a/src/libsync/capabilities.cpp +++ b/src/libsync/capabilities.cpp @@ -103,6 +103,10 @@ bool Capabilities::isValid() const return !_capabilities.isEmpty(); } +bool Capabilities::hasActivities() const { + return _capabilities.contains("activity"); +} + QList Capabilities::supportedChecksumTypes() const { QList list; diff --git a/src/libsync/capabilities.h b/src/libsync/capabilities.h index 88ad84c11..8f8fd826a 100644 --- a/src/libsync/capabilities.h +++ b/src/libsync/capabilities.h @@ -59,6 +59,9 @@ public: /// returns true if the capabilities are loaded already. bool isValid() const; + /// return true if the activity app is enabled + bool hasActivities() const; + /** * Returns the checksum types the server understands. *