[#10811] There should be an option to continue opening suspicious urls

This commit is contained in:
andrey 2020-06-26 12:42:15 +02:00
parent 2110446d29
commit 96adbd6185
No known key found for this signature in database
GPG Key ID: 89B67245FD2F0272
5 changed files with 27 additions and 18 deletions

View File

@ -139,6 +139,13 @@
(update-browser (assoc browser :history-index (dec history-index)))
(resolve-url nil)))))
(fx/defn ignore-unsafe
{:events [:browser/ignore-unsafe]}
[cofx]
(let [browser (get-current-browser (:db cofx))
host (http/url-host (get-current-url browser))]
(update-browser cofx (assoc browser :ignore-unsafe host))))
(defn can-go-forward? [{:keys [history-index history]}]
(< history-index (dec (count history))))

View File

@ -3,8 +3,7 @@
(def container
{:justify-content :center
:flex 1
:background-color colors/gray-lighter})
:flex 1})
(def container-root-view
{:flex 1
@ -26,6 +25,4 @@
{:color colors/blue})
(def buttons-container
{:flex-direction :row
:justify-content :center
:margin-top 24})
{:margin 24})

View File

@ -2,10 +2,10 @@
(:require [re-frame.core :as re-frame]
[status-im.i18n :as i18n]
[status-im.ui.components.colors :as colors]
[status-im.ui.components.common.common :as components.common]
[status-im.ui.components.icons.vector-icons :as vector-icons]
[status-im.ui.components.react :as react]
[status-im.ui.screens.browser.site-blocked.styles :as styles])
[status-im.ui.screens.browser.site-blocked.styles :as styles]
[quo.core :as quo])
(:require-macros [status-im.utils.views :as views]))
(views/defview view [{:keys [can-go-back?]}]
@ -16,16 +16,19 @@
[vector-icons/icon :main-icons/info {:color colors/red}]
[react/text {:style styles/title-text}
(i18n/label :t/browsing-site-blocked-title)]
[react/nested-text {:style styles/description-text}
[react/nested-text {:style styles/description-text}
(i18n/label :t/browsing-site-blocked-description1)
[{:on-press #(.openURL ^js react/linking "status-im://chat/public/status")
:style styles/chat-link-text}
"#status"]
(i18n/label :t/browsing-site-blocked-description2)]
[react/view styles/buttons-container
[components.common/button {:on-press (fn []
(let [handler (if can-go-back?
:browser.ui/previous-page-button-pressed
:navigate-back)]
(re-frame/dispatch [handler])))
:label (i18n/label :t/browsing-site-blocked-go-back)}]]]])
[quo/button {:on-press (fn []
(let [handler (if can-go-back?
:browser.ui/previous-page-button-pressed
:navigate-back)]
(re-frame/dispatch [handler])))}
(i18n/label :t/browsing-site-blocked-go-back)]]
[quo/button {:theme :negative
:on-press #(re-frame/dispatch [:browser/ignore-unsafe])}
(i18n/label :t/continue-anyway)]]])

View File

@ -105,7 +105,7 @@
;; should-component-update is called only when component's props are changed,
;; that's why it can't be used in `browser`, because `url` comes from subs
(views/defview browser-component
[{:keys [error? url browser browser-id unsafe? can-go-back?
[{:keys [error? url browser browser-id unsafe? can-go-back? ignore-unsafe
can-go-forward? resolving? network-id url-original
show-permission show-tooltip dapp? name dapps-account]}]
{:should-component-update (fn [_ _ args]
@ -114,7 +114,7 @@
[react/view {:flex 1
:elevation -10}
[react/view components.styles/flex
(if unsafe?
(if (and unsafe? (not= (http/url-host url) ignore-unsafe))
[site-blocked.views/view {:can-go-back? can-go-back?
:site browser-id}]
[components.webview/webview
@ -148,7 +148,7 @@
(views/defview browser []
(views/letsubs [window-width [:dimensions/window-width]
{:keys [browser-id dapp? name unsafe?] :as browser} [:get-current-browser]
{:keys [browser-id dapp? name unsafe? ignore-unsafe] :as browser} [:get-current-browser]
{:keys [url error? loading? url-editing? show-tooltip show-permission resolving?]} [:browser/options]
dapps-account [:dapps-account]
network-id [:chain-id]]
@ -167,6 +167,7 @@
:browser browser
:browser-id browser-id
:unsafe? unsafe?
:ignore-unsafe ignore-unsafe
:can-go-back? can-go-back?
:can-go-forward? can-go-forward?
:resolving? resolving?

View File

@ -1157,5 +1157,6 @@
"tx-fail-description2" : "This transaction is likely to fail. Set a custom network fee to sign at your own risk.",
"set-custom-fee" : "Set custom fee",
"not-enough-snt": "Not enough SNT",
"set-max": "Set max"
"set-max": "Set max",
"continue-anyway": "Continue anyway"
}