Line 0
Link Here
|
|
|
1 |
From 1d0bf08a1cc1c1091f195500546a1feec9c84997 Mon Sep 17 00:00:00 2001 |
2 |
From: Roeland Jago Douma <roeland@famdouma.nl> |
3 |
Date: Mon, 19 Nov 2018 14:13:51 +0100 |
4 |
Subject: [PATCH] Do not fetch activities if they are not enabled |
5 |
|
6 |
Fixes #788 |
7 |
Fixes #834 |
8 |
|
9 |
If the activity app is not enabled we should not try to fetch the |
10 |
activities at all. |
11 |
|
12 |
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl> |
13 |
--- |
14 |
src/gui/activitylistmodel.cpp | 16 +++++++++++++--- |
15 |
src/gui/activitylistmodel.h | 1 + |
16 |
src/libsync/capabilities.cpp | 4 ++++ |
17 |
src/libsync/capabilities.h | 3 +++ |
18 |
4 files changed, 21 insertions(+), 3 deletions(-) |
19 |
|
20 |
diff --git a/src/gui/activitylistmodel.cpp b/src/gui/activitylistmodel.cpp |
21 |
index d8bbbeea8..d4f993b55 100644 |
22 |
--- src/gui/activitylistmodel.cpp |
23 |
+++ src/gui/activitylistmodel.cpp |
24 |
@@ -291,18 +291,28 @@ void ActivityListModel::combineActivityLists() |
25 |
endInsertRows(); |
26 |
} |
27 |
|
28 |
+bool ActivityListModel::canFetchActivities() const { |
29 |
+ return _accountState->isConnected() && _accountState->account()->capabilities().hasActivities(); |
30 |
+} |
31 |
+ |
32 |
void ActivityListModel::fetchMore(const QModelIndex &) |
33 |
{ |
34 |
- if (_accountState->isConnected()) { |
35 |
- _activityLists = ActivityList(); |
36 |
+ _activityLists = ActivityList(); |
37 |
+ if (canFetchActivities()) { |
38 |
startFetchJob(); |
39 |
+ } else { |
40 |
+ combineActivityLists(); |
41 |
} |
42 |
} |
43 |
|
44 |
void ActivityListModel::slotRefreshActivity() |
45 |
{ |
46 |
_activityLists.clear(); |
47 |
- startFetchJob(); |
48 |
+ if (canFetchActivities()) { |
49 |
+ startFetchJob(); |
50 |
+ } else { |
51 |
+ combineActivityLists(); |
52 |
+ } |
53 |
} |
54 |
|
55 |
void ActivityListModel::slotRemoveAccount() |
56 |
diff --git a/src/gui/activitylistmodel.h b/src/gui/activitylistmodel.h |
57 |
index 952dc82d5..9b66da135 100644 |
58 |
--- src/gui/activitylistmodel.h |
59 |
+++ src/gui/activitylistmodel.h |
60 |
@@ -67,6 +67,7 @@ private slots: |
61 |
private: |
62 |
void startFetchJob(); |
63 |
void combineActivityLists(); |
64 |
+ bool canFetchActivities() const; |
65 |
|
66 |
ActivityList _activityLists; |
67 |
ActivityList _syncFileItemLists; |
68 |
diff --git a/src/libsync/capabilities.cpp b/src/libsync/capabilities.cpp |
69 |
index 89942885c..39df7d167 100644 |
70 |
--- src/libsync/capabilities.cpp |
71 |
+++ src/libsync/capabilities.cpp |
72 |
@@ -103,6 +103,10 @@ bool Capabilities::isValid() const |
73 |
return !_capabilities.isEmpty(); |
74 |
} |
75 |
|
76 |
+bool Capabilities::hasActivities() const { |
77 |
+ return _capabilities.contains("activity"); |
78 |
+} |
79 |
+ |
80 |
QList<QByteArray> Capabilities::supportedChecksumTypes() const |
81 |
{ |
82 |
QList<QByteArray> list; |
83 |
diff --git a/src/libsync/capabilities.h b/src/libsync/capabilities.h |
84 |
index 88ad84c11..8f8fd826a 100644 |
85 |
--- src/libsync/capabilities.h |
86 |
+++ src/libsync/capabilities.h |
87 |
@@ -59,6 +59,9 @@ class OWNCLOUDSYNC_EXPORT Capabilities |
88 |
/// returns true if the capabilities are loaded already. |
89 |
bool isValid() const; |
90 |
|
91 |
+ /// return true if the activity app is enabled |
92 |
+ bool hasActivities() const; |
93 |
+ |
94 |
/** |
95 |
* Returns the checksum types the server understands. |
96 |
* |