@@ -254,7 +254,11 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
254254
255255 viewModel = ViewModelProvider (this )[SubscriptionViewModel ::class .java]
256256 viewModel.stateLiveData.observe(viewLifecycleOwner) { it?.let (this ::handleResult) }
257- viewModel.feedGroupsLiveData.observe(viewLifecycleOwner) { it?.let (this ::handleFeedGroups) }
257+ viewModel.feedGroupsLiveData.observe(viewLifecycleOwner) {
258+ it?.let { (groups, listViewMode) ->
259+ handleFeedGroups(groups, listViewMode)
260+ }
261+ }
258262
259263 setupInitialLayout()
260264 }
@@ -405,24 +409,22 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
405409 }
406410 }
407411
408- private fun handleFeedGroups (groups : List <Group >) {
409- val listViewMode = viewModel.getListViewMode()
410-
412+ private fun handleFeedGroups (groups : List <Group >, listViewMode : Boolean ) {
411413 if (feedGroupsCarouselState != null ) {
412414 feedGroupsCarousel.onRestoreInstanceState(feedGroupsCarouselState)
413415 feedGroupsCarouselState = null
414416 }
415417
416- feedGroupsCarousel.listViewMode = listViewMode
417- feedGroupsSortMenuItem.showSortButton = groups.size > 1
418- feedGroupsSortMenuItem.listViewMode = listViewMode
419418 binding.itemsList.post {
420419 if (context == null ) {
421420 // since this part was posted to the next UI cycle, the fragment might have been
422421 // removed in the meantime
423422 return @post
424423 }
425424
425+ feedGroupsCarousel.listViewMode = listViewMode
426+ feedGroupsSortMenuItem.showSortButton = groups.size > 1
427+ feedGroupsSortMenuItem.listViewMode = listViewMode
426428 feedGroupsCarousel.notifyChanged(FeedGroupCarouselItem .PAYLOAD_UPDATE_LIST_VIEW_MODE )
427429 feedGroupsSortMenuItem.notifyChanged(GroupsHeader .PAYLOAD_UPDATE_ICONS )
428430
0 commit comments