Fix Activity List: Add check to avoid first empty entry
authorMichael Schuster <michael@schuster.ms>
Wed, 18 Dec 2019 02:01:27 +0000 (03:01 +0100)
committerMichael Schuster <48932272+misch7@users.noreply.github.com>
Wed, 18 Dec 2019 02:29:54 +0000 (03:29 +0100)
Add checks to ActivityListModel::combineActivityLists in order to avoid adding
empty Activity entries to the _finalList.

The previous implementation always added an empty entry to the top of the list because
_notificationIgnoredFiles was appended without checking (_listOfIgnoredFiles.size() > 0).

Signed-off-by: Michael Schuster <michael@schuster.ms>
src/gui/activitylistmodel.cpp

index eab049af72e9a91ed0d6d39dea1a19741daa92f6..f64290abc098bf2ae15ed888019aff38701643c2 100644 (file)
@@ -294,18 +294,27 @@ void ActivityListModel::combineActivityLists()
 {
     ActivityList resultList;
 
-    std::sort(_notificationErrorsLists.begin(), _notificationErrorsLists.end());
-    resultList.append(_notificationErrorsLists);
-    resultList.append(_notificationIgnoredFiles);
+    if(_notificationErrorsLists.count() > 0) {
+        std::sort(_notificationErrorsLists.begin(), _notificationErrorsLists.end());
+        resultList.append(_notificationErrorsLists);
+    }
+    if(_listOfIgnoredFiles.size() > 0)
+        resultList.append(_notificationIgnoredFiles);
 
-    std::sort(_notificationLists.begin(), _notificationLists.end());
-    resultList.append(_notificationLists);
+    if(_notificationLists.count() > 0) {
+        std::sort(_notificationLists.begin(), _notificationLists.end());
+        resultList.append(_notificationLists);
+    }
 
-    std::sort(_syncFileItemLists.begin(), _syncFileItemLists.end());
-    resultList.append(_syncFileItemLists);
+    if(_syncFileItemLists.count() > 0) {
+        std::sort(_syncFileItemLists.begin(), _syncFileItemLists.end());
+        resultList.append(_syncFileItemLists);
+    }
 
-    std::sort(_activityLists.begin(), _activityLists.end());
-    resultList.append(_activityLists);
+    if(_activityLists.count() > 0) {
+        std::sort(_activityLists.begin(), _activityLists.end());
+        resultList.append(_activityLists);
+    }
 
     beginResetModel();
     _finalList.clear();