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_STREAM_VIDEO_ID = "last_stream_video_id"
const val LAST_WATCHED_FEED_TIME = "last_watched_feed_time" const val LAST_WATCHED_FEED_TIME = "last_watched_feed_time"
const val HIDE_WATCHED_FROM_FEED = "hide_watched_from_feed" const val HIDE_WATCHED_FROM_FEED = "hide_watched_from_feed"
const val SELECTED_FEED_FILTER = "selected_feed_filer" const val SELECTED_FEED_FILTER = "selected_filer_feed"
const val FEED_SORT_ORDER = "feed_sort_oder" const val FEED_SORT_ORDER = "sort_oder_feed"
/** /**
* Advanced * 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.adapters.VideosAdapter
import com.github.libretube.ui.base.BaseFragment import com.github.libretube.ui.base.BaseFragment
import com.github.libretube.ui.models.SubscriptionsViewModel import com.github.libretube.ui.models.SubscriptionsViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
class HomeFragment : BaseFragment() { class HomeFragment : BaseFragment() {
private lateinit var binding: FragmentHomeBinding private lateinit var binding: FragmentHomeBinding
@ -94,12 +96,13 @@ class HomeFragment : BaseFragment() {
} }
private suspend fun loadFeed() { private suspend fun loadFeed() {
val savedFeed = withContext(Dispatchers.Main) {
subscriptionsViewModel.videoFeed.value
}
val feed = if ( val feed = if (
PreferenceHelper.getBoolean(PreferenceKeys.SAVE_FEED, false) && PreferenceHelper.getBoolean(PreferenceKeys.SAVE_FEED, false) &&
!subscriptionsViewModel.videoFeed.value.isNullOrEmpty() !savedFeed.isNullOrEmpty()
) { ) { savedFeed } else {
subscriptionsViewModel.videoFeed.value.orEmpty()
} else {
runCatching { runCatching {
SubscriptionHelper.getFeed() SubscriptionHelper.getFeed()
}.getOrElse { return } }.getOrElse { return }
@ -122,8 +125,8 @@ class HomeFragment : BaseFragment() {
private fun loadBookmarks() { private fun loadBookmarks() {
val bookmarkedPlaylists = awaitQuery { val bookmarkedPlaylists = awaitQuery {
DatabaseHolder.Database.playlistBookmarkDao().getAll() DatabaseHolder.Database.playlistBookmarkDao().getAll()
} }.takeIf { it.isNotEmpty() } ?: return
if (bookmarkedPlaylists.isEmpty()) return
runOnUiThread { runOnUiThread {
makeVisible(binding.bookmarksTV, binding.bookmarksRV) makeVisible(binding.bookmarksTV, binding.bookmarksRV)
binding.bookmarksRV.layoutManager = LinearLayoutManager( binding.bookmarksRV.layoutManager = LinearLayoutManager(