jail component

This commit is contained in:
Roman Volosovskyi 2016-06-10 17:04:12 +03:00
parent 13a40fae93
commit 3aef0f2d9c
2 changed files with 23 additions and 13 deletions

View File

@ -5,7 +5,8 @@
[status-im.components.react :as r] [status-im.components.react :as r]
[status-im.utils.utils :refer [http-get toast]] [status-im.utils.utils :refer [http-get toast]]
[clojure.string :as s] [clojure.string :as s]
[status-im.persistence.realm :as realm])) [status-im.persistence.realm :as realm]
[status-im.components.jail :as j]))
(defn reg-handler (defn reg-handler
([name handler] (reg-handler name nil handler)) ([name handler] (reg-handler name nil handler))
@ -42,12 +43,6 @@
;; todo tbd hashing algorithm ;; todo tbd hashing algorithm
(hash file)) (hash file))
(defn get-jail []
(.-Jail (.-NativeModules r/react)))
(defn parse [file success-callback fail-callback]
(.parse (get-jail) file success-callback fail-callback))
(defn json->clj [json] (defn json->clj [json]
(js->clj (.parse js/JSON json) :keywordize-keys true)) (js->clj (.parse js/JSON json) :keywordize-keys true))
@ -69,12 +64,12 @@
:icon "icon_lock_white"}}}) :icon "icon_lock_white"}}})
(defn parse-commands! [_ [identity file]] (defn parse-commands! [_ [identity file]]
(parse file (j/parse identity file
(fn [result] (fn [result]
(let [commands (json->clj result)] (let [commands (json->clj result)]
;; todo use commands from jail ;; todo use commands from jail
(dispatch [::add-commands identity file res]))) (dispatch [::add-commands identity file res])))
#(dispatch [::loading-failed! identity ::error-in-jail %]))) #(dispatch [::loading-failed! identity ::error-in-jail %])))
(defn validate-hash (defn validate-hash
[db [identity file]] [db [identity file]]

View File

@ -0,0 +1,15 @@
(ns status-im.components.jail
(:require [status-im.components.react :as r]))
(def jail (.-Jail (.-NativeModules r/react)))
(defn parse [chat-id file success-callback fail-callback]
(.parse jail chat-id file success-callback fail-callback))
(defn call
[chat-id path params callback]
(.call jail chat-id (clj->js path) (clj->js params) callback))
(defn add-listener
[chat-id callback]
(.addListener jail chat-id callback))