From 29669b8b0f550f51a9ddc6ee345428010b687c13 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 25 Nov 2020 20:08:39 +0100 Subject: [PATCH] :bug: Don't navigate when no frame/index found on viewer. --- common/app/common/data.cljc | 2 +- frontend/src/app/main/data/viewer.cljs | 3 ++- frontend/src/app/main/ui/viewer/shapes.cljs | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/common/app/common/data.cljc b/common/app/common/data.cljc index 18cfe35dc..be573163b 100644 --- a/common/app/common/data.cljc +++ b/common/app/common/data.cljc @@ -87,7 +87,7 @@ (defn index-of-pred [coll pred] - (loop [c (first coll) + (loop [c (first coll) coll (rest coll) index 0] (if (nil? c) diff --git a/frontend/src/app/main/data/viewer.cljs b/frontend/src/app/main/data/viewer.cljs index bdff939da..cf06925ec 100644 --- a/frontend/src/app/main/data/viewer.cljs +++ b/frontend/src/app/main/data/viewer.cljs @@ -322,7 +322,8 @@ (watch [_ state stream] (let [frames (get-in state [:viewer-data :frames]) index (d/index-of-pred frames #(= (:id %) frame-id))] - (rx/of (go-to-frame-by-index index)))))) + (when index + (rx/of (go-to-frame-by-index index))))))) (defn set-current-frame [frame-id] (ptk/reify ::current-frame diff --git a/frontend/src/app/main/ui/viewer/shapes.cljs b/frontend/src/app/main/ui/viewer/shapes.cljs index f3dcd254a..9ec1931e2 100644 --- a/frontend/src/app/main/ui/viewer/shapes.cljs +++ b/frontend/src/app/main/ui/viewer/shapes.cljs @@ -38,6 +38,7 @@ :navigate (let [frame-id (:destination interaction)] (st/emit! (dv/go-to-frame frame-id))) + nil))) (defn generic-wrapper-factory