diff --git a/src/status_im/components/main_tabs.cljs b/src/status_im/components/main_tabs.cljs index e075308ada..6897002597 100644 --- a/src/status_im/components/main_tabs.cljs +++ b/src/status_im/components/main_tabs.cljs @@ -1,6 +1,7 @@ (ns status-im.components.main-tabs (:require-macros [reagent.ratom :refer [reaction]] - [status-im.utils.views :refer [defview]]) + [status-im.utils.views :refer [defview]] + [cljs.core.async.macros :as am]) (:require [re-frame.core :refer [subscribe dispatch dispatch-sync]] [reagent.core :as r] [status-im.components.react :refer [view @@ -21,7 +22,7 @@ [status-im.components.tabs.styles :as st] [status-im.components.styles :as common-st] [status-im.i18n :refer [label]] - [taoensso.timbre :as log])) + [cljs.core.async :as a])) (def tab-list [{:view-id :chat-list @@ -57,7 +58,7 @@ (dispatch [:on-navigated-to-tab])))))))))) (def tab->index {:chat-list 0 - :discover 1 + :discover 1 :contact-list 2}) (def index->tab (clojure.set/map-invert tab->index)) @@ -70,28 +71,43 @@ n (get-tab-index view-id)] (- n p))) -(defn on-scroll-end [swiped? dragging?] +(defn on-scroll-end [swiped? dragging? scroll-ended] (fn [_ state] + (a/put! scroll-ended true) (when @dragging? (reset! dragging? false) (let [{:strs [index]} (js->clj state)] (reset! swiped? true) (dispatch [:navigate-to-tab (index->tab index)]))))) +(defn start-scrolling-loop + "Loop that synchronizes tabs scrolling to avoid an inconsistent state." + [scroll-start scroll-ended] + (am/go-loop [[swiper to] (a/