Skip to content

Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.

Re-read a playlist when it is reopened

Lelonio5daab253fdc7
diff --git a/.claude/settings.local.json b/.claude/settings.local.json
index 873690e..d976e7f 100644
--- a/.claude/settings.local.json
+++ b/.claude/settings.local.json
@@ -106,7 +106,8 @@
"Bash(git commit -q -m 'Open the player with a transform instead of a resize *)",
"Bash(git commit -q -m 'Add a settings screen behind the account picture *)",
"Bash(git commit -q -m 'Credit the author in the settings *)",
- "Bash(git commit -q -m 'Swap the player'\\\\''s heart for add-to-playlist *)"
+ "Bash(git commit -q -m 'Swap the player'\\\\''s heart for add-to-playlist *)",
+ "Bash(git commit -q -m 'Re-read a playlist when it is reopened *)"
]
}
}
diff --git a/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin b/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
index 40f6a21..6f3a392 100644
--- a/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
+++ b/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
@@ -2,27 +2,27 @@ C/C++ Structured Logl
j
h/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/additional_project_files.txtC
A
-?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  첀��3  ����3i
+?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  ܁���3  ����3i
g
-e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build.json  �����3� ����3n
+e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build.json  ݁���3� ����3n
l
-j/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build_mini.json  �����3� �����3[
+j/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build_mini.json  ݁���3� �����3[
Y
-W/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja  �����3�� ����3_
+W/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja  ݁���3�� ����3_
]
-[/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja.txt  �����3d
+[/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja.txt  ݁���3d
b
-`/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build_file_index.txt  �����3 @ ����3e
+`/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build_file_index.txt  ݁���3 @ ����3e
c
-a/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json  �����3�� ����3i
+a/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json  ݁���3�� ����3i
g
-e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json.bin  �����3 �" ����3o
+e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json.bin  ݁���3 �" ����3o
m
-k/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/metadata_generation_command.txt  �����3
+k/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/metadata_generation_command.txt  ݁���3
� ����3b
`
-^/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/prefab_config.json  �����3  ( ����3g
+^/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/prefab_config.json  ݁���3  ( ����3g
e
-c/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/symbol_folder_index.txt  �����3  b ����3D
+c/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/symbol_folder_index.txt  ށ���3  b ����3D
B
-@/Users/emanuele/Progetto Spotify/app/src/main/cpp/CMakeLists.txt  �����3 � �Ȅ��3
\ No newline at end of file
+@/Users/emanuele/Progetto Spotify/app/src/main/cpp/CMakeLists.txt  ށ���3 � �Ȅ��3
\ No newline at end of file
diff --git a/app/src/main/java/dev/emanuele/spot/ui/MainViewModel.kt b/app/src/main/java/dev/emanuele/spot/ui/MainViewModel.kt
index 17cbc22..7303c85 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/MainViewModel.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/MainViewModel.kt
@@ -307,6 +307,10 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
.onSuccess {
_addToPlaylist.value =
_addToPlaylist.value.copy(busy = null, done = playlist.name)
+ // The detail screen holds a list resolved before this track
+ // was in it; if that is the playlist just written to, read
+ // it again.
+ if (_playlist.value.uri == playlist.uri) openPlaylist(playlist)
}
.onFailure {
android.util.Log.e(TAG, "add to playlist failed: ${chain(it)}", it)
@@ -587,7 +591,15 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
// page should keep at the front.
container.playlistOrder.record(playlist.uri)
- if (_playlist.value.uri == playlist.uri && _playlist.value.tracks.isNotEmpty()) return
+ // Reopening what is already loaded re-reads it rather than showing the
+ // copy in memory. It used to return here, which is how a track added
+ // from the player could be genuinely in the playlist on Spotify and
+ // missing from this screen: the list had been resolved before the track
+ // existed and nothing ever asked again.
+ //
+ // The tracks already on screen stay up while the reload runs, so this
+ // costs a round trip and shows no spinner.
+ val cached = _playlist.value.takeIf { it.uri == playlist.uri }?.tracks.orEmpty()
val kind = kindOf(playlist.uri)
playlistJob?.cancel()
@@ -597,7 +609,7 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
artworkUrl = playlist.artworkUrl,
kind = kind,
)
- _playlist.value = base.copy(loading = true)
+ _playlist.value = base.copy(tracks = cached, loading = cached.isEmpty())
playlistJob = viewModelScope.launch {
runCatching {
if (kind == DetailKind.ARTIST) loadArtist(playlist.uri) else loadContext(playlist.uri)
@@ -607,7 +619,10 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
}
.onFailure {
android.util.Log.e(TAG, "detail load failed: ${chain(it)}", it)
- _playlist.value = base.copy(error = describe(it))
+ // Only when there is nothing to show. A refresh that fails
+ // over a list already on screen should leave the list.
+ _playlist.value =
+ if (cached.isEmpty()) base.copy(error = describe(it)) else base.copy(tracks = cached)
}
}
}