mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 22:22:43 -05:00
Prevent reprocessing the style-dictionary cache multiple times
This commit is contained in:
parent
73e8b80521
commit
a79d1013bf
1 changed files with 12 additions and 3 deletions
|
@ -91,9 +91,18 @@
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
(mf/deps tokens)
|
(mf/deps tokens)
|
||||||
(fn []
|
(fn []
|
||||||
(p/let [resolved-tokens (resolve-tokens+ tokens)]
|
(let [cached (get @!tokens-cache tokens)]
|
||||||
(reset! !tokens-cache resolved-tokens)
|
(cond
|
||||||
(reset! tokens-state resolved-tokens))))
|
;; The tokens are already processing somewhere
|
||||||
|
(p/promise? cached) (p/then cached #(reset! tokens-state %))
|
||||||
|
;; Get the cached entry
|
||||||
|
(some? cached) (reset! tokens-state cached)
|
||||||
|
;; No cached entry, start processing
|
||||||
|
:else (let [promise+ (resolve-tokens+ tokens)]
|
||||||
|
(swap! !tokens-cache assoc tokens promise+)
|
||||||
|
(p/then promise+ (fn [resolved-tokens]
|
||||||
|
(swap! !tokens-cache assoc tokens resolved-tokens)
|
||||||
|
(reset! tokens-state resolved-tokens))))))))
|
||||||
@tokens-state))
|
@tokens-state))
|
||||||
|
|
||||||
;; Testing ---------------------------------------------------------------------
|
;; Testing ---------------------------------------------------------------------
|
||||||
|
|
Loading…
Add table
Reference in a new issue