damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 12428d01ad440f1740b3ca4a791da9e92bbd663e
parent d09154344833a0ccd20c23e38947664dad255b01
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 29 May 2023 14:20:45 -0700

preloader: only preload non-animated images to test animation bug fix

Diffstat:
Mdamus/Util/EventCache.swift | 18+++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/damus/Util/EventCache.swift b/damus/Util/EventCache.swift @@ -370,6 +370,14 @@ func preload_image(url: URL) { } } +func is_animated_image(url: URL) -> Bool { + guard let ext = url.pathComponents.last?.split(separator: ".").last?.lowercased() else { + return false + } + + return ext == "gif" +} + func preload_event(plan: PreloadPlan, state: DamusState) async { var artifacts: NoteArtifacts? = plan.data.artifacts.artifacts let settings = state.settings @@ -387,12 +395,16 @@ func preload_event(plan: PreloadPlan, state: DamusState) async { plan.data.artifacts_model.state = .loaded(arts) } - // jb55: image preloading might be breaking gifs? some kind of disk race condition perhaps? - /* for url in arts.images { + guard !is_animated_image(url: url) else { + // jb55: I have a theory that animated images are not working with the preloader due + // to some disk-cache write race condition. normal images need not apply + + continue + } + preload_image(url: url) } - */ } if plan.load_preview {