Fix compatibility with previous backups

This commit is contained in:
Bnyro 2023-02-12 17:42:51 +01:00
parent 26a4eeea6f
commit f0857633e9
2 changed files with 11 additions and 8 deletions

View File

@ -112,8 +112,8 @@ object PreferenceKeys {
const val LAST_STREAM_VIDEO_ID = "last_stream_video_id"
const val LAST_WATCHED_FEED_TIME = "last_watched_feed_time"
const val HIDE_WATCHED_FROM_FEED = "hide_watched_from_feed"
const val SELECTED_FEED_FILTER = "selected_feed_filer"
const val FEED_SORT_ORDER = "feed_sort_oder"
const val SELECTED_FEED_FILTER = "selected_filer_feed"
const val FEED_SORT_ORDER = "sort_oder_feed"
/**
* Advanced

View File

@ -25,6 +25,8 @@ import com.github.libretube.ui.adapters.PlaylistsAdapter
import com.github.libretube.ui.adapters.VideosAdapter
import com.github.libretube.ui.base.BaseFragment
import com.github.libretube.ui.models.SubscriptionsViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
class HomeFragment : BaseFragment() {
private lateinit var binding: FragmentHomeBinding
@ -94,12 +96,13 @@ class HomeFragment : BaseFragment() {
}
private suspend fun loadFeed() {
val savedFeed = withContext(Dispatchers.Main) {
subscriptionsViewModel.videoFeed.value
}
val feed = if (
PreferenceHelper.getBoolean(PreferenceKeys.SAVE_FEED, false) &&
!subscriptionsViewModel.videoFeed.value.isNullOrEmpty()
) {
subscriptionsViewModel.videoFeed.value.orEmpty()
} else {
!savedFeed.isNullOrEmpty()
) { savedFeed } else {
runCatching {
SubscriptionHelper.getFeed()
}.getOrElse { return }
@ -122,8 +125,8 @@ class HomeFragment : BaseFragment() {
private fun loadBookmarks() {
val bookmarkedPlaylists = awaitQuery {
DatabaseHolder.Database.playlistBookmarkDao().getAll()
}
if (bookmarkedPlaylists.isEmpty()) return
}.takeIf { it.isNotEmpty() } ?: return
runOnUiThread {
makeVisible(binding.bookmarksTV, binding.bookmarksRV)
binding.bookmarksRV.layoutManager = LinearLayoutManager(