mirror of
https://github.com/penpot/penpot.git
synced 2025-02-22 14:57:01 -05:00
Merge pull request #5911 from penpot/niwinz-notifications-post-save-refresh
🐛 Fix incorrect notification assignation after update operation
This commit is contained in:
commit
2dcf692853
4 changed files with 27 additions and 44 deletions
|
@ -50,6 +50,8 @@ is a number of cores)
|
|||
- [COMMENTS] Notifications in Backend, Profile Section, and Mention Email Notification [Taiga #9233](https://tree.taiga.io/project/penpot/us/9233)
|
||||
|
||||
### :bug: Bugs fixed
|
||||
|
||||
- Fix missing state refresh on notifications update [Taiga #10253](https://tree.taiga.io/project/penpot/issue/10253)
|
||||
- Fix icon visualization on select component [Taiga #8889](https://tree.taiga.io/project/penpot/issue/8889)
|
||||
- Fix typo on integration tests docs [Taiga #10112](https://tree.taiga.io/project/penpot/issue/10112)
|
||||
- Fix problem with alt key measures being stuck [Taiga #9348](https://tree.taiga.io/project/penpot/issue/9348)
|
||||
|
|
|
@ -14,11 +14,12 @@
|
|||
[app.config :as cf]
|
||||
[app.main.data.event :as ev]
|
||||
[app.main.data.media :as di]
|
||||
[app.main.data.notifications :as ntf]
|
||||
[app.main.data.team :as-alias dtm]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.router :as rt]
|
||||
[app.plugins.register :as plugins.register]
|
||||
[app.util.i18n :as i18n]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.storage :as storage]
|
||||
[beicon.v2.core :as rx]
|
||||
[potok.v2.core :as ptk]))
|
||||
|
@ -239,25 +240,24 @@
|
|||
[:email-comments [::sm/one-of #{:all :partial :none}]]
|
||||
[:email-invites [::sm/one-of #{:all :none}]]])
|
||||
|
||||
(def ^:private check-update-notifications-params
|
||||
(sm/check-fn schema:update-notifications))
|
||||
|
||||
(defn update-notifications
|
||||
[data]
|
||||
(dm/assert!
|
||||
"expected valid parameters"
|
||||
(sm/check schema:update-notifications data))
|
||||
|
||||
(assert (check-update-notifications-params data))
|
||||
(ptk/reify ::update-notifications
|
||||
ev/Event
|
||||
(-data [_] {})
|
||||
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update-in state [:profile :props] assoc :notifications data))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(let [{:keys [on-error on-success]
|
||||
:or {on-error identity
|
||||
on-success identity}} (meta data)]
|
||||
(->> (rp/cmd! :update-profile-notifications data)
|
||||
(rx/tap on-success)
|
||||
(rx/catch #(do (on-error %) (rx/empty)))
|
||||
(rx/ignore))))))
|
||||
(->> (rp/cmd! :update-profile-notifications data)
|
||||
(rx/map #(ntf/success (tr "dashboard.notifications.notifications-saved")))))))
|
||||
|
||||
(defn update-profile-props
|
||||
[props]
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
[app.main.ui.settings.change-email]
|
||||
[app.main.ui.settings.delete-account]
|
||||
[app.main.ui.settings.feedback :refer [feedback-page]]
|
||||
[app.main.ui.settings.notifications :refer [notifications-page]]
|
||||
[app.main.ui.settings.notifications :refer [notifications-page*]]
|
||||
[app.main.ui.settings.options :refer [options-page]]
|
||||
[app.main.ui.settings.password :refer [password-page]]
|
||||
[app.main.ui.settings.profile :refer [profile-page]]
|
||||
|
@ -71,4 +71,4 @@
|
|||
[:& access-tokens-page]
|
||||
|
||||
:settings-notifications
|
||||
[:& notifications-page])]]]]))
|
||||
[:& notifications-page* {:profile profile}])]]]]))
|
||||
|
|
|
@ -9,14 +9,11 @@
|
|||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.schema :as sm]
|
||||
[app.main.data.notifications :as ntf]
|
||||
[app.main.data.profile :as dp]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.components.forms :as fm]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[okulary.core :as l]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(def default-notification-settings
|
||||
|
@ -24,29 +21,9 @@
|
|||
:email-comments :partial
|
||||
:email-invites :all})
|
||||
|
||||
(def notification-settings-ref
|
||||
(l/derived
|
||||
(fn [profile]
|
||||
(-> (merge default-notification-settings
|
||||
(-> profile :props :notifications))
|
||||
(d/update-vals d/name)))
|
||||
refs/profile))
|
||||
|
||||
(defn- on-error
|
||||
[form _]
|
||||
(reset! form nil)
|
||||
(st/emit! (ntf/error (tr "generic.error"))))
|
||||
|
||||
(defn- on-success
|
||||
[_]
|
||||
(st/emit! (ntf/success (tr "dashboard.notifications.notifications-saved"))))
|
||||
|
||||
(defn- on-submit
|
||||
[form event]
|
||||
(dom/prevent-default event)
|
||||
(let [params (with-meta (:clean-data @form)
|
||||
{:on-success (partial on-success form)
|
||||
:on-error (partial on-error form)})]
|
||||
[form _event]
|
||||
(let [params (:clean-data @form)]
|
||||
(st/emit! (dp/update-notifications params))))
|
||||
|
||||
(def ^:private schema:notifications-form
|
||||
|
@ -55,11 +32,15 @@
|
|||
[:email-comments [::sm/one-of #{:all :partial :none}]]
|
||||
[:email-invites [::sm/one-of #{:all :partial :none}]]])
|
||||
|
||||
(mf/defc notifications-page
|
||||
[]
|
||||
(let [settings (mf/deref notification-settings-ref)
|
||||
form (fm/use-form :schema schema:notifications-form
|
||||
:initial settings)]
|
||||
(mf/defc notifications-page*
|
||||
[{:keys [profile]}]
|
||||
(let [settings (mf/with-memo [profile]
|
||||
(-> (merge default-notification-settings
|
||||
(-> profile :props :notifications))
|
||||
(update-vals d/name)))
|
||||
form (fm/use-form :schema schema:notifications-form
|
||||
:initial settings)]
|
||||
|
||||
(mf/with-effect []
|
||||
(dom/set-html-title (tr "title.settings.notifications")))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue