feat: apply loading message delay for directories#2410
feat: apply loading message delay for directories#2410joelim-work merged 7 commits intogokcehan:masterfrom
Conversation
CatsDeservePets
left a comment
There was a problem hiding this comment.
Scrolling through directories feels much smoother now.
ui.go
Outdated
| switch { | ||
| case reg.loading: | ||
| if previewLoading { | ||
| if time.Since(reg.loadTime) > 100*time.Millisecond { |
There was a problem hiding this comment.
Interesting. I never noticed before, but volatile previews only ever displayed loading... once, even though they have to load every time.
This is fixed now.
There was a problem hiding this comment.
It is because of this part of the code, which marks the preview as reloading entirely from scratch if it is volatile:
if volatile && r.volatile {
if !gOpts.preload {
r.loadTime = time.Now()
r.loading = true
}
nav.previewChan <- path
}One thing I dislike about the initial implementation of previews is that it conflates 'loading' with 'displaying'. The preload option separates these two steps:
- Loading is performing any prerequisite work (e.g. generating thumbnails from a video), and then loading the preview into a
regobject. - Displaying is taking that
regobject and physically displaying it in the UI. For text and sixel previews, the preview data is stored directly in theregobject, but volatile previews (e.g. Ueberzug images) have a flag set which then delegates the actual work to thepreviewerscript.
This does mean now that the loading... message now only applies for the loading step, but in theory the displaying step should be fast and not require such a message.
ed0b5db to
37e4f81
Compare
This PR changes the way delays are handled when displaying the
loading...message.dirandregobjects contain aloadTimevariable, which conceptually represents the time the object was last created or updated. For objects that represent real directories/previews, this is used to check for modifications by comparing againstmtime. For placeholder objects representing directories/previews that are in the process of being loaded, this can be used to measure how long it has been loading, and whether or not enough time has passed to displayloading...without causing flickering.