mirror of
https://github.com/penpot/penpot.git
synced 2025-01-22 14:39:45 -05:00
🐛 Have language change notification written in the new language
This commit is contained in:
parent
0014bb3d24
commit
41aede2b50
5 changed files with 41 additions and 36 deletions
|
@ -16,6 +16,7 @@
|
|||
- Add some missing database indexes (mainly improves performance on large databases on file-update rpc method, and some background tasks).
|
||||
- Fix problem width handoff code generation [Taiga #1204](https://tree.taiga.io/project/penpot/issue/1204)
|
||||
- Fix problem with indices refreshing on page changes [#646](https://github.com/penpot/penpot/issues/646)
|
||||
- Have language change notification written in the new language [Taiga #1205](https://tree.taiga.io/project/penpot/issue/1205)
|
||||
- Properly handle errors on github, gitlab and ldap auth backends.
|
||||
- Properly mark profile auth backend (on first register/ auth with 3rd party auth provider).
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
(st/emit! (rt/initialize-router ui/routes)
|
||||
(rt/initialize-history on-navigate))
|
||||
|
||||
(st/emit! udu/fetch-profile)
|
||||
(st/emit! (udu/fetch-profile))
|
||||
(mf/mount (mf/element ui/app) (dom/get-element "app"))
|
||||
(mf/mount (mf/element modal) (dom/get-element "modal")))
|
||||
|
||||
|
|
|
@ -50,38 +50,43 @@
|
|||
;; --- Profile Fetched
|
||||
|
||||
(defn profile-fetched
|
||||
[{:keys [fullname] :as data}]
|
||||
(us/verify ::profile data)
|
||||
(ptk/reify ::profile-fetched
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc state :profile
|
||||
(cond-> data
|
||||
(nil? (:lang data))
|
||||
(assoc :lang cfg/default-language)
|
||||
([data] (profile-fetched nil data))
|
||||
([on-success {:keys [fullname] :as data}]
|
||||
(us/verify ::profile data)
|
||||
(ptk/reify ::profile-fetched
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc state :profile
|
||||
(cond-> data
|
||||
(nil? (:lang data))
|
||||
(assoc :lang cfg/default-language)
|
||||
|
||||
(nil? (:theme data))
|
||||
(assoc :theme cfg/default-theme))))
|
||||
(nil? (:theme data))
|
||||
(assoc :theme cfg/default-theme))))
|
||||
|
||||
ptk/EffectEvent
|
||||
(effect [_ state stream]
|
||||
(let [profile (:profile state)]
|
||||
(swap! storage assoc :profile profile)
|
||||
(i18n/set-current-locale! (:lang profile))
|
||||
(theme/set-current-theme! (:theme profile))))))
|
||||
ptk/EffectEvent
|
||||
(effect [_ state stream]
|
||||
(let [profile (:profile state)]
|
||||
(swap! storage assoc :profile profile)
|
||||
(i18n/set-current-locale! (:lang profile))
|
||||
(theme/set-current-theme! (:theme profile))
|
||||
(when on-success
|
||||
(on-success)))))))
|
||||
|
||||
;; --- Fetch Profile
|
||||
|
||||
(def fetch-profile
|
||||
(reify
|
||||
ptk/WatchEvent
|
||||
(watch [_ state s]
|
||||
(->> (rp/query! :profile)
|
||||
(rx/map profile-fetched)
|
||||
(rx/catch (fn [error]
|
||||
(if (= (:type error) :not-found)
|
||||
(rx/of (rt/nav :auth-login))
|
||||
(rx/empty))))))))
|
||||
(defn fetch-profile
|
||||
([] (fetch-profile nil))
|
||||
([on-success]
|
||||
(reify
|
||||
ptk/WatchEvent
|
||||
(watch [_ state s]
|
||||
(->> (rp/query! :profile)
|
||||
(rx/map (partial profile-fetched on-success))
|
||||
(rx/catch (fn [error]
|
||||
(if (= (:type error) :not-found)
|
||||
(rx/of (rt/nav :auth-login))
|
||||
(rx/empty)))))))))
|
||||
|
||||
;; --- Update Profile
|
||||
|
||||
|
@ -97,8 +102,7 @@
|
|||
handle-error #(do (on-error (:payload %))
|
||||
(rx/empty))]
|
||||
(->> (rp/mutation :update-profile data)
|
||||
(rx/do on-success)
|
||||
(rx/map (constantly fetch-profile))
|
||||
(rx/map (constantly (fetch-profile on-success)))
|
||||
(rx/catch rp/client-error? handle-error))))))
|
||||
|
||||
;; --- Request Email Change
|
||||
|
@ -123,7 +127,7 @@
|
|||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(->> (rp/mutation :cancel-email-change {})
|
||||
(rx/map (constantly fetch-profile))))))
|
||||
(rx/map (constantly (fetch-profile)))))))
|
||||
|
||||
;; --- Update Password (Form)
|
||||
|
||||
|
@ -158,7 +162,7 @@
|
|||
(watch [_ state stream]
|
||||
(let [{:keys [id] :as profile} (:profile state)]
|
||||
(->> (rp/mutation :update-profile-props {:props {:onboarding-viewed true}})
|
||||
(rx/map (constantly fetch-profile)))))))
|
||||
(rx/map (constantly (fetch-profile))))))))
|
||||
|
||||
|
||||
;; --- Update Photo
|
||||
|
@ -184,7 +188,7 @@
|
|||
(rx/map prepare)
|
||||
(rx/mapcat #(rp/mutation :update-profile-photo %))
|
||||
(rx/do on-success)
|
||||
(rx/map (constantly fetch-profile))
|
||||
(rx/map (constantly (fetch-profile)))
|
||||
(rx/catch on-error))))))
|
||||
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
(if (and (:is-active data) (:claims data))
|
||||
(let [message (tr "auth.notifications.team-invitation-accepted")]
|
||||
(st/emit! (rt/nav :dashboard-projects {:team-id (get-in data [:claims :team-id])})
|
||||
du/fetch-profile
|
||||
(du/fetch-profile)
|
||||
(dm/success message)))
|
||||
(st/emit! (rt/nav :auth-register-success {} {:email (:email data)})))))
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
(let [msg (tr "dashboard.notifications.email-changed-successfully")]
|
||||
(ts/schedule 100 #(st/emit! (dm/success msg)))
|
||||
(st/emit! (rt/nav :settings-profile)
|
||||
du/fetch-profile)))
|
||||
(du/fetch-profile))))
|
||||
|
||||
(defmethod handle-token :auth
|
||||
[tdata]
|
||||
|
@ -53,7 +53,7 @@
|
|||
(case (:state tdata)
|
||||
:created
|
||||
(let [message (tr "auth.notifications.team-invitation-accepted")]
|
||||
(st/emit! du/fetch-profile
|
||||
(st/emit! (du/fetch-profile)
|
||||
(rt/nav :dashboard-projects {:team-id (:team-id tdata)})
|
||||
(dm/success message)))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue