Skip to content

Commit

Permalink
[#10811] There should be an option to continue opening suspicious urls
Browse files Browse the repository at this point in the history
  • Loading branch information
flexsurfer committed Jul 2, 2020
1 parent 2110446 commit 96adbd6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
7 changes: 7 additions & 0 deletions src/status_im/browser/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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))))

Expand Down
7 changes: 2 additions & 5 deletions src/status_im/ui/screens/browser/site_blocked/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

(def container
{:justify-content :center
:flex 1
:background-color colors/gray-lighter})
:flex 1})

(def container-root-view
{:flex 1
Expand All @@ -26,6 +25,4 @@
{:color colors/blue})

(def buttons-container
{:flex-direction :row
:justify-content :center
:margin-top 24})
{:margin 24})
21 changes: 12 additions & 9 deletions src/status_im/ui/screens/browser/site_blocked/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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?]}]
Expand All @@ -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)]]])
7 changes: 4 additions & 3 deletions src/status_im/ui/screens/browser/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down Expand Up @@ -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]]
Expand All @@ -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?
Expand Down
3 changes: 2 additions & 1 deletion translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 96adbd6

Please sign in to comment.