mirror of
https://github.com/status-im/status-react.git
synced 2025-01-09 10:42:53 +00:00
lein-kibit suggestions
This commit is contained in:
parent
c45ffd49d6
commit
529148c101
@ -135,7 +135,7 @@
|
|||||||
:fontSize 12
|
:fontSize 12
|
||||||
:fontFamily font}}
|
:fontFamily font}}
|
||||||
"Active a minute ago"])]
|
"Active a minute ago"])]
|
||||||
(when (not group?)
|
(when-not group?
|
||||||
[view {:style {:position "absolute"
|
[view {:style {:position "absolute"
|
||||||
:top 10
|
:top 10
|
||||||
:right 66}}
|
:right 66}}
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
staged-commands @staged-commands-atom]
|
staged-commands @staged-commands-atom]
|
||||||
[view {:style {:backgroundColor color-white
|
[view {:style {:backgroundColor color-white
|
||||||
:elevation 4}}
|
:elevation 4}}
|
||||||
(when (and staged-commands (< 0 (count staged-commands)))
|
(when (and staged-commands (pos? (count staged-commands)))
|
||||||
[staged-commands-view staged-commands])
|
[staged-commands-view staged-commands])
|
||||||
(if command
|
(if command
|
||||||
[special-input-view command]
|
[special-input-view command]
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
(send-command chat-id command message))}
|
(send-command chat-id command message))}
|
||||||
input-options)
|
input-options)
|
||||||
message]
|
message]
|
||||||
(if (< 0 (count message))
|
(if (pos? (count message))
|
||||||
[touchable-highlight {:on-press (fn []
|
[touchable-highlight {:on-press (fn []
|
||||||
(send-command chat-id command message))
|
(send-command chat-id command message))
|
||||||
:underlay-color :transparent}
|
:underlay-color :transparent}
|
||||||
|
@ -67,8 +67,8 @@
|
|||||||
:marginRight 18
|
:marginRight 18
|
||||||
:width 20
|
:width 20
|
||||||
:height 20}}]
|
:height 20}}]
|
||||||
(when (or (< 0 (count input-message))
|
(when (or (pos? (count input-message))
|
||||||
(< 0 (count @staged-commands-atom)))
|
(pos? (count @staged-commands-atom)))
|
||||||
[touchable-highlight {:on-press (fn []
|
[touchable-highlight {:on-press (fn []
|
||||||
(send @chat input-message))
|
(send @chat input-message))
|
||||||
:underlay-color :transparent}
|
:underlay-color :transparent}
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
(let [suggestions-atom (subscribe [:get-suggestions])]
|
(let [suggestions-atom (subscribe [:get-suggestions])]
|
||||||
(fn []
|
(fn []
|
||||||
(let [suggestions @suggestions-atom]
|
(let [suggestions @suggestions-atom]
|
||||||
(when (not (empty? suggestions))
|
(when (seq suggestions)
|
||||||
[view {:style {:flexDirection "row"
|
[view {:style {:flexDirection "row"
|
||||||
:marginVertical 1
|
:marginVertical 1
|
||||||
:marginHorizontal 0
|
:marginHorizontal 0
|
||||||
|
@ -114,7 +114,7 @@
|
|||||||
:marginLeft 5}}
|
:marginLeft 5}}
|
||||||
timestamp]]
|
timestamp]]
|
||||||
;;; new messages count
|
;;; new messages count
|
||||||
(when (< 0 new-messages-count)
|
(when (pos? new-messages-count)
|
||||||
[view {:style {:position "absolute"
|
[view {:style {:position "absolute"
|
||||||
:top 36
|
:top 36
|
||||||
:right 0
|
:right 0
|
||||||
|
@ -61,6 +61,6 @@
|
|||||||
:fontSize 16
|
:fontSize 16
|
||||||
:fontFamily font
|
:fontFamily font
|
||||||
:color text1-color}}
|
:color text1-color}}
|
||||||
(if (< 0 (count name))
|
(if (pos? (count name))
|
||||||
name
|
name
|
||||||
"Noname")]]])
|
"Noname")]]])
|
||||||
|
@ -273,7 +273,7 @@
|
|||||||
(if-let [command (get-command db text)]
|
(if-let [command (get-command db text)]
|
||||||
(do (dispatch [:set-chat-command (:command command)])
|
(do (dispatch [:set-chat-command (:command command)])
|
||||||
db)
|
db)
|
||||||
(let [msg (when (< 0 (count text))
|
(let [msg (when (pos? (count text))
|
||||||
(if (= chat-id "console")
|
(if (= chat-id "console")
|
||||||
(sign-up-service/send-console-msg text)
|
(sign-up-service/send-console-msg text)
|
||||||
(let [{msg-id :msg-id
|
(let [{msg-id :msg-id
|
||||||
@ -449,8 +449,7 @@
|
|||||||
(register-handler :remove-selected-participants
|
(register-handler :remove-selected-participants
|
||||||
(fn [db [action navigator]]
|
(fn [db [action navigator]]
|
||||||
(log/debug action)
|
(log/debug action)
|
||||||
(let [identities (-> (new-participants-selection db)
|
(let [identities (vec (new-participants-selection db))
|
||||||
(vec))
|
|
||||||
chat-id (current-chat-id db)]
|
chat-id (current-chat-id db)]
|
||||||
(chat-remove-participants chat-id identities)
|
(chat-remove-participants chat-id identities)
|
||||||
(nav-pop navigator)
|
(nav-pop navigator)
|
||||||
@ -468,8 +467,7 @@
|
|||||||
(register-handler :add-new-participants
|
(register-handler :add-new-participants
|
||||||
(fn [db [action navigator]]
|
(fn [db [action navigator]]
|
||||||
(log/debug action)
|
(log/debug action)
|
||||||
(let [identities (-> (new-participants-selection db)
|
(let [identities (vec (new-participants-selection db))
|
||||||
(vec))
|
|
||||||
chat-id (current-chat-id db)]
|
chat-id (current-chat-id db)]
|
||||||
(chat-add-participants chat-id identities)
|
(chat-add-participants chat-id identities)
|
||||||
(nav-pop navigator)
|
(nav-pop navigator)
|
||||||
@ -491,8 +489,7 @@
|
|||||||
(register-handler :create-new-group
|
(register-handler :create-new-group
|
||||||
(fn [db [action group-name navigator]]
|
(fn [db [action group-name navigator]]
|
||||||
(log/debug action)
|
(log/debug action)
|
||||||
(let [identities (-> (new-group-selection db)
|
(let [identities (vec (new-group-selection db))
|
||||||
(vec))
|
|
||||||
group-id (api/start-group-chat identities group-name)
|
group-id (api/start-group-chat identities group-name)
|
||||||
db (create-chat db group-id identities true group-name)]
|
db (create-chat db group-id identities true group-name)]
|
||||||
(dispatch [:show-chat group-id navigator :replace])
|
(dispatch [:show-chat group-id navigator :replace])
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
(defn- get-contact-name [phone-contact]
|
(defn- get-contact-name [phone-contact]
|
||||||
(cstr/join " "
|
(cstr/join " "
|
||||||
(filter #(not (cstr/blank? %))
|
(remove cstr/blank?
|
||||||
[(:givenName phone-contact)
|
[(:givenName phone-contact)
|
||||||
(:middleName phone-contact)
|
(:middleName phone-contact)
|
||||||
(:familyName phone-contact)])))
|
(:familyName phone-contact)])))
|
||||||
|
@ -49,10 +49,7 @@
|
|||||||
(defn execute-commands-js [body]
|
(defn execute-commands-js [body]
|
||||||
(.eval js/window body)
|
(.eval js/window body)
|
||||||
(let [commands (.-commands js/window)]
|
(let [commands (.-commands js/window)]
|
||||||
(dispatch [:set-commands (map (fn [command]
|
(dispatch [:set-commands (map #(update % :command keyword)
|
||||||
(update command :command
|
|
||||||
(fn [command-key]
|
|
||||||
(keyword command-key))))
|
|
||||||
(js->clj commands :keywordize-keys true))])))
|
(js->clj commands :keywordize-keys true))])))
|
||||||
|
|
||||||
(defn load-commands []
|
(defn load-commands []
|
||||||
|
@ -14,8 +14,7 @@
|
|||||||
0))))
|
0))))
|
||||||
|
|
||||||
(defn chat-updated? [db chat-id]
|
(defn chat-updated? [db chat-id]
|
||||||
(->> (db/updated-chat-signal-path chat-id)
|
(get-in db (db/updated-chat-signal-path chat-id)))
|
||||||
(get-in db)))
|
|
||||||
|
|
||||||
(defn update-new-group-selection [db identity add?]
|
(defn update-new-group-selection [db identity add?]
|
||||||
(update-in db db/new-group-path (fn [new-group]
|
(update-in db db/new-group-path (fn [new-group]
|
||||||
|
@ -55,8 +55,7 @@
|
|||||||
(signal-chats-updated db)))))
|
(signal-chats-updated db)))))
|
||||||
|
|
||||||
(defn chats-list []
|
(defn chats-list []
|
||||||
(-> (r/get-all :chats)
|
(r/sorted (r/get-all :chats) :timestamp :desc))
|
||||||
(r/sorted :timestamp :desc)))
|
|
||||||
|
|
||||||
(defn chat-by-id [chat-id]
|
(defn chat-by-id [chat-id]
|
||||||
(-> (r/get-by-field :chats :chat-id chat-id)
|
(-> (r/get-by-field :chats :chat-id chat-id)
|
||||||
@ -69,13 +68,11 @@
|
|||||||
(let [contacts (-> (r/get-by-field :chats :chat-id chat-id)
|
(let [contacts (-> (r/get-by-field :chats :chat-id chat-id)
|
||||||
(r/single)
|
(r/single)
|
||||||
(aget "contacts"))
|
(aget "contacts"))
|
||||||
colors-in-use (->> (.map contacts (fn [object index collection]
|
colors-in-use (set (.map contacts (fn [object index collection]
|
||||||
{:text-color (aget object "text-color")
|
{:text-color (aget object "text-color")
|
||||||
:background-color (aget object "background-color")}))
|
:background-color (aget object "background-color")})))
|
||||||
(set))
|
colors (filter (fn [color]
|
||||||
colors (->> group-chat-colors
|
(not (contains? colors-in-use color))) group-chat-colors)
|
||||||
(filter (fn [color]
|
|
||||||
(not (contains? colors-in-use color)))))
|
|
||||||
new-contacts (mapv (fn [ident {:keys [background text]}]
|
new-contacts (mapv (fn [ident {:keys [background text]}]
|
||||||
{:identity ident
|
{:identity ident
|
||||||
:background-color background
|
:background-color background
|
||||||
@ -87,18 +84,16 @@
|
|||||||
(r/write
|
(r/write
|
||||||
(fn []
|
(fn []
|
||||||
(let [query (include-query :identity identities)
|
(let [query (include-query :identity identities)
|
||||||
chat (-> (r/get-by-field :chats :chat-id chat-id)
|
chat (r/single (r/get-by-field :chats :chat-id chat-id))]
|
||||||
(r/single))]
|
|
||||||
(-> (aget chat "contacts")
|
(-> (aget chat "contacts")
|
||||||
(r/filtered query)
|
(r/filtered query)
|
||||||
(r/delete))))))
|
(r/delete))))))
|
||||||
|
|
||||||
(defn active-group-chats []
|
(defn active-group-chats []
|
||||||
(let [results (-> (r/get-all :chats)
|
(let [results (r/filtered (r/get-all :chats)
|
||||||
(r/filtered "group-chat = true && is-active = true"))]
|
"group-chat = true && is-active = true")]
|
||||||
(->> (.map results (fn [object index collection]
|
(js->clj (.map results (fn [object index collection]
|
||||||
(aget object "chat-id")))
|
(aget object "chat-id"))))))
|
||||||
(js->clj))))
|
|
||||||
|
|
||||||
|
|
||||||
(defn set-chat-active [chat-id active?]
|
(defn set-chat-active [chat-id active?]
|
||||||
@ -107,7 +102,7 @@
|
|||||||
(r/single)
|
(r/single)
|
||||||
(aset "is-active" active?)))))
|
(aset "is-active" active?)))))
|
||||||
|
|
||||||
(comment
|
#_(comment
|
||||||
(active-group-chats)
|
(active-group-chats)
|
||||||
|
|
||||||
|
|
||||||
@ -141,4 +136,4 @@
|
|||||||
(swap! re-frame.db/app-db (fn [db]
|
(swap! re-frame.db/app-db (fn [db]
|
||||||
(create-chat db "A group chat")))
|
(create-chat db "A group chat")))
|
||||||
|
|
||||||
)
|
)
|
||||||
|
@ -91,8 +91,7 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;----------------------------------------------
|
;;;;;;;;;;;;;;;;;;;;----------------------------------------------
|
||||||
|
|
||||||
(defn contacts-list []
|
(defn contacts-list []
|
||||||
(-> (r/get-all :contacts)
|
(r/sorted (r/get-all :contacts) :name :asc))
|
||||||
(r/sorted :name :asc)))
|
|
||||||
|
|
||||||
(defn contacts-list-exclude [exclude-idents]
|
(defn contacts-list-exclude [exclude-idents]
|
||||||
(let [query (exclude-query :whisper-identity exclude-idents)]
|
(let [query (exclude-query :whisper-identity exclude-idents)]
|
||||||
@ -107,8 +106,7 @@
|
|||||||
(r/sorted :name :asc))))
|
(r/sorted :name :asc))))
|
||||||
|
|
||||||
(defn contact-by-identity [identity]
|
(defn contact-by-identity [identity]
|
||||||
(-> (r/get-by-field :contacts :whisper-identity identity)
|
(r/single-cljs (r/get-by-field :contacts :whisper-identity identity)))
|
||||||
(r/single-cljs)))
|
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
|
|
||||||
@ -136,4 +134,4 @@
|
|||||||
|
|
||||||
(:new-group @re-frame.db/app-db)
|
(:new-group @re-frame.db/app-db)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
@ -22,12 +22,10 @@
|
|||||||
:delivery-status nil} true)))))
|
:delivery-status nil} true)))))
|
||||||
|
|
||||||
(defn get-messages [chat-id]
|
(defn get-messages [chat-id]
|
||||||
(-> (r/get-by-field :msgs :chat-id chat-id)
|
(r/sorted (r/get-by-field :msgs :chat-id chat-id) :timestamp :desc))
|
||||||
(r/sorted :timestamp :desc)))
|
|
||||||
|
|
||||||
(defn message-by-id [msg-id]
|
(defn message-by-id [msg-id]
|
||||||
(-> (r/get-by-field :msgs :msg-id msg-id)
|
(r/single-cljs (r/get-by-field :msgs :msg-id msg-id)))
|
||||||
(r/single-cljs)))
|
|
||||||
|
|
||||||
(defn update-message! [{:keys [msg-id] :as msg}]
|
(defn update-message! [{:keys [msg-id] :as msg}]
|
||||||
(log/debug "update-message!" msg)
|
(log/debug "update-message!" msg)
|
||||||
@ -58,4 +56,4 @@
|
|||||||
|
|
||||||
@re-frame.db/app-db
|
@re-frame.db/app-db
|
||||||
|
|
||||||
)
|
)
|
||||||
|
@ -14,8 +14,7 @@
|
|||||||
|
|
||||||
(defn update-identity [db identity]
|
(defn update-identity [db identity]
|
||||||
(let [password (get-in db db/identity-password-path)
|
(let [password (get-in db db/identity-password-path)
|
||||||
encrypted (->> (to-edn-string identity)
|
encrypted (password-encrypt password (to-edn-string identity))]
|
||||||
(password-encrypt password))]
|
|
||||||
(s/put kv/kv-store :identity encrypted)
|
(s/put kv/kv-store :identity encrypted)
|
||||||
(assoc db :user-identity identity)))
|
(assoc db :user-identity identity)))
|
||||||
|
|
||||||
@ -23,10 +22,9 @@
|
|||||||
(let [encrypted (s/get kv/kv-store :identity)
|
(let [encrypted (s/get kv/kv-store :identity)
|
||||||
password (get-in db db/identity-password-path)]
|
password (get-in db db/identity-password-path)]
|
||||||
(when encrypted
|
(when encrypted
|
||||||
(-> (password-decrypt password encrypted)
|
(read-string (password-decrypt password encrypted)))))
|
||||||
(read-string)))))
|
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
|
|
||||||
(stored-identity @re-frame.db/app-db)
|
(stored-identity @re-frame.db/app-db)
|
||||||
)
|
)
|
||||||
|
@ -83,8 +83,7 @@
|
|||||||
|
|
||||||
(defn get-by-field [schema-name field value]
|
(defn get-by-field [schema-name field value]
|
||||||
(let [q (to-query schema-name :eq field value)]
|
(let [q (to-query schema-name :eq field value)]
|
||||||
(-> (.objects realm (name schema-name))
|
(.filtered (.objects realm (name schema-name)) q)))
|
||||||
(.filtered q))))
|
|
||||||
|
|
||||||
(defn get-all [schema-name]
|
(defn get-all [schema-name]
|
||||||
(.objects realm (to-string schema-name)))
|
(.objects realm (to-string schema-name)))
|
||||||
@ -108,9 +107,7 @@
|
|||||||
(js->clj :keywordize-keys true)))
|
(js->clj :keywordize-keys true)))
|
||||||
|
|
||||||
(defn list-to-array [record list-field]
|
(defn list-to-array [record list-field]
|
||||||
(assoc record list-field (-> (get record list-field)
|
(update-in record [list-field] (comp vec vals)))
|
||||||
vals
|
|
||||||
vec)))
|
|
||||||
|
|
||||||
(defn decode-value [{:keys [key value]}]
|
(defn decode-value [{:keys [key value]}]
|
||||||
(read-string value))
|
(read-string value))
|
||||||
@ -119,8 +116,7 @@
|
|||||||
(.delete realm obj))
|
(.delete realm obj))
|
||||||
|
|
||||||
(defn exists? [schema-name field value]
|
(defn exists? [schema-name field value]
|
||||||
(> (.-length (get-by-field schema-name field value))
|
(pos? (.-length (get-by-field schema-name field value))))
|
||||||
0))
|
|
||||||
|
|
||||||
(defn get-count [objs]
|
(defn get-count [objs]
|
||||||
(.-length objs))
|
(.-length objs))
|
||||||
@ -131,4 +127,4 @@
|
|||||||
|
|
||||||
(comment
|
(comment
|
||||||
|
|
||||||
)
|
)
|
||||||
|
@ -23,18 +23,15 @@
|
|||||||
|
|
||||||
(register-sub :get-chat-messages
|
(register-sub :get-chat-messages
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(let [chat-id (-> (current-chat-id @db)
|
(let [chat-id (reaction (current-chat-id @db))
|
||||||
(reaction))
|
chat-updated (reaction (chat-updated? @db @chat-id))]
|
||||||
chat-updated (-> (chat-updated? @db @chat-id)
|
|
||||||
(reaction))]
|
|
||||||
(reaction
|
(reaction
|
||||||
(let [_ @chat-updated]
|
(let [_ @chat-updated]
|
||||||
(get-messages @chat-id))))))
|
(get-messages @chat-id))))))
|
||||||
|
|
||||||
(register-sub :get-current-chat-id
|
(register-sub :get-current-chat-id
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(-> (current-chat-id @db)
|
(reaction (current-chat-id @db))))
|
||||||
(reaction))))
|
|
||||||
|
|
||||||
(register-sub :get-suggestions
|
(register-sub :get-suggestions
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
@ -58,35 +55,29 @@
|
|||||||
|
|
||||||
(register-sub :get-chat-command
|
(register-sub :get-chat-command
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(-> (get-chat-command @db)
|
(reaction (get-chat-command @db))))
|
||||||
(reaction))))
|
|
||||||
|
|
||||||
(register-sub :get-chat-command-content
|
(register-sub :get-chat-command-content
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(-> (get-chat-command-content @db)
|
(reaction (get-chat-command-content @db))))
|
||||||
(reaction))))
|
|
||||||
|
|
||||||
(register-sub :chat-command-request
|
(register-sub :chat-command-request
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(-> (get-chat-command-request @db)
|
(reaction (get-chat-command-request @db))))
|
||||||
(reaction))))
|
|
||||||
|
|
||||||
;; -- Chats list --------------------------------------------------------------
|
;; -- Chats list --------------------------------------------------------------
|
||||||
|
|
||||||
(register-sub :get-chats
|
(register-sub :get-chats
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(let [chats-updated (-> (chats-updated? @db)
|
(let [chats-updated (reaction (chats-updated? @db))]
|
||||||
(reaction))]
|
|
||||||
(reaction
|
(reaction
|
||||||
(let [_ @chats-updated]
|
(let [_ @chats-updated]
|
||||||
(chats-list))))))
|
(chats-list))))))
|
||||||
|
|
||||||
(register-sub :get-current-chat
|
(register-sub :get-current-chat
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(let [current-chat-id (-> (current-chat-id @db)
|
(let [current-chat-id (reaction (current-chat-id @db))
|
||||||
(reaction))
|
chat-updated (reaction (chat-updated? @db @current-chat-id))]
|
||||||
chat-updated (-> (chat-updated? @db @current-chat-id)
|
|
||||||
(reaction))]
|
|
||||||
(reaction
|
(reaction
|
||||||
(let [_ @chat-updated]
|
(let [_ @chat-updated]
|
||||||
(when-let [chat-id @current-chat-id]
|
(when-let [chat-id @current-chat-id]
|
||||||
@ -131,11 +122,9 @@
|
|||||||
|
|
||||||
(register-sub :all-new-contacts
|
(register-sub :all-new-contacts
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(let [current-chat-id (-> (current-chat-id @db)
|
(let [current-chat-id (reaction (current-chat-id @db))
|
||||||
(reaction))
|
chat (reaction (when-let [chat-id @current-chat-id]
|
||||||
chat (-> (when-let [chat-id @current-chat-id]
|
(chat-by-id chat-id)))]
|
||||||
(chat-by-id chat-id))
|
|
||||||
(reaction))]
|
|
||||||
(reaction
|
(reaction
|
||||||
(when @chat
|
(when @chat
|
||||||
(let [current-participants (->> @chat
|
(let [current-participants (->> @chat
|
||||||
@ -145,11 +134,9 @@
|
|||||||
|
|
||||||
(register-sub :current-chat-contacts
|
(register-sub :current-chat-contacts
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(let [current-chat-id (-> (current-chat-id @db)
|
(let [current-chat-id (reaction (current-chat-id @db))
|
||||||
(reaction))
|
chat (reaction (when-let [chat-id @current-chat-id]
|
||||||
chat (-> (when-let [chat-id @current-chat-id]
|
(chat-by-id chat-id)))]
|
||||||
(chat-by-id chat-id))
|
|
||||||
(reaction))]
|
|
||||||
(reaction
|
(reaction
|
||||||
(when @chat
|
(when @chat
|
||||||
(let [current-participants (->> @chat
|
(let [current-participants (->> @chat
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
(ns syng-im.utils.crypt
|
(ns syng-im.utils.crypt
|
||||||
(:require [goog.crypt :refer [byteArrayToHex]])
|
(:require [goog.crypt :refer [byteArrayToHex]]
|
||||||
|
[clojure.string :as s])
|
||||||
(:import goog.crypt.Sha256))
|
(:import goog.crypt.Sha256))
|
||||||
|
|
||||||
(set! js/window.RnRandomBytes (js/require "react-native-randombytes"))
|
(set! js/window.RnRandomBytes (js/require "react-native-randombytes"))
|
||||||
@ -7,7 +8,7 @@
|
|||||||
(def sha-256 (Sha256.))
|
(def sha-256 (Sha256.))
|
||||||
|
|
||||||
(defn bytes-to-str [arr]
|
(defn bytes-to-str [arr]
|
||||||
(apply str (map char arr)))
|
(s/join (map char arr)))
|
||||||
|
|
||||||
(defn str-to-bytes [s]
|
(defn str-to-bytes [s]
|
||||||
(map (comp int) s))
|
(map (comp int) s))
|
||||||
@ -15,8 +16,7 @@
|
|||||||
(defn encrypt [s]
|
(defn encrypt [s]
|
||||||
(.reset sha-256)
|
(.reset sha-256)
|
||||||
(.update sha-256 s)
|
(.update sha-256 s)
|
||||||
(-> (.digest sha-256)
|
(byteArrayToHex (.digest sha-256)))
|
||||||
byteArrayToHex))
|
|
||||||
|
|
||||||
(defn gen-random-bytes [length cb]
|
(defn gen-random-bytes [length cb]
|
||||||
(.randomBytes js/window.RnRandomBytes length (fn [& [err buf]]
|
(.randomBytes js/window.RnRandomBytes length (fn [& [err buf]]
|
||||||
|
@ -3,11 +3,9 @@
|
|||||||
(:require [syng-im.components.realm]))
|
(:require [syng-im.components.realm]))
|
||||||
|
|
||||||
(defn to-datasource [items]
|
(defn to-datasource [items]
|
||||||
(-> (data-source {:rowHasChanged (fn [row1 row2]
|
(clone-with-rows (data-source {:rowHasChanged not=}) items))
|
||||||
(not= row1 row2))})
|
|
||||||
(clone-with-rows items)))
|
|
||||||
|
|
||||||
(defn to-realm-datasource [items]
|
(defn to-realm-datasource [items]
|
||||||
(-> (js/RealmReactNative.ListView.DataSource. (cljs.core/clj->js {:rowHasChanged (fn [row1 row2]
|
(-> (cljs.core/clj->js {:rowHasChanged not=})
|
||||||
(not= row1 row2))}))
|
(js/RealmReactNative.ListView.DataSource.)
|
||||||
(clone-with-rows items)))
|
(clone-with-rows items)))
|
||||||
|
@ -43,8 +43,7 @@
|
|||||||
(.then (fn [response]
|
(.then (fn [response]
|
||||||
(log response)
|
(log response)
|
||||||
(.text response)))
|
(.text response)))
|
||||||
(.then (fn [text]
|
(.then on-success)
|
||||||
(on-success text)))
|
|
||||||
(.catch (or on-error
|
(.catch (or on-error
|
||||||
(fn [error]
|
(fn [error]
|
||||||
(toast (str error))))))))
|
(toast (str error))))))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user