home: do not collect immediately on recreate

Do not use collectImmediately when recreating tabs in the home menu.

This resulted in an issue where the ViewPager would not update to
reflect the new tab layout.
This commit is contained in:
OxygenCobalt
2022-06-27 14:50:33 -06:00
parent 5b70295330
commit 67ef667080
2 changed files with 2 additions and 5 deletions
@@ -142,7 +142,7 @@ class HomeFragment : ViewBindingFragment<FragmentHomeBinding>(), Toolbar.OnMenuI
// --- VIEWMODEL SETUP --- // --- VIEWMODEL SETUP ---
collect(homeModel.isFastScrolling, ::updateFastScrolling) collect(homeModel.isFastScrolling, ::updateFastScrolling)
collectImmediately(homeModel.recreateTabs, ::handleRecreateTabs) collect(homeModel.recreateTabs, ::handleRecreateTabs)
collectImmediately(homeModel.currentTab, ::updateCurrentTab) collectImmediately(homeModel.currentTab, ::updateCurrentTab)
collectImmediately(indexerModel.state, ::handleIndexerState) collectImmediately(indexerModel.state, ::handleIndexerState)
collect(navModel.exploreNavigationItem, ::handleNavigation) collect(navModel.exploreNavigationItem, ::handleNavigation)
@@ -22,7 +22,6 @@ import android.content.Context
import android.net.Uri import android.net.Uri
import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@@ -276,9 +275,7 @@ class PlaybackViewModel(application: Application) :
// --- SAVE/RESTORE FUNCTIONS --- // --- SAVE/RESTORE FUNCTIONS ---
/** /** Force save the current [PlaybackStateManager] state to the database. */
* Force save the current [PlaybackStateManager] state to the database.
*/
fun savePlaybackState(context: Context, onDone: () -> Unit) { fun savePlaybackState(context: Context, onDone: () -> Unit) {
viewModelScope.launch { viewModelScope.launch {
playbackManager.saveState(PlaybackStateDatabase.getInstance(context)) playbackManager.saveState(PlaybackStateDatabase.getInstance(context))