]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Fix fetch handling in TestingALM
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 1 Mar 2023 13:06:36 +0000 (14:06 +0100)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 25 Jul 2023 00:40:28 +0000 (08:40 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
test/activitylistmodeltestutils.cpp
test/activitylistmodeltestutils.h

index 06f6109ba6674f9337f764ef9943c2ed14ae11c0..3e8ef27ae8434fa9dd3604295256a5a02f0dbf06 100644 (file)
@@ -459,37 +459,31 @@ void TestingALM::startFetchJob()
     job->start();
 }
 
-void TestingALM::insertOrRemoveDummyFetchingActivity()
-{
-    OCC::ActivityListModel::insertOrRemoveDummyFetchingActivity();
-}
-
 void TestingALM::slotProcessReceivedActivities()
 {
-    if (rowCount() > _numRowsPrev) {
-        auto finalListCopy = finalList();
-        for (int i = _numRowsPrev; i < rowCount(); ++i) {
-            const auto modelIndex = index(i, 0);
-            auto activity = finalListCopy.at(modelIndex.row());
-            if (activity._links.isEmpty()) {
-                const auto activityJsonObject = FakeRemoteActivityStorage::instance()->activityById(activity._id);
-
-                if (!activityJsonObject.isNull()) {
-                    // because "_links" are normally populated within the notificationhandler.cpp, which we don't run as part of this unit test, we have to fill them here
-                    // TODO: move the logic to populate "_links" to "activitylistmodel.cpp"
-                    auto actions = activityJsonObject.toObject().value("actions").toArray();
-                    foreach (auto action, actions) {
-                        activity._links.append(OCC::ActivityLink::createFomJsonObject(action.toObject()));
-                    }
-
-                    finalListCopy[modelIndex.row()] = activity;
+    auto finalListCopy = finalList();
+    for (int i = _numRowsPrev; i < rowCount(); ++i) {
+        const auto modelIndex = index(i, 0);
+        auto activity = finalListCopy.at(modelIndex.row());
+        if (activity._links.isEmpty()) {
+            const auto activityJsonObject = FakeRemoteActivityStorage::instance()->activityById(activity._id);
+
+            if (!activityJsonObject.isNull()) {
+                // because "_links" are normally populated within the notificationhandler.cpp, which we don't run as part of this unit test, we have to fill them here
+                // TODO: move the logic to populate "_links" to "activitylistmodel.cpp"
+                const auto actions = activityJsonObject.toObject().value("actions").toArray();
+                for (const auto &action : actions) {
+                    activity._links.append(OCC::ActivityLink::createFomJsonObject(action.toObject()));
                 }
             }
         }
 
-        setFinalList(finalListCopy);
+        finalListCopy[modelIndex.row()] = activity;
+        qDebug() << activity._subject << activity._subjectDisplay;
     }
-    _numRowsPrev = rowCount();
+
+    setFinalList(finalListCopy);
+
     setAndRefreshCurrentlyFetching(false);
     emit activitiesProcessed();
 }
index 9ce12aeab231efb839389ea1a1017bc4707f985f..16b8614dce66caf4ff581926c1bba8b90b5ca8c3 100644 (file)
@@ -78,7 +78,6 @@ public:
     TestingALM() = default;
 
     void startFetchJob() override;
-    void insertOrRemoveDummyFetchingActivity();
 
 public slots:
     void slotProcessReceivedActivities();