fix: full refresh on profile switch

This commit is contained in:
edde746
2025-11-09 16:52:00 +01:00
parent bbec52e5f0
commit 7fbd320fa7
4 changed files with 42 additions and 11 deletions
+8 -1
View File
@@ -273,7 +273,7 @@ class _DiscoverScreenState extends State<DiscoverScreen>
}
}
// Public method to refresh content
// Public method to refresh content (for normal navigation)
@override
void refresh() {
appLogger.d('DiscoverScreen.refresh() called');
@@ -281,6 +281,13 @@ class _DiscoverScreenState extends State<DiscoverScreen>
_refreshContinueWatching();
}
// Public method to fully reload all content (for profile switches)
void fullRefresh() {
appLogger.d('DiscoverScreen.fullRefresh() called - reloading all content');
// Reload all content including Recently Added and content hubs
_loadContent();
}
/// Get icon for hub based on its title
IconData _getHubIcon(String title) {
final lowerTitle = title.toLowerCase();
+11 -1
View File
@@ -503,12 +503,22 @@ class _LibrariesScreenState extends State<LibrariesScreen>
}
}
// Public method to refresh content
// Public method to refresh content (for normal navigation)
@override
void refresh() {
_loadLibraries();
}
// Public method to fully reload all content (for profile switches)
void fullRefresh() {
appLogger.d('LibrariesScreen.fullRefresh() called - reloading all content');
// Reload libraries and clear any selected library/filters
_selectedLibraryKey = null;
_selectedFilters.clear();
_items.clear();
_loadLibraries();
}
Future<void> _toggleLibraryVisibility(PlexLibrary library) async {
final hiddenLibrariesProvider = Provider.of<HiddenLibrariesProvider>(
context,
+9 -9
View File
@@ -93,22 +93,22 @@ class _MainScreenState extends State<MainScreen> with RouteAware {
void _invalidateAllScreens() {
appLogger.d('Invalidating all screen data due to profile switch');
// Refresh discover screen
// Full refresh discover screen (reload all content for new profile)
final discoverState = _discoverKey.currentState;
if (discoverState != null && discoverState is Refreshable) {
(discoverState as Refreshable).refresh();
if (discoverState != null) {
(discoverState as dynamic).fullRefresh();
}
// Refresh libraries screen
// Full refresh libraries screen (clear filters and reload for new profile)
final librariesState = _librariesKey.currentState;
if (librariesState != null && librariesState is Refreshable) {
(librariesState as Refreshable).refresh();
if (librariesState != null) {
(librariesState as dynamic).fullRefresh();
}
// Refresh search screen
// Full refresh search screen (clear search for new profile)
final searchState = _searchKey.currentState;
if (searchState != null && searchState is Refreshable) {
(searchState as Refreshable).refresh();
if (searchState != null) {
(searchState as dynamic).fullRefresh();
}
}
+14
View File
@@ -6,6 +6,7 @@ import '../models/plex_metadata.dart';
import '../services/settings_service.dart';
import '../providers/settings_provider.dart';
import '../utils/provider_extensions.dart';
import '../utils/app_logger.dart';
import '../widgets/media_card.dart';
import '../widgets/desktop_app_bar.dart';
import '../mixins/refreshable.dart';
@@ -120,6 +121,19 @@ class _SearchScreenState extends State<SearchScreen>
}
}
// Public method to fully reload all content (for profile switches)
void fullRefresh() {
appLogger.d('SearchScreen.fullRefresh() called - clearing search and reloading');
// Clear search results and search text for new profile
_searchController.clear();
setState(() {
_searchResults.clear();
_isSearching = false;
_hasSearched = false;
_lastSearchedQuery = '';
});
}
@override
void updateItemInLists(String ratingKey, PlexMetadata updatedMetadata) {
final index = _searchResults.indexWhere(