Tusky-App-Android/app/src/test/java/com/keylesspalace/tusky/components/viewthread
Nik Clayton c650ca9362
Improve the actual and perceived speed of thread loading (#3118)
* Improve the actual and perceived speed of thread loading

To improve the actual speed, note that if the user has opened a thread from
their home timeline then the initial status is cached in the database. Other
statuses in the same thread may be cached as well.

So try and load the initial status from the database, falling back to the
network if it's not present (e.g., the user has opened a thread from the
local or federated timelines, or a search).

Introduce a new loading state to deal with this case.

In typical cases this allows the UI to display the initial status immediately
with no need to show a progress indicator.

To improve the perceived speed, delay showing the initial loading circular
progress indicators by 500ms. If loading the initial status completes within
that time no spinner is shown and the user will perceive the action as
close-to-immediate
(https://www.nngroup.com/articles/response-times-3-important-limits/).

Additionally, introduce an extra indeterminate progress indicator.

The new indicator is linear, anchored to the bottom of the screen, and shows
progress loading ancestor/descendant statuses. Like the other indicator is
also delayed 500ms from when ancestor/descendant status information is
fetched, and if the fetch completes in that time it will not be shown.

* Mark `getStatus` as suspend so it doesn't run on the main thread

* Save an allocation, use an isDetailed parameter to TimelineStatusWithAccount.toViewData

Rename Status.toViewData's "detailed" parameter to "isDetailed" for
consistency with other uses.

* Ensure suspend functions run to completion when testing

* Delay-load the status from the network even if it's cached

This speeds up the UI while ensuring it will eventually contain accurate data
from the remote.

* Load the network status before updating the list

Avoids excess animations if the network copy has changes

* Fix UI flicker when loading reblogged statuses

* Lint

* Fixup tests
2023-01-09 21:31:31 +01:00
..
ViewThreadViewModelTest.kt Improve the actual and perceived speed of thread loading (#3118) 2023-01-09 21:31:31 +01:00