implement ConnectionChange call, upgrade status-go
Signed-off-by: Eric Dvorsak <eric@dvorsak.fr>
This commit is contained in:
parent
aa02547815
commit
b1ce44af3a
|
@ -17,7 +17,7 @@ dependencies {
|
||||||
implementation 'com.github.ericwlange:AndroidJSCore:3.0.1'
|
implementation 'com.github.ericwlange:AndroidJSCore:3.0.1'
|
||||||
implementation 'status-im:function:0.0.1'
|
implementation 'status-im:function:0.0.1'
|
||||||
|
|
||||||
String statusGoVersion = 'develop-g228bda9f'
|
String statusGoVersion = 'develop-gabb5df88'
|
||||||
final String statusGoGroup = 'status-im', statusGoName = 'status-go'
|
final String statusGoGroup = 'status-im', statusGoName = 'status-go'
|
||||||
|
|
||||||
// Check if the local status-go jar exists, and compile against that if it does
|
// Check if the local status-go jar exists, and compile against that if it does
|
||||||
|
|
|
@ -699,4 +699,10 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
||||||
public void closeApplication() {
|
public void closeApplication() {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ReactMethod
|
||||||
|
public void connectionChange(final String type, final boolean isExpensive) {
|
||||||
|
Log.d(TAG, "ConnectionChange: " + type + ", is expensive " + isExpensive);
|
||||||
|
Statusgo.ConnectionChange(type, isExpensive ? 1 : 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,6 +403,15 @@ RCT_EXPORT_METHOD(closeApplication) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RCT_EXPORT_METHOD(connectionChange:(NSString *)type
|
||||||
|
isExpensive:(BOOL)isExpensive) {
|
||||||
|
#if DEBUG
|
||||||
|
NSLog(@"ConnectionChange() method called");
|
||||||
|
#endif
|
||||||
|
ConnectionChange((char *) [type UTF8String], isExpensive? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
+ (void)signalEvent:(const char *) signal
|
+ (void)signalEvent:(const char *) signal
|
||||||
{
|
{
|
||||||
if(!signal){
|
if(!signal){
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
<artifactItem>
|
<artifactItem>
|
||||||
<groupId>status-im</groupId>
|
<groupId>status-im</groupId>
|
||||||
<artifactId>status-go-ios-simulator</artifactId>
|
<artifactId>status-go-ios-simulator</artifactId>
|
||||||
<version>develop-g228bda9f</version>
|
<version>develop-gabb5df88</version>
|
||||||
<type>zip</type>
|
<type>zip</type>
|
||||||
<overWrite>true</overWrite>
|
<overWrite>true</overWrite>
|
||||||
<outputDirectory>./</outputDirectory>
|
<outputDirectory>./</outputDirectory>
|
||||||
|
|
|
@ -92,3 +92,6 @@
|
||||||
|
|
||||||
(defn close-application []
|
(defn close-application []
|
||||||
(module-interface/-close-application rns-module))
|
(module-interface/-close-application rns-module))
|
||||||
|
|
||||||
|
(defn connection-change [data]
|
||||||
|
(module-interface/-connection-change rns-module data))
|
||||||
|
|
|
@ -232,6 +232,9 @@
|
||||||
(defn close-application []
|
(defn close-application []
|
||||||
(.closeApplication status))
|
(.closeApplication status))
|
||||||
|
|
||||||
|
(defn connection-change [{:keys [type expensive?]}]
|
||||||
|
(.connectionChange status type expensive?))
|
||||||
|
|
||||||
(defrecord ReactNativeStatus []
|
(defrecord ReactNativeStatus []
|
||||||
module/IReactNativeStatus
|
module/IReactNativeStatus
|
||||||
;; status-go calls
|
;; status-go calls
|
||||||
|
@ -276,4 +279,6 @@
|
||||||
(-should-move-to-internal-storage? [this callback]
|
(-should-move-to-internal-storage? [this callback]
|
||||||
(should-move-to-internal-storage? callback))
|
(should-move-to-internal-storage? callback))
|
||||||
(-close-application [this]
|
(-close-application [this]
|
||||||
(close-application)))
|
(close-application))
|
||||||
|
(-connection-change [this data]
|
||||||
|
(connection-change data)))
|
||||||
|
|
|
@ -60,4 +60,5 @@
|
||||||
(impl/should-move-to-internal-storage? callback))
|
(impl/should-move-to-internal-storage? callback))
|
||||||
(-notify-users [this {:keys [message payload tokens] :as m} callback])
|
(-notify-users [this {:keys [message payload tokens] :as m} callback])
|
||||||
(-add-peer [this enode callback])
|
(-add-peer [this enode callback])
|
||||||
(-close-application [this]))
|
(-close-application [this])
|
||||||
|
(-connection-change [this data]))
|
||||||
|
|
|
@ -20,5 +20,6 @@
|
||||||
(-should-move-to-internal-storage? [this callback])
|
(-should-move-to-internal-storage? [this callback])
|
||||||
(-notify-users [this {:keys [message payload tokens] :as m} callback])
|
(-notify-users [this {:keys [message payload tokens] :as m} callback])
|
||||||
(-add-peer [this enode callback])
|
(-add-peer [this enode callback])
|
||||||
(-close-application [this]))
|
(-close-application [this])
|
||||||
|
(-connection-change [this data]))
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
(ns status-im.network.events
|
||||||
|
(:require [re-frame.core :as re-frame]
|
||||||
|
[status-im.utils.handlers :as handlers]
|
||||||
|
[status-im.network.net-info :as net-info]
|
||||||
|
[status-im.native-module.core :as status]))
|
||||||
|
|
||||||
|
(re-frame/reg-fx
|
||||||
|
::listen-to-network-status
|
||||||
|
(fn [[connection-listener net-info-listener]]
|
||||||
|
(net-info/is-connected? connection-listener)
|
||||||
|
(net-info/net-info net-info-listener)
|
||||||
|
(net-info/add-connection-listener connection-listener)
|
||||||
|
(net-info/add-net-info-listener net-info-listener)))
|
||||||
|
|
||||||
|
(re-frame/reg-fx
|
||||||
|
::notify-status-go
|
||||||
|
(fn [data]
|
||||||
|
(status/connection-change data)))
|
||||||
|
|
||||||
|
(handlers/register-handler-fx
|
||||||
|
:listen-to-network-status
|
||||||
|
(fn []
|
||||||
|
{::listen-to-network-status [#(re-frame/dispatch [::update-connection-status %])
|
||||||
|
#(re-frame/dispatch [::update-network-status %])]}))
|
||||||
|
|
||||||
|
(handlers/register-handler-db
|
||||||
|
::update-connection-status
|
||||||
|
[re-frame/trim-v]
|
||||||
|
(fn [db [is-connected?]]
|
||||||
|
(assoc db :network-status (if is-connected? :online :offline))))
|
||||||
|
|
||||||
|
(handlers/register-handler-fx
|
||||||
|
::update-network-status
|
||||||
|
[re-frame/trim-v]
|
||||||
|
(fn [_ [data]]
|
||||||
|
{::notify-status-go data}))
|
|
@ -1,17 +0,0 @@
|
||||||
(ns status-im.network.handlers
|
|
||||||
(:require [re-frame.core :refer [dispatch debug enrich after]]
|
|
||||||
[status-im.utils.handlers :refer [register-handler]]
|
|
||||||
[status-im.utils.handlers :as u]
|
|
||||||
[status-im.network.net-info :as ni]))
|
|
||||||
|
|
||||||
(register-handler :listen-to-network-status!
|
|
||||||
(u/side-effect!
|
|
||||||
(fn []
|
|
||||||
(let [handler #(dispatch [:update-network-status %])]
|
|
||||||
(ni/init handler)
|
|
||||||
(ni/add-listener handler)))))
|
|
||||||
|
|
||||||
(register-handler :update-network-status
|
|
||||||
(fn [db [_ is-connected?]]
|
|
||||||
(let [status (if is-connected? :online :offline)]
|
|
||||||
(assoc db :network-status status))))
|
|
|
@ -2,13 +2,30 @@
|
||||||
(:require [taoensso.timbre :as log]
|
(:require [taoensso.timbre :as log]
|
||||||
[status-im.ui.components.react :as react-components]))
|
[status-im.ui.components.react :as react-components]))
|
||||||
|
|
||||||
(defn init [callback]
|
(defn is-connected? [callback]
|
||||||
(when react-components/net-info
|
(when react-components/net-info
|
||||||
(.then (.fetch (.-isConnected react-components/net-info))
|
(.then (.fetch (.-isConnected react-components/net-info))
|
||||||
(fn [is-connected?]
|
(fn [is-connected?]
|
||||||
(log/debug "Is connected?" is-connected?)
|
(log/debug "Is connected?" is-connected?)
|
||||||
(callback is-connected?)))))
|
(callback is-connected?)))))
|
||||||
|
|
||||||
(defn add-listener [listener]
|
(defn- wrap-net-info [callback]
|
||||||
|
(fn [info-js]
|
||||||
|
(let [info (js->clj info-js :keywordize-keys true)]
|
||||||
|
(.then (.isConnectionExpensive react-components/net-info)
|
||||||
|
(fn [expensive?]
|
||||||
|
(callback {:type (:type info) :expensive? expensive?}))))))
|
||||||
|
|
||||||
|
(defn net-info [callback]
|
||||||
|
(when react-components/net-info
|
||||||
|
(.then (.getConnectionInfo react-components/net-info)
|
||||||
|
(wrap-net-info callback))))
|
||||||
|
|
||||||
|
(defn add-connection-listener [listener]
|
||||||
(when react-components/net-info
|
(when react-components/net-info
|
||||||
(.addEventListener (.-isConnected react-components/net-info) "connectionChange" listener)))
|
(.addEventListener (.-isConnected react-components/net-info) "connectionChange" listener)))
|
||||||
|
|
||||||
|
(defn add-net-info-listener [listener]
|
||||||
|
(when react-components/net-info
|
||||||
|
(.addEventListener react-components/net-info "connectionChange"
|
||||||
|
(wrap-net-info listener))))
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
status-im.commands.handlers.jail
|
status-im.commands.handlers.jail
|
||||||
status-im.commands.events.loading
|
status-im.commands.events.loading
|
||||||
status-im.commands.handlers.debug
|
status-im.commands.handlers.debug
|
||||||
status-im.network.handlers
|
status-im.network.events
|
||||||
status-im.protocol.handlers
|
status-im.protocol.handlers
|
||||||
status-im.ui.screens.accounts.events
|
status-im.ui.screens.accounts.events
|
||||||
status-im.ui.screens.accounts.login.events
|
status-im.ui.screens.accounts.login.events
|
||||||
|
@ -226,7 +226,7 @@
|
||||||
:dispatch-n [[:initialize-db]
|
:dispatch-n [[:initialize-db]
|
||||||
[:load-accounts]
|
[:load-accounts]
|
||||||
[:check-console-chat]
|
[:check-console-chat]
|
||||||
[:listen-to-network-status!]
|
[:listen-to-network-status]
|
||||||
[:initialize-crypt]
|
[:initialize-crypt]
|
||||||
[:initialize-geth]]}))
|
[:initialize-geth]]}))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue