damus

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

commit bd5390fbc06683443c7be226cefbddc49f277654
parent 068099c5a704e3467a1584615b0b34e3e245c348
Author: William Casarin <jb55@jb55.com>
Date:   Mon,  2 Jan 2023 15:23:13 -0800

actually add PreviewCache oops

Diffstat:
Adamus/Util/PreviewCache.swift | 35+++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+), 0 deletions(-)

diff --git a/damus/Util/PreviewCache.swift b/damus/Util/PreviewCache.swift @@ -0,0 +1,35 @@ +// +// PreviewCache.swift +// damus +// +// Created by William Casarin on 2023-01-02. +// + +import Foundation +import LinkPresentation + +enum Preview { + case value(LinkViewRepresentable) + case failed +} + +class PreviewCache { + var previews: [String: Preview] + + func lookup(_ evid: String) -> Preview? { + return previews[evid] + } + + func store(evid: String, preview: LinkViewRepresentable?) { + switch preview { + case .none: + previews[evid] = .failed + case .some(let meta): + previews[evid] = .value(meta) + } + } + + init() { + self.previews = [:] + } +}