fix opening public playlists

This commit is contained in:
Bnyro 2022-12-01 17:11:31 +01:00
parent e481756b68
commit f57262da6a
4 changed files with 6 additions and 6 deletions

View File

@ -53,7 +53,7 @@ object PlaylistsHelper {
suspend fun getPlaylist(playlistId: String): Playlist { suspend fun getPlaylist(playlistId: String): Playlist {
// load locally stored playlists with the auth api // load locally stored playlists with the auth api
return when (getPlaylistType()) { return when (getPrivatePlaylistType(playlistId)) {
PlaylistType.PRIVATE -> RetrofitInstance.authApi.getPlaylist(playlistId) PlaylistType.PRIVATE -> RetrofitInstance.authApi.getPlaylist(playlistId)
PlaylistType.PUBLIC -> RetrofitInstance.api.getPlaylist(playlistId) PlaylistType.PUBLIC -> RetrofitInstance.api.getPlaylist(playlistId)
PlaylistType.LOCAL -> { PlaylistType.LOCAL -> {
@ -227,11 +227,11 @@ object PlaylistsHelper {
return importLists return importLists
} }
fun getPlaylistType(): PlaylistType { fun getPrivatePlaylistType(): PlaylistType {
return if (loggedIn()) PlaylistType.PRIVATE else PlaylistType.LOCAL return if (loggedIn()) PlaylistType.PRIVATE else PlaylistType.LOCAL
} }
fun getPlaylistType(playlistId: String): PlaylistType { fun getPrivatePlaylistType(playlistId: String): PlaylistType {
if (playlistId.all { it.isDigit() }) return PlaylistType.LOCAL if (playlistId.all { it.isDigit() }) return PlaylistType.LOCAL
if (playlistId.matches(pipedPlaylistRegex)) return PlaylistType.PRIVATE if (playlistId.matches(pipedPlaylistRegex)) return PlaylistType.PRIVATE
return PlaylistType.PUBLIC return PlaylistType.PUBLIC

View File

@ -108,7 +108,7 @@ class HomeFragment : BaseFragment() {
runOnUiThread { runOnUiThread {
makeVisible(binding.playlistsRV, binding.playlistsTV) makeVisible(binding.playlistsRV, binding.playlistsTV)
binding.playlistsRV.layoutManager = LinearLayoutManager(context) binding.playlistsRV.layoutManager = LinearLayoutManager(context)
binding.playlistsRV.adapter = PlaylistsAdapter(playlists.toMutableList(), PlaylistsHelper.getPlaylistType()) binding.playlistsRV.adapter = PlaylistsAdapter(playlists.toMutableList(), PlaylistsHelper.getPrivatePlaylistType())
binding.playlistsRV.adapter?.registerAdapterDataObserver(object : binding.playlistsRV.adapter?.registerAdapterDataObserver(object :
RecyclerView.AdapterDataObserver() { RecyclerView.AdapterDataObserver() {
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) { override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {

View File

@ -123,7 +123,7 @@ class LibraryFragment : BaseFragment() {
val playlistsAdapter = PlaylistsAdapter( val playlistsAdapter = PlaylistsAdapter(
playlists.toMutableList(), playlists.toMutableList(),
PlaylistsHelper.getPlaylistType() PlaylistsHelper.getPrivatePlaylistType()
) )
// listen for playlists to become deleted // listen for playlists to become deleted

View File

@ -110,7 +110,7 @@ object PlayingQueue {
fun insertPlaylist(playlistId: String, newCurrentStream: StreamItem) { fun insertPlaylist(playlistId: String, newCurrentStream: StreamItem) {
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {
try { try {
val playlistType = PlaylistsHelper.getPlaylistType(playlistId) val playlistType = PlaylistsHelper.getPrivatePlaylistType(playlistId)
val playlist = PlaylistsHelper.getPlaylist(playlistId) val playlist = PlaylistsHelper.getPlaylist(playlistId)
add( add(
*playlist.relatedStreams *playlist.relatedStreams