Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Andrey Shovkoplyas 2019-09-04 12:31:49 +02:00
parent e7fa010088
commit 1475bb6cf6
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
1 changed files with 8 additions and 1 deletions

View File

@ -24,6 +24,12 @@
[status-im.utils.slurp :refer [slurp]]
[status-im.utils.views :as views]))
(def timeout (atom {}))
(defn debounce [event]
(when @timeout (js/clearTimeout @timeout))
(reset! timeout (js/setTimeout #(re-frame/dispatch event) 500)))
(def browser-config-edn
(slurp "./src/status_im/utils/browser_config.edn"))
@ -59,6 +65,7 @@
{:browser? true}
[toolbar.view/nav-button
(actions/close (fn []
(when @timeout (js/clearTimeout @timeout))
(re-frame/dispatch [:navigate-back])
(when error?
(re-frame/dispatch [:browser.ui/remove-browser-pressed browser-id]))))]
@ -130,7 +137,7 @@
:bounces false
:local-storage-enabled true
:render-error web-view-error
:on-navigation-state-change #(re-frame/dispatch [:browser/navigation-state-changed % error?])
:on-navigation-state-change #(debounce [:browser/navigation-state-changed % error?])
:on-bridge-message #(re-frame/dispatch [:browser/bridge-message-received %])
:on-load #(re-frame/dispatch [:browser/loading-started])
:on-error #(re-frame/dispatch [:browser/error-occured])