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 {
// load locally stored playlists with the auth api
return when (getPlaylistType()) {
return when (getPrivatePlaylistType(playlistId)) {
PlaylistType.PRIVATE -> RetrofitInstance.authApi.getPlaylist(playlistId)
PlaylistType.PUBLIC -> RetrofitInstance.api.getPlaylist(playlistId)
PlaylistType.LOCAL -> {
@ -227,11 +227,11 @@ object PlaylistsHelper {
return importLists
}
fun getPlaylistType(): PlaylistType {
fun getPrivatePlaylistType(): PlaylistType {
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.matches(pipedPlaylistRegex)) return PlaylistType.PRIVATE
return PlaylistType.PUBLIC

View File

@ -108,7 +108,7 @@ class HomeFragment : BaseFragment() {
runOnUiThread {
makeVisible(binding.playlistsRV, binding.playlistsTV)
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 :
RecyclerView.AdapterDataObserver() {
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {

View File

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

View File

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