nowinandroid
nowinandroid copied to clipboard
Sort authors stream by news count
Fixes #393
This is definitely not the most efficient way to order by news by count, but since getNewsResourcesStream() is already called by the GetSaveableNewsResourcesStreamUseCase (and the data is on disk), I guess this is good enough for now.

There is unfortunately one issue at the moment.
During the first launch, GetSortedFollowableAuthorsStreamUseCase() is called 4 times.
The first 3 times, newsRepository.getNewsResourcesStream() returns an empty list.
Which means authors are initially displayed on the AuthorsCarousel sorted by name.
But then, on the 4th invocation, newsRepository.getNewsResourcesStream() contains data.
AuthorsCarousel is then updated with the expected sort, but does not scroll to the start as it tries to remain stable.
Potential solutions are:
- return an empty list of authors from
GetSortedFollowableAuthorsStreamUseCaseuntil thenewsRepository.getNewsResourcesStream()is no longer empty (but it creates a layout shift) - wait for non-empty
newsRepository.getNewsResourcesStream()(or non-emptygetSortedFollowableAuthorsStream()) in theStateFlow<OnboardingUiState>(preferred solution but feels "slower" to show the initial content) - always scroll the
AuthorsCarouselto the start when it changes
This is a duplicate of #394
Ho, my bad. I did not see this draft PR as it did not reference the issue 🙈