fix: deleted catalogs no longer flash back on home load (#71) - #125
Merged
Conversation
HomeViewModel.loadHomeData built its "early skeleton" row list directly from mediaRepository.getDefaultCatalogConfigs(), which is the unfiltered set of all 26 preinstalled catalogs. The real filtered list (which correctly respects the hidden_preinstalled_catalogs DataStore key) was loaded a few lines later, but in the meantime users saw their deleted catalogs reappear as loading skeletons for 1-3 seconds. On cold launches or slow networks the flash lasted long enough that users thought the delete never took — matching the exact symptom reported in #71 (and the duplicate #74 we already closed). The persistence layer was always correct: removeCustomCatalog adds the id to a hidden set, ensurePreinstalledDefaults filters it out, and the cloud sync snapshot/restore both carry the hidden set. Only the skeleton path was bypassing all of that. Fix: read the active-profile hidden set via the existing catalogRepository.getHiddenPreinstalledCatalogIdsForActiveProfile() suspend function (single DataStore .first() read, negligible cost) and filter getDefaultCatalogConfigs() before building the skeleton. Wrapped in runCatching so a DataStore read failure falls back to the old behavior instead of breaking the home load. Closes #71
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #71 (and the duplicate #74 we already closed).
Users reported that deleting a catalog (e.g. "Trending in Anime", "New K-Dramas") showed a "removed" confirmation but the catalog reappeared a moment later on the home screen, even after restart. The reports included screenshots showing the catalog flashing back in during home loading.
Root cause
The persistence layer was already correct —
removeCustomCatalogadds the id to a hidden set,ensurePreinstalledDefaultsfilters against it, cloud sync carries it both ways, andreadCatalogsFromPrefshonors it when reading the full list.But
HomeViewModel.loadHomeData()(line 915-931) builds an "early skeleton" of loading rows before callingensurePreinstalledDefaults, and it built that skeleton directly frommediaRepository.getDefaultCatalogConfigs()— the unfiltered list of all 26 preinstalled catalogs. So on every cold load and every subsequentloadHomeData()call wherecategories.isEmpty(), the user saw their deleted catalogs reappear as skeleton rows for 1-3 seconds until the real filtered list replaced them. On slow networks the flash lasted long enough that users believed the delete never took effect.Fix
Before building the early skeleton, read the active-profile hidden set via the existing
catalogRepository.getHiddenPreinstalledCatalogIdsForActiveProfile()suspend function and filtergetDefaultCatalogConfigs()to exclude hidden preinstalled catalogs.Wrapped in
runCatchingso a DataStore read failure falls back to the old behavior rather than breaking the home load entirely.Why this is safe
getHiddenPreinstalledCatalogIdsForActiveProfile()is onecontext.settingsDataStore.data.first()+ a Gson decode — microseconds of cost on a path that already awaits a much longer sequence of network/catalog calls.CatalogRepository.readCatalogsFromPrefs(line 823-831),CloudSyncRepository.pushToCloud(line 241-246), andCloudSyncRepository.applyCloudPayload(line 446) all use identical filter logic. This PR just applies the same filter one layer up for the skeleton.filterNot { cfg.isPreinstalled && cfg.id in hidden }matches the existing filter atCatalogRepository.kt:831, so custom user-added catalogs are never removed by this code path (they aren't in the default list anyway).Test plan