Skip to content

Commit 1320e8b

Browse files
committed
Fix inspect
1 parent b2174a0 commit 1320e8b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/nextjournal/clerk/render.cljs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,14 @@
535535
(:nextjournal/render-opts x)
536536
{:viewer viewer :path path})]))))
537537

538+
539+
;; TODO: figure out if we can make `inspect` work synchronously by
540+
;; evaluating the `:render-fn`s on init to fix the flicker
541+
(declare await-render-fns)
542+
(defn await+inspect-presented [x]
543+
(when-let [desc (hooks/use-promise (await-render-fns x))]
544+
[inspect-presented desc]))
545+
538546
(defn inspect [value]
539547
(r/with-let [!state (r/atom nil)]
540548
(when (not= (:value @!state ::not-found) value)
@@ -546,7 +554,7 @@
546554
(.resolve js/Promise (present-elision-fn fetch-opts)))
547555
(fn [more]
548556
(swap! !state update :desc viewer/merge-presentations more fetch-opts))))}
549-
[inspect-presented (:desc @!state)]]))
557+
[await+inspect-presented (:desc @!state)]]))
550558

551559
(defn show-panel [panel-id panel]
552560
(swap! !panels assoc panel-id panel))

0 commit comments

Comments
 (0)