]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Ensure on removal of share that display string is updated for last (now non-)duplicat...
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 17 Oct 2024 06:49:35 +0000 (14:49 +0800)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Fri, 18 Oct 2024 09:05:16 +0000 (11:05 +0200)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/filedetails/sharemodel.cpp

index 23f03edf2da5b97b1343d59e5dbf001f7549c1f7..2a314c3faec650565c7ab605a81af0877f4724bb 100644 (file)
@@ -647,10 +647,26 @@ void ShareModel::slotRemoveShareWithId(const QString &shareId)
     const auto sharee = share->getShareWith();
     slotRemoveSharee(sharee);
 
-    beginRemoveRows({}, shareIndex.row(), shareIndex.row());
-    _shares.removeAt(shareIndex.row());
+    const auto shareRow = shareIndex.row();
+    beginRemoveRows({}, shareRow, shareRow);
+    _shares.removeAt(shareRow);
     endRemoveRows();
 
+    // Handle display name duplicates now. First remove the index from the bucket it was in; then,
+    // check if this removal means the remaining index in the bucket is no longer a duplicate.
+    // If this is the case then handle the update for this item too.
+    const auto duplicateShares = _duplicateDisplayNameShareIndices.value(shareRow);
+    if (duplicateShares) {
+        duplicateShares->remove(shareRow);
+        if (duplicateShares->count() == 1) {
+            const auto noLongerDuplicateIndex = *(duplicateShares->begin());
+            _duplicateDisplayNameShareIndices.remove(noLongerDuplicateIndex);
+            const auto noLongerDuplicateModelIndex = index(noLongerDuplicateIndex);
+            Q_EMIT dataChanged(noLongerDuplicateModelIndex, noLongerDuplicateModelIndex, {Qt::DisplayRole});
+        }
+        _duplicateDisplayNameShareIndices.remove(shareRow);
+    }
+
     handleLinkShare();
 
     Q_EMIT sharesChanged();