disable js-toast temporally to open the app

This commit is contained in:
Tienson Qin
2025-03-11 15:57:14 +08:00
parent 8f1b610361
commit da1c4dd465

View File

@@ -1,8 +1,8 @@
(ns logseq.shui.toaster.core
(:require [rum.core :as rum]
(:require [cljs-bean.core :as bean]
[daiquiri.interpreter :refer [interpret]]
[logseq.shui.util :as util]
[cljs-bean.core :as bean]))
[rum.core :as rum]))
(defonce ^:private Toaster (util/lsui-wrap "Toaster"))
(defonce ^:private *toast (atom nil))
@@ -22,23 +22,24 @@
(rum/defc install-toaster
< rum/static
[]
(let [^js js-toast (js/window.LSUI.useToast)]
(rum/use-effect!
(fn []
(reset! *toast {:toast (.-toast js-toast)
:dismiss (.-dismiss js-toast)
:update (.-update js-toast)})
#())
[])
[:<> (Toaster)]))
;; (let [^js js-toast (js/window.LSUI.useToast)]
;; (rum/use-effect!
;; (fn []
;; (reset! *toast {:toast (.-toast js-toast)
;; :dismiss (.-dismiss js-toast)
;; :update (.-update js-toast)})
;; #())
;; [])
;; [:<> (Toaster)])
)
(defn update-html-props
[v]
(update-keys v
#(case %
:class :className
:for :htmlFor
%)))
#(case %
:class :className
:for :htmlFor
%)))
(defn interpret-vals
[config ks & args]
@@ -46,7 +47,7 @@
(let [v (get config k)
v (if (fn? v) (apply v args) v)]
(if (vector? v) (assoc config k (interpret v)) config)))
config ks))
config ks))
(defn toast!
([content-or-config] (toast! content-or-config :default nil))
@@ -56,12 +57,12 @@
(let [config (if (map? content-or-config)
content-or-config
(-> {:description content-or-config}
(merge (if (map? status) status {:variant status}))))
(merge (if (map? status) status {:variant status}))))
config (update-html-props (merge config opts))
id (or (:id config) (gen-id))
config (assoc config :id id)
config (interpret-vals config [:title :description :action :icon]
{:id id :dismiss! #(dismiss id) :update! #(toast! (assoc %1 :id id))})]
{:id id :dismiss! #(dismiss id) :update! #(toast! (assoc %1 :id id))})]
(js->clj (toast (clj->js config))))
:exception)))