🐛 Fix backend notification dialogs

This commit is contained in:
Andrey Antukh 2025-04-03 11:07:35 +02:00
parent 8f600f334f
commit 1d69941882
5 changed files with 10 additions and 20 deletions

View file

@ -73,7 +73,7 @@
(st/emit! (ntf/hide)))
(defn handle-notification
[{:keys [message code level] :as params}]
[{:keys [message code] :as params}]
(ptk/reify ::show-notification
ptk/WatchEvent
(watch [_ _ _]
@ -81,9 +81,6 @@
:upgrade-version
(rx/of (ntf/dialog
:content (tr "notifications.by-code.upgrade-version")
:controls :inline-actions
:type :inline
:level level
:accept {:label (tr "labels.refresh")
:callback force-reload!}
:tag :notification))
@ -91,16 +88,14 @@
:maintenance
(rx/of (ntf/dialog
:content (tr "notifications.by-code.maintenance")
:controls :inline-actions
:type level
:accept {:label (tr "labels.accept")
:callback hide-notifications!}
:tag :notification))
(rx/of (ntf/dialog
:content message
:controls :close
:type level
:accept {:label (tr "labels.close")
:callback hide-notifications!}
:tag :notification))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View file

@ -19,7 +19,7 @@
(def ^:private schema:notification
[:map {:title "Notification"}
[:level [::sm/one-of #{:success :error :info :warning}]]
[:level {:optional true} [::sm/one-of #{:success :error :info :warning}]]
[:status {:optional true}
[::sm/one-of #{:visible :hide}]]
[:position {:optional true}
@ -129,15 +129,11 @@
:timeout timeout})))
(defn dialog
[& {:keys [content controls actions accept cancel position tag level links]
:or {controls :none position :floating level :info}}]
[& {:keys [content accept cancel tag links]}]
(show (d/without-nils
{:content content
:level level
:links links
:position position
:controls controls
:actions actions
:type :inline
:accept accept
:cancel cancel
:links links
:tag tag})))

View file

@ -65,7 +65,6 @@
(->> (rx/from initmsg)
(rx/map dws/send))
;; Subscribe to notifications of the subscription
(->> stream
(rx/filter (ptk/type? ::dws/message))

View file

@ -370,6 +370,6 @@
(if edata
[:> static/exception-page* {:data edata :route route}]
[:> error-boundary* {:fallback static/internal-error*}
[:& notifications/current-notification]
[:> notifications/current-notification*]
(when route
[:> page* {:route route :profile profile}])])]]))

View file

@ -14,10 +14,10 @@
[okulary.core :as l]
[rumext.v2 :as mf]))
(def ref:notification
(def ^:private ref:notification
(l/derived :notification st/state))
(mf/defc current-notification
(mf/defc current-notification*
[]
(let [notification (mf/deref ref:notification)
on-close (mf/use-fn #(st/emit! (ntf/hide)))