diff --git a/src/status_im/utils/utils.cljs b/src/status_im/utils/utils.cljs index 4409c41334..c7d861f042 100644 --- a/src/status_im/utils/utils.cljs +++ b/src/status_im/utils/utils.cljs @@ -126,6 +126,11 @@ (when (string? s) (string/replace s m r))) +(defn safe-nth + [coll index] + (when (number? index) + (nth coll index))) + (defn svg? [some-string] (string/ends-with? some-string ".svg")) diff --git a/src/status_im2/contexts/chat/lightbox/view.cljs b/src/status_im2/contexts/chat/lightbox/view.cljs index c5fd21160b..8c64224f4b 100644 --- a/src/status_im2/contexts/chat/lightbox/view.cljs +++ b/src/status_im2/contexts/chat/lightbox/view.cljs @@ -130,7 +130,7 @@ ;; The initial value of data is the image that was pressed (and not the whole album) in order ;; for the transition animation to execute properly, otherwise it would animate towards ;; outside the screen (even if we have `initialScrollIndex` set). - data (reagent/atom [(nth messages index)]) + data (reagent/atom (if (number? index) [(nth messages index)] [])) scroll-index (reagent/atom index) transparent? (reagent/atom false) set-full-height? (reagent/atom false)