[#4201] Remove browser item from home on back button if current page has error

Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
psdp 2018-05-21 13:50:55 +00:00 committed by Julien Eluard
parent 5f430d2cc8
commit d4d4406341
No known key found for this signature in database
GPG Key ID: 6FD7DB5437FCBEF6
2 changed files with 12 additions and 4 deletions

View File

@ -12,13 +12,15 @@
(spec/def :browser/fullscreen? (spec/nilable boolean?))
(spec/def :browser/can-go-back? (spec/nilable boolean?))
(spec/def :browser/can-go-forward? (spec/nilable boolean?))
(spec/def :browser/error? (spec/nilable boolean?))
(spec/def :browser/options
(allowed-keys
:opt-un [:browser/browser-id
:browser/can-go-back?
:browser/can-go-forward?
:browser/fullscreen?]))
:browser/fullscreen?
:browser/error?]))
(spec/def :browser/browser
(allowed-keys

View File

@ -79,15 +79,19 @@
(views/defview browser []
(views/letsubs [webview (atom nil)
{:keys [address]} [:get-current-account]
{:keys [dapp? contact url] :as browser} [:get-current-browser]
{:keys [can-go-back? can-go-forward?]} [:get :browser/options]
{:keys [dapp? contact url browser-id] :as browser} [:get-current-browser]
{:keys [can-go-back? can-go-forward? error?]} [:get :browser/options]
extra-js [:web-view-extra-js]
rpc-url [:get :rpc-url]
network-id [:get-network-id]]
[react/keyboard-avoiding-view styles/browser
[status-bar/status-bar]
[toolbar.view/toolbar {}
[toolbar.view/nav-button-with-count actions/default-close]
[toolbar.view/nav-button-with-count
(actions/close (fn []
(re-frame/dispatch [:navigate-back])
(when error?
(re-frame/dispatch [:remove-browser browser-id]))))]
(if dapp?
[toolbar-content-dapp contact]
[toolbar-content browser])]
@ -102,6 +106,8 @@
:render-error web-view-error
:render-loading web-view-loading
:on-navigation-state-change #(on-navigation-change % browser)
:on-load #(re-frame/dispatch [:update-browser-options {:error? false}])
:on-error #(re-frame/dispatch [:update-browser-options {:error? true}])
:injected-on-start-loading-java-script (str js-res/web3
js-res/jquery
(get-inject-js url)