From 815d273a4494956c6dc2fbc175d49e5ae1008113 Mon Sep 17 00:00:00 2001 From: Arvin Date: Sun, 5 Apr 2026 14:45:13 +0200 Subject: [PATCH] fix: deleted catalogs no longer flash back on home load (#71) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../com/arflix/tv/ui/screens/home/HomeViewModel.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/arflix/tv/ui/screens/home/HomeViewModel.kt b/app/src/main/kotlin/com/arflix/tv/ui/screens/home/HomeViewModel.kt index 5f85353d1..b7c5e91f2 100644 --- a/app/src/main/kotlin/com/arflix/tv/ui/screens/home/HomeViewModel.kt +++ b/app/src/main/kotlin/com/arflix/tv/ui/screens/home/HomeViewModel.kt @@ -913,8 +913,19 @@ class HomeViewModel @Inject constructor( try { if (_uiState.value.categories.isEmpty()) { + // Build the early skeleton from the default catalog list minus any + // preinstalled catalogs the user has explicitly hidden for the active + // profile. Without this filter, deleted catalogs flash back into view + // for 1-3 seconds on every cold load and on every loadHomeData() call, + // which is the "catalog reappears after deletion" symptom reported in + // issue #71 (and the duplicate #74 which we already closed). + val hiddenForSkeleton = runCatching { + catalogRepository.getHiddenPreinstalledCatalogIdsForActiveProfile().toSet() + }.getOrDefault(emptySet()) + val skeletonDefaults = mediaRepository.getDefaultCatalogConfigs() + .filterNot { cfg -> cfg.isPreinstalled && cfg.id in hiddenForSkeleton } val earlySkeleton = buildProfileSkeletonCategories( - savedCatalogs = mediaRepository.getDefaultCatalogConfigs(), + savedCatalogs = skeletonDefaults, cachedContinueWatching = emptyList() ) if (requestId != loadHomeRequestId) return@loadHome