Eliminated some unnecessary gamelist reloads.

This commit is contained in:
Leon Styhre 2023-01-01 15:31:03 +01:00
parent f78f7ab35f
commit d6db705b93

View file

@ -317,14 +317,15 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection
std::string key {file->getFullPath()}; std::string key {file->getFullPath()};
SystemData* curSys {sysData.system}; SystemData* curSys {sysData.system};
bool mFavoritesSorting = false; bool favoritesSorting {false};
bool onFileChanged {false};
// Read the applicable favorite sorting setting depending on whether the // Read the applicable favorite sorting setting depending on whether the
// system is a custom collection or not. // system is a custom collection or not.
if (sysData.decl.isCustom) if (sysData.decl.isCustom)
mFavoritesSorting = Settings::getInstance()->getBool("FavFirstCustom"); favoritesSorting = Settings::getInstance()->getBool("FavFirstCustom");
else else
mFavoritesSorting = Settings::getInstance()->getBool("FavoritesFirst"); favoritesSorting = Settings::getInstance()->getBool("FavoritesFirst");
const std::unordered_map<std::string, FileData*>& children = const std::unordered_map<std::string, FileData*>& children =
curSys->getRootFolder()->getChildrenByFilename(); curSys->getRootFolder()->getChildrenByFilename();
@ -364,7 +365,7 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection
rootFolder->getParent()->getSystem()->getRootFolder()}; rootFolder->getParent()->getSystem()->getRootFolder()};
parentRootFolder->sort(parentRootFolder->getSortTypeFromString( parentRootFolder->sort(parentRootFolder->getSortTypeFromString(
parentRootFolder->getSortTypeString()), parentRootFolder->getSortTypeString()),
mFavoritesSorting); favoritesSorting);
mWindow->queueInfoPopup( mWindow->queueInfoPopup(
"DISABLED '" + "DISABLED '" +
Utils::String::toUpper( Utils::String::toUpper(
@ -377,12 +378,13 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection
collectionEntry, false); collectionEntry, false);
} }
rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()), rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
mFavoritesSorting); favoritesSorting);
} }
else { else {
// Re-index with new metadata. // Re-index with new metadata.
fileIndex->addToIndex(collectionEntry); fileIndex->addToIndex(collectionEntry);
ViewController::getInstance()->onFileChanged(collectionEntry, true); ViewController::getInstance()->onFileChanged(collectionEntry, true);
onFileChanged = true;
} }
} }
else { else {
@ -403,6 +405,7 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection
fileIndex->addToIndex(newGame); fileIndex->addToIndex(newGame);
ViewController::getInstance()->getGamelistView(curSys)->onFileChanged(newGame, ViewController::getInstance()->getGamelistView(curSys)->onFileChanged(newGame,
true); true);
onFileChanged = true;
} }
} }
@ -412,7 +415,7 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection
else if (sysData.decl.isCustom && else if (sysData.decl.isCustom &&
!Settings::getInstance()->getBool("UseCustomCollectionsSystem")) { !Settings::getInstance()->getBool("UseCustomCollectionsSystem")) {
rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()), rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
mFavoritesSorting); favoritesSorting);
} }
// If the game doesn't exist in the current system and it's a custom // If the game doesn't exist in the current system and it's a custom
// collection, then skip the sorting. // collection, then skip the sorting.
@ -422,18 +425,18 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection
if (rootFolder->getSystem()->isGroupedCustomCollection()) { if (rootFolder->getSystem()->isGroupedCustomCollection()) {
rootFolder->getParent()->sort(rootFolder->getParent()->getSortTypeFromString( rootFolder->getParent()->sort(rootFolder->getParent()->getSortTypeFromString(
rootFolder->getParent()->getSortTypeString()), rootFolder->getParent()->getSortTypeString()),
mFavoritesSorting); favoritesSorting);
rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()), rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
mFavoritesSorting); favoritesSorting);
} }
else { else {
rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()), rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
mFavoritesSorting); favoritesSorting);
} }
} }
else if (!sysData.decl.isCustom) { else if (!sysData.decl.isCustom) {
rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()), rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
mFavoritesSorting); favoritesSorting);
} }
if (name == "recent") { if (name == "recent") {
@ -456,15 +459,18 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection
} }
} }
else { else {
ViewController::getInstance()->onFileChanged(rootFolder, true);
// For custom collections, update either the actual system or its parent depending
// on whether the collection is grouped or not.
if (sysData.decl.isCustom) { if (sysData.decl.isCustom) {
// For custom collections, update either the actual system or its parent depending
// on whether the collection is grouped or not.
ViewController::getInstance()->onFileChanged(rootFolder, true);
if (rootFolder->getSystem()->isGroupedCustomCollection()) if (rootFolder->getSystem()->isGroupedCustomCollection())
ViewController::getInstance()->onFileChanged(rootFolder->getParent(), true); ViewController::getInstance()->onFileChanged(rootFolder->getParent(), true);
else else
ViewController::getInstance()->onFileChanged(rootFolder, true); ViewController::getInstance()->onFileChanged(rootFolder, true);
} }
else if (!onFileChanged) {
ViewController::getInstance()->onFileChanged(rootFolder, true);
}
} }
} }
} }