mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
perf(activitylistmodel): store conflicts in separate list
Figuring out whether a sync conflict occurred by iterating through the entire activity list each time a new activity was added is really slow, even more so when there already are thousands of previous activities. This was especially noticeable during complete initial full syncs involving more than ~5000 files. Signed-off-by: Jyrki Gadinger <nilsding@nilsding.org>
This commit is contained in:
parent
34876bf130
commit
88cfbcafea
@ -532,15 +532,13 @@ void ActivityListModel::addEntriesToActivityList(const ActivityList &activityLis
|
||||
beginInsertRows({}, startRow, startRow + activityList.count() - 1);
|
||||
for(const auto &activity : activityList) {
|
||||
_finalList.append(activity);
|
||||
if (activity._syncFileItemStatus == SyncFileItem::Conflict) {
|
||||
_conflictsList.push_back(activity);
|
||||
}
|
||||
}
|
||||
endInsertRows();
|
||||
|
||||
const auto deselectedConflictIt = std::find_if(_finalList.constBegin(), _finalList.constEnd(), [] (const auto &activity) {
|
||||
return activity._syncFileItemStatus == SyncFileItem::Conflict;
|
||||
});
|
||||
const auto conflictsFound = (deselectedConflictIt != _finalList.constEnd());
|
||||
|
||||
setHasSyncConflicts(conflictsFound);
|
||||
setHasSyncConflicts(!_conflictsList.isEmpty());
|
||||
}
|
||||
|
||||
void ActivityListModel::accountStateHasChanged()
|
||||
@ -625,6 +623,10 @@ void ActivityListModel::removeActivityFromActivityList(const Activity &activity)
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
if (activity._syncFileItemStatus == SyncFileItem::Conflict) {
|
||||
_conflictsList.removeOne(activity);
|
||||
}
|
||||
|
||||
if (activity._type != Activity::ActivityType &&
|
||||
activity._type != Activity::DummyFetchingActivityType &&
|
||||
activity._type != Activity::DummyMoreActivitiesAvailableType &&
|
||||
@ -925,6 +927,7 @@ void ActivityListModel::slotRefreshActivityInitial()
|
||||
void ActivityListModel::slotRemoveAccount()
|
||||
{
|
||||
_finalList.clear();
|
||||
_conflictsList.clear();
|
||||
_activityLists.clear();
|
||||
_presentedActivities.clear();
|
||||
setAndRefreshCurrentlyFetching(false);
|
||||
@ -957,15 +960,7 @@ bool ActivityListModel::hasSyncConflicts() const
|
||||
|
||||
ActivityList ActivityListModel::allConflicts() const
|
||||
{
|
||||
auto result = ActivityList{};
|
||||
|
||||
for(const auto &activity : _finalList) {
|
||||
if (activity._syncFileItemStatus == SyncFileItem::Conflict) {
|
||||
result.push_back(activity);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return _conflictsList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -183,6 +183,7 @@ private:
|
||||
ActivityList _notificationLists;
|
||||
ActivityList _listOfIgnoredFiles;
|
||||
ActivityList _notificationErrorsLists;
|
||||
ActivityList _conflictsList;
|
||||
ActivityList _finalList;
|
||||
|
||||
QSet<qint64> _presentedActivities;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user