[#5278][Android] persist webview state during session
This commit is contained in:
parent
434046fe9d
commit
48d81a4f95
1
.env
1
.env
|
@ -16,3 +16,4 @@ INSTABUG_SURVEYS=1
|
||||||
GROUP_CHATS_ENABLED=0
|
GROUP_CHATS_ENABLED=0
|
||||||
USE_SYM_KEY=0
|
USE_SYM_KEY=0
|
||||||
SPAM_BUTTON_DETECTION_ENABLED=1
|
SPAM_BUTTON_DETECTION_ENABLED=1
|
||||||
|
CACHED_WEBVIEWS_ENABLED=1
|
||||||
|
|
|
@ -17,3 +17,4 @@ GROUP_CHATS_ENABLED=0
|
||||||
USE_SYM_KEY=0
|
USE_SYM_KEY=0
|
||||||
SPAM_BUTTON_DETECTION_ENABLED=1
|
SPAM_BUTTON_DETECTION_ENABLED=1
|
||||||
MAINNET_WARNING_ENABLED=1
|
MAINNET_WARNING_ENABLED=1
|
||||||
|
CACHED_WEBVIEWS_ENABLED=1
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -56,7 +56,7 @@
|
||||||
"react-native-tcp": "3.3.0",
|
"react-native-tcp": "3.3.0",
|
||||||
"react-native-testfairy": "2.10.0",
|
"react-native-testfairy": "2.10.0",
|
||||||
"react-native-udp": "2.2.1",
|
"react-native-udp": "2.2.1",
|
||||||
"react-native-webview-bridge": "https://github.com/status-im/react-native-webview-bridge.git",
|
"react-native-webview-bridge": "git+https://github.com/status-im/react-native-webview-bridge.git#feature/cached-webviews",
|
||||||
"realm": "2.3.3",
|
"realm": "2.3.3",
|
||||||
"rn-snoopy": "https://github.com/status-im/rn-snoopy.git",
|
"rn-snoopy": "https://github.com/status-im/rn-snoopy.git",
|
||||||
"string_decoder": "0.10.31",
|
"string_decoder": "0.10.31",
|
||||||
|
|
|
@ -1,9 +1,28 @@
|
||||||
(ns status-im.ui.components.webview-bridge
|
(ns status-im.ui.components.webview-bridge
|
||||||
(:require [reagent.core :as reagent]
|
(:require [reagent.core :as reagent]
|
||||||
[status-im.react-native.js-dependencies :as js-dependencies]))
|
[status-im.react-native.js-dependencies :as js-dependencies]
|
||||||
|
[reagent.core :as reagent.core]
|
||||||
|
[status-im.utils.platform :as platform]
|
||||||
|
[status-im.utils.config :as config]))
|
||||||
|
|
||||||
(def webview-bridge-class
|
(def webview-bridge-class
|
||||||
(reagent/adapt-react-class (.-default js-dependencies/webview-bridge)))
|
(reagent/adapt-react-class (.-default js-dependencies/webview-bridge)))
|
||||||
|
|
||||||
(defn webview-bridge [opts]
|
(def module (.-WebViewBridgeModule (.-NativeModules js-dependencies/react-native)))
|
||||||
[webview-bridge-class opts])
|
|
||||||
|
(defn webview-bridge [{:keys [dapp? dapp-name] :as opts}]
|
||||||
|
(if (and config/cached-webviews-enabled? platform/android? dapp?)
|
||||||
|
(reagent.core/create-class
|
||||||
|
(let [dapp-name-sent? (reagent.core/atom false)]
|
||||||
|
{:component-will-mount
|
||||||
|
(fn []
|
||||||
|
;; unfortunately it's impossible to pass some initial params
|
||||||
|
;; to view, that's why we have to pass dapp-name to the module
|
||||||
|
;; before showing webview
|
||||||
|
(.setCurrentDapp module dapp-name
|
||||||
|
(fn [] (reset! dapp-name-sent? true))))
|
||||||
|
:reagent-render
|
||||||
|
(fn [opts]
|
||||||
|
(when @dapp-name-sent?
|
||||||
|
[webview-bridge-class opts]))}))
|
||||||
|
[webview-bridge-class opts]))
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
(views/defview browser []
|
(views/defview browser []
|
||||||
(views/letsubs [webview (atom nil)
|
(views/letsubs [webview (atom nil)
|
||||||
{:keys [address]} [:get-current-account]
|
{:keys [address]} [:get-current-account]
|
||||||
{:keys [browser-id] :as browser} [:get-current-browser]
|
{:keys [browser-id dapp? name] :as browser} [:get-current-browser]
|
||||||
{:keys [error? loading? url-editing? show-tooltip]} [:get :browser/options]
|
{:keys [error? loading? url-editing? show-tooltip]} [:get :browser/options]
|
||||||
rpc-url [:get :rpc-url]
|
rpc-url [:get :rpc-url]
|
||||||
network-id [:get-network-id]]
|
network-id [:get-network-id]]
|
||||||
|
@ -101,7 +101,9 @@
|
||||||
:handler #(re-frame/dispatch [:navigate-to-modal :wallet-modal])}]]]
|
:handler #(re-frame/dispatch [:navigate-to-modal :wallet-modal])}]]]
|
||||||
[react/view components.styles/flex
|
[react/view components.styles/flex
|
||||||
[components.webview-bridge/webview-bridge
|
[components.webview-bridge/webview-bridge
|
||||||
{:ref #(reset! webview %)
|
{:dapp? dapp?
|
||||||
|
:dapp-name name
|
||||||
|
:ref #(reset! webview %)
|
||||||
:source {:uri url}
|
:source {:uri url}
|
||||||
:java-script-enabled true
|
:java-script-enabled true
|
||||||
:bounces false
|
:bounces false
|
||||||
|
|
|
@ -44,3 +44,4 @@
|
||||||
(def spam-button-detection-enabled? (enabled? (get-config :SPAM_BUTTON_DETECTION_ENABLED "0")))
|
(def spam-button-detection-enabled? (enabled? (get-config :SPAM_BUTTON_DETECTION_ENABLED "0")))
|
||||||
(def mainnet-warning-enabled? (enabled? (get-config :MAINNET_WARNING_ENABLED 0)))
|
(def mainnet-warning-enabled? (enabled? (get-config :MAINNET_WARNING_ENABLED 0)))
|
||||||
(def in-app-notifications-enabled? (enabled? (get-config :IN_APP_NOTIFICATIONS_ENABLED 0)))
|
(def in-app-notifications-enabled? (enabled? (get-config :IN_APP_NOTIFICATIONS_ENABLED 0)))
|
||||||
|
(def cached-webviews-enabled? (enabled? (get-config :CACHED_WEBVIEWS_ENABLED 0)))
|
||||||
|
|
Loading…
Reference in New Issue