0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-08 16:18:11 -05:00

🐛 Have language change notification written in the new language

This commit is contained in:
Andrés Moya 2021-02-12 14:03:33 +01:00 committed by Andrey Antukh
parent 0014bb3d24
commit 41aede2b50
5 changed files with 41 additions and 36 deletions

View file

@ -16,6 +16,7 @@
- Add some missing database indexes (mainly improves performance on large databases on file-update rpc method, and some background tasks). - 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 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) - 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 handle errors on github, gitlab and ldap auth backends.
- Properly mark profile auth backend (on first register/ auth with 3rd party auth provider). - Properly mark profile auth backend (on first register/ auth with 3rd party auth provider).

View file

@ -82,7 +82,7 @@
(st/emit! (rt/initialize-router ui/routes) (st/emit! (rt/initialize-router ui/routes)
(rt/initialize-history on-navigate)) (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 ui/app) (dom/get-element "app"))
(mf/mount (mf/element modal) (dom/get-element "modal"))) (mf/mount (mf/element modal) (dom/get-element "modal")))

View file

@ -50,38 +50,43 @@
;; --- Profile Fetched ;; --- Profile Fetched
(defn profile-fetched (defn profile-fetched
[{:keys [fullname] :as data}] ([data] (profile-fetched nil data))
(us/verify ::profile data) ([on-success {:keys [fullname] :as data}]
(ptk/reify ::profile-fetched (us/verify ::profile data)
ptk/UpdateEvent (ptk/reify ::profile-fetched
(update [_ state] ptk/UpdateEvent
(assoc state :profile (update [_ state]
(cond-> data (assoc state :profile
(nil? (:lang data)) (cond-> data
(assoc :lang cfg/default-language) (nil? (:lang data))
(assoc :lang cfg/default-language)
(nil? (:theme data)) (nil? (:theme data))
(assoc :theme cfg/default-theme)))) (assoc :theme cfg/default-theme))))
ptk/EffectEvent ptk/EffectEvent
(effect [_ state stream] (effect [_ state stream]
(let [profile (:profile state)] (let [profile (:profile state)]
(swap! storage assoc :profile profile) (swap! storage assoc :profile profile)
(i18n/set-current-locale! (:lang profile)) (i18n/set-current-locale! (:lang profile))
(theme/set-current-theme! (:theme profile)))))) (theme/set-current-theme! (:theme profile))
(when on-success
(on-success)))))))
;; --- Fetch Profile ;; --- Fetch Profile
(def fetch-profile (defn fetch-profile
(reify ([] (fetch-profile nil))
ptk/WatchEvent ([on-success]
(watch [_ state s] (reify
(->> (rp/query! :profile) ptk/WatchEvent
(rx/map profile-fetched) (watch [_ state s]
(rx/catch (fn [error] (->> (rp/query! :profile)
(if (= (:type error) :not-found) (rx/map (partial profile-fetched on-success))
(rx/of (rt/nav :auth-login)) (rx/catch (fn [error]
(rx/empty)))))))) (if (= (:type error) :not-found)
(rx/of (rt/nav :auth-login))
(rx/empty)))))))))
;; --- Update Profile ;; --- Update Profile
@ -97,8 +102,7 @@
handle-error #(do (on-error (:payload %)) handle-error #(do (on-error (:payload %))
(rx/empty))] (rx/empty))]
(->> (rp/mutation :update-profile data) (->> (rp/mutation :update-profile data)
(rx/do on-success) (rx/map (constantly (fetch-profile on-success)))
(rx/map (constantly fetch-profile))
(rx/catch rp/client-error? handle-error)))))) (rx/catch rp/client-error? handle-error))))))
;; --- Request Email Change ;; --- Request Email Change
@ -123,7 +127,7 @@
ptk/WatchEvent ptk/WatchEvent
(watch [_ state stream] (watch [_ state stream]
(->> (rp/mutation :cancel-email-change {}) (->> (rp/mutation :cancel-email-change {})
(rx/map (constantly fetch-profile)))))) (rx/map (constantly (fetch-profile)))))))
;; --- Update Password (Form) ;; --- Update Password (Form)
@ -158,7 +162,7 @@
(watch [_ state stream] (watch [_ state stream]
(let [{:keys [id] :as profile} (:profile state)] (let [{:keys [id] :as profile} (:profile state)]
(->> (rp/mutation :update-profile-props {:props {:onboarding-viewed true}}) (->> (rp/mutation :update-profile-props {:props {:onboarding-viewed true}})
(rx/map (constantly fetch-profile))))))) (rx/map (constantly (fetch-profile))))))))
;; --- Update Photo ;; --- Update Photo
@ -184,7 +188,7 @@
(rx/map prepare) (rx/map prepare)
(rx/mapcat #(rp/mutation :update-profile-photo %)) (rx/mapcat #(rp/mutation :update-profile-photo %))
(rx/do on-success) (rx/do on-success)
(rx/map (constantly fetch-profile)) (rx/map (constantly (fetch-profile)))
(rx/catch on-error)))))) (rx/catch on-error))))))

View file

@ -84,7 +84,7 @@
(if (and (:is-active data) (:claims data)) (if (and (:is-active data) (:claims data))
(let [message (tr "auth.notifications.team-invitation-accepted")] (let [message (tr "auth.notifications.team-invitation-accepted")]
(st/emit! (rt/nav :dashboard-projects {:team-id (get-in data [:claims :team-id])}) (st/emit! (rt/nav :dashboard-projects {:team-id (get-in data [:claims :team-id])})
du/fetch-profile (du/fetch-profile)
(dm/success message))) (dm/success message)))
(st/emit! (rt/nav :auth-register-success {} {:email (:email data)}))))) (st/emit! (rt/nav :auth-register-success {} {:email (:email data)})))))

View file

@ -42,7 +42,7 @@
(let [msg (tr "dashboard.notifications.email-changed-successfully")] (let [msg (tr "dashboard.notifications.email-changed-successfully")]
(ts/schedule 100 #(st/emit! (dm/success msg))) (ts/schedule 100 #(st/emit! (dm/success msg)))
(st/emit! (rt/nav :settings-profile) (st/emit! (rt/nav :settings-profile)
du/fetch-profile))) (du/fetch-profile))))
(defmethod handle-token :auth (defmethod handle-token :auth
[tdata] [tdata]
@ -53,7 +53,7 @@
(case (:state tdata) (case (:state tdata)
:created :created
(let [message (tr "auth.notifications.team-invitation-accepted")] (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)}) (rt/nav :dashboard-projects {:team-id (:team-id tdata)})
(dm/success message))) (dm/success message)))