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