Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ interface PlaylistBookmarkDao {
@Query("SELECT * FROM playlistBookmark")
suspend fun getAll(): List<PlaylistBookmark>

@Query("SELECT * FROM playlistBookmark WHERE playlistId = :playlistId LIMIT 1")
suspend fun findById(playlistId: String): PlaylistBookmark?

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(bookmark: PlaylistBookmark)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.github.libretube.extensions.ceilHalf
import com.github.libretube.extensions.dpToPx
import com.github.libretube.helpers.NavBarHelper
import com.github.libretube.helpers.PreferenceHelper
import com.github.libretube.helpers.ProxyHelper
import com.github.libretube.ui.adapters.PlaylistBookmarkAdapter
import com.github.libretube.ui.adapters.PlaylistsAdapter
import com.github.libretube.ui.base.DynamicLayoutManagerFragment
Expand Down Expand Up @@ -140,7 +141,9 @@ class LibraryFragment : DynamicLayoutManagerFragment() {
private fun initBookmarks() {
lifecycleScope.launch {
val bookmarks = withContext(Dispatchers.IO) {
DatabaseHolder.Database.playlistBookmarkDao().getAll()
DatabaseHolder.Database.playlistBookmarkDao().getAll().map {
it.copy(thumbnailUrl = ProxyHelper.rewriteUrl(it.thumbnailUrl))
}
}

val binding = _binding ?: return@launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ class PlaylistFragment : DynamicLayoutManagerFragment() {
if (!isBookmarked) return
withContext(Dispatchers.IO) {
// update the playlist thumbnail and title if bookmarked
val playlistBookmark = DatabaseHolder.Database.playlistBookmarkDao().getAll()
.firstOrNull { it.playlistId == playlistId } ?: return@withContext
val playlistBookmark = DatabaseHolder.Database.playlistBookmarkDao().findById(playlistId)
?: return@withContext
if (playlistBookmark.thumbnailUrl != playlist.thumbnailUrl ||
playlistBookmark.playlistName != playlist.name ||
playlistBookmark.videos != playlist.videos
Expand Down