From 8663a1fbbb27965974dd16067864c18bf3dceaab Mon Sep 17 00:00:00 2001 From: jpcmpc23 <129786532+jpcmpc123@users.noreply.github.com> Date: Mon, 16 Nov 2026 16:41:45 -0400 Subject: [PATCH 1/2] fix(search): restore submitted results when the search state is lost Rotating the device recreates the activity, and the search screen can come back restored (submitted query, results branch) while the search state behind it is back at Empty with no results, so the results branch only shows "No Result Found" and nothing re-runs the search. Re-run the submitted search once when the screen is showing results for a submitted query but the UI state is Empty. A finished search leaves the state at Success (even with zero results) and a new submit goes through Loading first, so this cannot loop or double-fire. Refs maxrave-dev/SimpMusic#2711 --- .../simpmusic/ui/screen/other/SearchScreen.kt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/other/SearchScreen.kt b/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/other/SearchScreen.kt index 2bd6572adb..775e7ef9a3 100644 --- a/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/other/SearchScreen.kt +++ b/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/other/SearchScreen.kt @@ -338,6 +338,35 @@ fun SearchScreen( } } + // Rotation recreates the activity (MainActivity does not handle orientation changes), and + // when the search state does not survive that recreation this screen comes back restored — + // submitted query, results branch — but with the ViewModel UI state back at Empty and no + // results, which the results branch can only render as "No Result Found". Nothing re-ran the + // search, so the results stayed lost until the user searched again by hand. Re-run the + // submitted search once in exactly that situation. A search that finished — even one with + // zero results — leaves the UI state at Success, and submitting a search sets Loading first, + // so this can neither loop nor double-fire a search that is already on its way. + LaunchedEffect(searchUIType, uiState, isSearchSubmitted, searchText) { + if (searchUIType == SearchUIType.SEARCH_RESULTS && + isSearchSubmitted && + uiState is SearchScreenUIState.Empty + ) { + val query = searchText.trim() + if (query.isNotEmpty()) { + when (searchScreenState.searchType) { + SearchType.ALL -> searchViewModel.searchAll(query) + SearchType.SONGS -> searchViewModel.searchSongs(query) + SearchType.VIDEOS -> searchViewModel.searchVideos(query) + SearchType.ALBUMS -> searchViewModel.searchAlbums(query) + SearchType.ARTISTS -> searchViewModel.searchArtists(query) + SearchType.PLAYLISTS -> searchViewModel.searchPlaylists(query) + SearchType.FEATURED_PLAYLISTS -> searchViewModel.searchFeaturedPlaylist(query) + SearchType.PODCASTS -> searchViewModel.searchPodcast(query) + } + } + } + } + //On search icon click while on search screen, open keyboard. Android only feature if (getPlatform() == Platform.Android) { val reloadDestination by sharedViewModel.reloadDestination.collectAsStateWithLifecycle() From dab9057f27fcaea50d64623285c1c86c5add8d8d Mon Sep 17 00:00:00 2001 From: jpcmpc23 <129786532+jpcmpc123@users.noreply.github.com> Date: Mon, 16 Nov 2026 19:00:58 -0400 Subject: [PATCH 2/2] fix(search): keep search state across rotation instead of re-running it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MainActivity did not handle orientation changes, so rotating recreated the activity; on memory-tight devices the whole app state went with it and only the saved query/flags came back — results and suggestions were lost. Two layers: - AndroidManifest: MainActivity now handles orientation config changes, so rotation no longer recreates the activity and nothing is lost. - SearchScreen safety net: if the screen still comes back restored with a submitted query but an Empty UI state, re-run the submitted search; if it comes back on the suggestions branch, unfocused, with a restored query and no suggestions, re-run the suggestion fetch once. Refs maxrave-dev/SimpMusic#2711 --- androidApp/src/main/AndroidManifest.xml | 2 +- .../simpmusic/ui/screen/other/SearchScreen.kt | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/androidApp/src/main/AndroidManifest.xml b/androidApp/src/main/AndroidManifest.xml index 1a3a355216..ebc91d04de 100644 --- a/androidApp/src/main/AndroidManifest.xml +++ b/androidApp/src/main/AndroidManifest.xml @@ -83,7 +83,7 @@