mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 09:30:13 +03:00
Limit fetching Activities to 100 or max. 30 days old
Signed-off-by: Michael Schuster <michael@schuster.ms>
This commit is contained in:
parent
3ae55c2555
commit
e2188b109a
2 changed files with 17 additions and 0 deletions
|
@ -247,6 +247,9 @@ void ActivityListModel::slotActivitiesReceived(const QJsonDocument &json, int st
|
|||
|
||||
_currentlyFetching = false;
|
||||
|
||||
QDateTime oldestDate = QDateTime::currentDateTime();
|
||||
oldestDate = oldestDate.addDays(_maxActivitiesDays * -1);
|
||||
|
||||
foreach (auto activ, activities) {
|
||||
auto json = activ.toObject();
|
||||
|
||||
|
@ -271,6 +274,14 @@ void ActivityListModel::slotActivitiesReceived(const QJsonDocument &json, int st
|
|||
|
||||
list.append(a);
|
||||
_currentItem = list.last()._id;
|
||||
|
||||
_totalActivitiesFetched++;
|
||||
if(_totalActivitiesFetched == _maxActivities ||
|
||||
a._dateTime < oldestDate) {
|
||||
|
||||
_doneFetching = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_activityLists.append(list);
|
||||
|
@ -432,6 +443,7 @@ void ActivityListModel::slotRefreshActivity()
|
|||
_activityLists.clear();
|
||||
_doneFetching = false;
|
||||
_currentItem = 0;
|
||||
_totalActivitiesFetched = 0;
|
||||
|
||||
if (canFetchActivities()) {
|
||||
startFetchJob();
|
||||
|
@ -448,5 +460,6 @@ void ActivityListModel::slotRemoveAccount()
|
|||
_currentlyFetching = false;
|
||||
_doneFetching = false;
|
||||
_currentItem = 0;
|
||||
_totalActivitiesFetched = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,6 +102,10 @@ private:
|
|||
bool _currentlyFetching = false;
|
||||
bool _doneFetching = false;
|
||||
int _currentItem = 0;
|
||||
|
||||
int _totalActivitiesFetched = 0;
|
||||
int _maxActivities = 100;
|
||||
int _maxActivitiesDays = 30;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue