mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-24 22:15:57 +03:00
Check for and store indices of shares with duplicate display names
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
194222afcd
commit
1169c0ba3d
2 changed files with 33 additions and 0 deletions
|
@ -486,6 +486,38 @@ void ShareModel::slotSharesFetched(const QList<SharePtr> &shares)
|
|||
slotAddShare(share);
|
||||
}
|
||||
|
||||
// Perform forward pass on shares and check for duplicate display names; store these indeces so
|
||||
// we can check for these and display the specific user identifier in the display string later
|
||||
_duplicateDisplayNameShareIndices.clear();
|
||||
const auto shareCount = _shares.count();
|
||||
for (auto i = 0; i < shareCount; ++i) {
|
||||
if (_duplicateDisplayNameShareIndices.contains(i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto sharee = _shares.at(i)->getShareWith();
|
||||
if (sharee == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto hasDuplicates = false;
|
||||
for (auto j = i + 1; j < shareCount; ++j) {
|
||||
const auto otherSharee = _shares.at(j)->getShareWith();
|
||||
if (otherSharee == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sharee->format() == otherSharee->format()) {
|
||||
hasDuplicates = true; // Reassign is faster
|
||||
_duplicateDisplayNameShareIndices.insert(j);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasDuplicates) {
|
||||
_duplicateDisplayNameShareIndices.insert(i);
|
||||
}
|
||||
}
|
||||
|
||||
handleLinkShare();
|
||||
}
|
||||
|
||||
|
|
|
@ -253,6 +253,7 @@ private:
|
|||
QHash<QString, QPersistentModelIndex> _shareIdIndexHash;
|
||||
QHash<QString, QString> _shareIdRecentlySetPasswords;
|
||||
QVector<ShareePtr> _sharees;
|
||||
QSet<unsigned int> _duplicateDisplayNameShareIndices;
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
|
Loading…
Reference in a new issue