Browse Source

Revert "disable js-toast temporally to open the app"

This reverts commit da1c4dd465661758bf794071c0bd0cfd21ed852a.
Tienson Qin 7 months ago
parent
commit
c269046b44
1 changed files with 18 additions and 19 deletions
  1. 18 19
      deps/shui/src/logseq/shui/toaster/core.cljs

+ 18 - 19
deps/shui/src/logseq/shui/toaster/core.cljs

@@ -1,8 +1,8 @@
 (ns logseq.shui.toaster.core
-  (:require [cljs-bean.core :as bean]
+  (:require [rum.core :as rum]
             [daiquiri.interpreter :refer [interpret]]
             [logseq.shui.util :as util]
-            [rum.core :as rum]))
+            [cljs-bean.core :as bean]))
 
 (defonce ^:private Toaster (util/lsui-wrap "Toaster"))
 (defonce ^:private *toast (atom nil))
@@ -22,24 +22,23 @@
 (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]
@@ -47,7 +46,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))
@@ -57,12 +56,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)))