diff --git a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt index bcf4ed66a..45de2fafd 100644 --- a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt +++ b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt index 819c03025..5f8755200 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt @@ -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(