🐛 Fix unauthorized error on handoff on share-link.

This commit is contained in:
Andrey Antukh 2020-11-30 10:51:44 +01:00 committed by Hirunatan
parent 39db88c533
commit 4a7b5618ff
3 changed files with 28 additions and 21 deletions

View file

@ -331,6 +331,22 @@
(when index (when index
(rx/of (go-to-frame-by-index index))))))) (rx/of (go-to-frame-by-index index)))))))
(defn go-to-section
[section]
(ptk/reify ::go-to-section
ptk/WatchEvent
(watch [_ state stream]
(let [route (:route state)
screen (-> route :data :name keyword)
pparams (:path-params route)
qparams (:query-params route)]
(rx/of
(if (= :handoff section)
(rt/nav :handoff pparams qparams)
(rt/nav :viewer pparams (assoc qparams :section section))))))))
(defn set-current-frame [frame-id] (defn set-current-frame [frame-id]
(ptk/reify ::current-frame (ptk/reify ::current-frame
ptk/UpdateEvent ptk/UpdateEvent

View file

@ -161,10 +161,13 @@
:handoff :handoff
(let [file-id (get-in route [:path-params :file-id]) (let [file-id (get-in route [:path-params :file-id])
page-id (get-in route [:path-params :page-id]) page-id (get-in route [:path-params :page-id])
index (get-in route [:query-params :index])] index (get-in route [:query-params :index])
token (get-in route [:query-params :token])]
[:& handoff {:page-id page-id [:& handoff {:page-id page-id
:file-id file-id :file-id file-id
:index index}]) :index index
:token token}])
:render-object :render-object
(do (do

View file

@ -213,20 +213,7 @@
(mf/use-callback (mf/use-callback
(mf/deps file-id page-id) (mf/deps file-id page-id)
(fn [section] (fn [section]
(st/emit! (st/emit! (dv/go-to-section section))))]
(case section
:interactions
(rt/nav :viewer
{:file-id file-id :page-id page-id}
{:index index :section "interactions"})
:comments
(rt/nav :viewer
{:file-id file-id :page-id page-id}
{:index index :section "comments"})
:handoff
(rt/nav :handoff
{:file-id file-id :page-id page-id}
{:index index})))))]
[:header.viewer-header [:header.viewer-header
[:div.main-icon [:div.main-icon
@ -249,11 +236,12 @@
:alt "View mode"} :alt "View mode"}
i/play] i/play]
(when-not anonymous?
[:button.mode-zone-button.tooltip.tooltip-bottom [:button.mode-zone-button.tooltip.tooltip-bottom
{:on-click #(navigate :comments) {:on-click #(navigate :comments)
:class (dom/classnames :active (= section :comments)) :class (dom/classnames :active (= section :comments))
:alt "Comments"} :alt "Comments"}
i/chat] i/chat])
[:button.mode-zone-button.tooltip.tooltip-bottom [:button.mode-zone-button.tooltip.tooltip-bottom
{:on-click #(navigate :handoff) {:on-click #(navigate :handoff)