From 8fb62628d232b26e91c5bec1308549c1dc07b691 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 25 Apr 2023 15:27:50 +0200 Subject: [PATCH] :sparkles: Add the abiltiy to forward command params as query-string --- frontend/src/app/main/repo.cljs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/main/repo.cljs b/frontend/src/app/main/repo.cljs index 3a68825c7e..f603b1faf5 100644 --- a/frontend/src/app/main/repo.cljs +++ b/frontend/src/app/main/repo.cljs @@ -97,7 +97,7 @@ (defn- send-command! "A simple helper for a common case of sending and receiving transit data to the penpot mutation api." - [id params {:keys [response-type form-data? raw-transit?]}] + [id params {:keys [response-type form-data? raw-transit? forward-query-params]}] (let [decode-fn (if raw-transit? http/conditional-error-decode-transit http/conditional-decode-transit) @@ -111,8 +111,11 @@ (if form-data? (http/form-data params) (http/transit-data params))) - :query (when (= method :get) - params) + :query (if (= method :get) + params + (if forward-query-params + (select-keys params forward-query-params) + nil)) :response-type (or response-type :text)}) (rx/map decode-fn) (rx/mapcat handle-response)))) @@ -139,6 +142,14 @@ [id params] (send-command! id params nil)) +(defmethod command :update-file + [id params] + (send-command! id params {:forward-query-params [:id]})) + +(defmethod command :upsert-file-object-thumbnail + [id params] + (send-command! id params {:forward-query-params [:file-id :object-id]})) + (defmethod command :export-binfile [id params] (send-command! id params {:response-type :blob}))