nowinandroid icon indicating copy to clipboard operation
nowinandroid copied to clipboard

Sort authors stream by news count

Open SimonMarquis opened this issue 2 years ago • 3 comments

Fixes #393

SimonMarquis avatar Nov 18 '22 23:11 SimonMarquis

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.

SimonMarquis avatar Nov 19 '22 01:11 SimonMarquis

image

SimonMarquis avatar Nov 19 '22 11:11 SimonMarquis

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 GetSortedFollowableAuthorsStreamUseCase until the newsRepository.getNewsResourcesStream() is no longer empty (but it creates a layout shift)
  • wait for non-empty newsRepository.getNewsResourcesStream() (or non-empty getSortedFollowableAuthorsStream()) in the StateFlow<OnboardingUiState> (preferred solution but feels "slower" to show the initial content)
  • always scroll the AuthorsCarousel to the start when it changes

SimonMarquis avatar Nov 19 '22 12:11 SimonMarquis

This is a duplicate of #394

JolandaVerhoef avatar Nov 20 '22 08:11 JolandaVerhoef

Ho, my bad. I did not see this draft PR as it did not reference the issue 🙈

SimonMarquis avatar Nov 20 '22 09:11 SimonMarquis