From: Michael Schuster Date: Fri, 17 Jan 2020 19:25:41 +0000 (+0100) Subject: Limit fetching Activities to 100 or max. 30 days old X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~222^2^2~413^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e2188b109a38ba68590956b83b0c338d578bb00c;p=nextcloud-desktop.git Limit fetching Activities to 100 or max. 30 days old Signed-off-by: Michael Schuster --- diff --git a/src/gui/tray/ActivityListModel.cpp b/src/gui/tray/ActivityListModel.cpp index dc1b109f6..8be9c174d 100644 --- a/src/gui/tray/ActivityListModel.cpp +++ b/src/gui/tray/ActivityListModel.cpp @@ -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; } } diff --git a/src/gui/tray/ActivityListModel.h b/src/gui/tray/ActivityListModel.h index e6e68cba4..96b0785ee 100644 --- a/src/gui/tray/ActivityListModel.h +++ b/src/gui/tray/ActivityListModel.h @@ -102,6 +102,10 @@ private: bool _currentlyFetching = false; bool _doneFetching = false; int _currentItem = 0; + + int _totalActivitiesFetched = 0; + int _maxActivities = 100; + int _maxActivitiesDays = 30; }; }