0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 07:29:08 -05:00

🐛 Fixed problems with preview

This commit is contained in:
alonso.torres 2020-09-17 14:00:41 +02:00 committed by Andrey Antukh
parent 432a139f35
commit f3477fefa5
3 changed files with 13 additions and 7 deletions

View file

@ -29,7 +29,8 @@
(require 'app.services.mutations.colors)
(require 'app.services.mutations.projects)
(require 'app.services.mutations.files)
(require 'app.services.mutations.profile))
(require 'app.services.mutations.profile)
(require 'app.services.mutations.viewer))
(defstate query-services
:start (load-query-services))

View file

@ -82,7 +82,7 @@
(vec))))
(defn bundle-fetched
[{:keys [project file page] :as bundle}]
[{:keys [project file page share-token] :as bundle}]
(us/verify ::bundle bundle)
(ptk/reify ::file-fetched
ptk/UpdateEvent
@ -93,7 +93,8 @@
:objects objects
:file file
:page page
:frames frames})))))
:frames frames
:share-token share-token})))))
(def create-share-link
(ptk/reify ::create-share-link
@ -101,8 +102,8 @@
(watch [_ state stream]
(let [file-id (get-in state [:viewer-local :file-id])
page-id (get-in state [:viewer-local :page-id])]
(->> (rp/mutation :create-file-share-token {:file-id file-id
:page-id page-id})
(->> (rp/mutation! :create-file-share-token {:file-id file-id
:page-id page-id})
(rx/map (fn [{:keys [token]}]
#(assoc-in % [:viewer-data :share-token] token))))))))
@ -233,8 +234,10 @@
(let [page-id (get-in state [:viewer-local :page-id])
file-id (get-in state [:viewer-local :file-id])
frames (get-in state [:viewer-data :frames])
share-token (get-in state [:viewer-data :share-token])
index (d/index-of-pred frames #(= (:id %) frame-id))]
(rx/of (rt/nav :viewer {:page-id page-id :file-id file-id} {:index index}))))))
(rx/of (rt/nav :viewer {:page-id page-id :file-id file-id} {:token share-token
:index index}))))))
;; --- Shortcuts

View file

@ -10,6 +10,7 @@
(ns app.main.ui.viewer.header
(:require
[rumext.alpha :as mf]
[cuerdas.core :as str]
[app.main.ui.icons :as i]
[app.main.data.messages :as dm]
[app.main.data.viewer :as dv]
@ -84,7 +85,8 @@
delete #(st/emit! dv/delete-share-link)
href (.-href js/location)
link (str href "&token=" token)
href (subs href 0 (str/index-of href "?"))
link (str href "?token=" token "&index=0")
copy-link
(fn [event]