0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-25 07:58:49 -05:00

Add support for new profile persistence.

This commit is contained in:
Andrey Antukh 2016-05-06 21:07:02 +03:00
parent f5d7f0abf4
commit de2fe77270
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95

View file

@ -6,22 +6,31 @@
(ns uxbox.repo.users
"A main interface for access to remote resources."
(:refer-clojure :exclude [do])
(:require [beicon.core :as rx]
[uxbox.repo.core :refer (request url send!)]
[uxbox.state :as ust]))
[uxbox.util.transit :as t]))
(defn- decode-payload
[{:keys [payload] :as rsp}]
(let [metadata (:metadata payload)]
(assoc rsp :payload
(assoc payload :metadata (t/decode metadata)))))
(defmethod request :fetch/profile
[type _]
(let [url (str url "/profile/me")]
(send! {:method :get :url url})))
(let [url (str url "/profile/me")
params {:method :get :url url}]
(->> (send! params)
(rx/map decode-payload))))
(defmethod request :update/profile
[type data]
(let [params {:url (str url "/profile/me")
[type {:keys [metadata id] :as body}]
(let [body (assoc body :metadata (t/encode metadata))
params {:url (str url "/profile/me")
:method :put
:body data}]
(send! params)))
:body body}]
(->> (send! params)
(rx/map decode-payload))))
(defmethod request :update/password
[type data]