mirror of
https://github.com/status-im/status-react.git
synced 2025-02-19 22:28:40 +00:00
contacts handlers
Former-commit-id: 73d3fdb3e6e54192520750988317412d407df66f
This commit is contained in:
parent
a2467348e3
commit
8fb71e46b7
@ -64,9 +64,9 @@
|
|||||||
|
|
||||||
(defn on-action-selected [position]
|
(defn on-action-selected [position]
|
||||||
(case position
|
(case position
|
||||||
0 (dispatch [:show-add-participants #_navigator])
|
0 (dispatch [:show-add-participants])
|
||||||
1 (dispatch [:show-remove-participants #_navigator])
|
1 (dispatch [:show-remove-participants])
|
||||||
2 (dispatch [:leave-group-chat #_navigator])))
|
2 (dispatch [:leave-group-chat])))
|
||||||
|
|
||||||
(defn overlay [{:keys [on-click-outside]} items]
|
(defn overlay [{:keys [on-click-outside]} items]
|
||||||
[view st/actions-overlay
|
[view st/actions-overlay
|
||||||
@ -97,21 +97,18 @@
|
|||||||
:icon :menu_group
|
:icon :menu_group
|
||||||
:icon-style {:width 25
|
:icon-style {:width 25
|
||||||
:height 19}
|
:height 19}
|
||||||
:handler nil #_#(dispatch [:show-add-participants
|
:handler #(dispatch [:show-add-participants])}
|
||||||
navigator])}
|
|
||||||
{:title "Remove Contact from chat"
|
{:title "Remove Contact from chat"
|
||||||
:subtitle "Alex, John"
|
:subtitle "Alex, John"
|
||||||
:icon :search_gray_copy
|
:icon :search_gray_copy
|
||||||
:icon-style {:width 17
|
:icon-style {:width 17
|
||||||
:height 17}
|
:height 17}
|
||||||
:handler nil #_#(dispatch
|
:handler #(dispatch [:show-remove-participants])}
|
||||||
[:show-remove-participants navigator])}
|
|
||||||
{:title "Leave Chat"
|
{:title "Leave Chat"
|
||||||
:icon :muted
|
:icon :muted
|
||||||
:icon-style {:width 18
|
:icon-style {:width 18
|
||||||
:height 21}
|
:height 21}
|
||||||
:handler nil #_#(dispatch [:leave-group-chat
|
:handler #(dispatch [:leave-group-chat])}
|
||||||
navigator])}
|
|
||||||
{:title "Settings"
|
{:title "Settings"
|
||||||
:subtitle "Not implemented"
|
:subtitle "Not implemented"
|
||||||
:icon :settings
|
:icon :settings
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
:autoFocus true
|
:autoFocus true
|
||||||
:placeholder "Type your search tags here"
|
:placeholder "Type your search tags here"
|
||||||
:onSubmitEditing (fn [e]
|
:onSubmitEditing (fn [e]
|
||||||
(let [search (aget e "nativeEvent" "text")
|
(let [search (aget e "nativeEvent" "text")
|
||||||
hashtags (get-hashtags search)]
|
hashtags (get-hashtags search)]
|
||||||
(dispatch [:broadcast-status search hashtags])))}]
|
(dispatch [:broadcast-status search hashtags])))}]
|
||||||
[view
|
[view
|
||||||
@ -50,25 +50,26 @@
|
|||||||
(dispatch [:updated-discoveries]))))
|
(dispatch [:updated-discoveries]))))
|
||||||
|
|
||||||
(defn discovery [{:keys [navigator]}]
|
(defn discovery [{:keys [navigator]}]
|
||||||
|
[]
|
||||||
(let [showSearch (r/atom false)]
|
(let [showSearch (r/atom false)]
|
||||||
(fn []
|
(fn []
|
||||||
[view {:style {:flex 1
|
[view {:style {:flex 1
|
||||||
:backgroundColor "#eef2f5"}}
|
:backgroundColor "#eef2f5"}}
|
||||||
[toolbar {:style st/discovery-toolbar
|
[toolbar {:style st/discovery-toolbar
|
||||||
:navigator navigator
|
:navigator navigator
|
||||||
:nav-action {:image {:source {:uri "icon_hamburger"}
|
:nav-action {:image {:source {:uri "icon_hamburger"}
|
||||||
:style {:width 16
|
:style {:width 16
|
||||||
:height 12}}
|
:height 12}}
|
||||||
:handler create-fake-discovery}
|
:handler create-fake-discovery}
|
||||||
:title "Add Participants"
|
:title "Add Participants"
|
||||||
:content (title-content @showSearch)
|
:content (title-content @showSearch)
|
||||||
:action {:image {:source {:uri "icon_search"}
|
:action {:image {:source {:uri "icon_search"}
|
||||||
:style {:width 17
|
:style {:width 17
|
||||||
:height 17}}
|
:height 17}}
|
||||||
:handler (fn []
|
:handler (fn []
|
||||||
(if @showSearch
|
(if @showSearch
|
||||||
(reset! showSearch false)
|
(reset! showSearch false)
|
||||||
(reset! showSearch true)))}}]
|
(reset! showSearch true)))}}]
|
||||||
[scroll-view {:style {}}
|
[scroll-view {:style {}}
|
||||||
[view {:style st/section-spacing}
|
[view {:style st/section-spacing}
|
||||||
[text {:style st/discovery-subtitle} "Popular tags"]]
|
[text {:style st/discovery-subtitle} "Popular tags"]]
|
||||||
@ -76,7 +77,3 @@
|
|||||||
[view {:style st/section-spacing}
|
[view {:style st/section-spacing}
|
||||||
[text {:style st/discovery-subtitle} "Recent"]]
|
[text {:style st/discovery-subtitle} "Recent"]]
|
||||||
[discovery-recent]]])))
|
[discovery-recent]]])))
|
||||||
(comment
|
|
||||||
(def page-width (aget (natal-shell.dimensions/get "window") "width"))
|
|
||||||
(def page-height (aget (natal-shell.dimensions/get "window") "height"))
|
|
||||||
)
|
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
(ns syng-im.contacts.handlers
|
(ns syng-im.contacts.handlers
|
||||||
(:require [re-frame.core :refer [register-handler after]]
|
(:require [re-frame.core :refer [register-handler after dispatch]]
|
||||||
[syng-im.models.contacts :as contacts]))
|
[syng-im.models.contacts :as contacts]
|
||||||
|
[syng-im.utils.crypt :refer [encrypt]]
|
||||||
|
[clojure.string :as s]
|
||||||
|
[syng-im.utils.utils :refer [http-post]]
|
||||||
|
[syng-im.utils.phone-number :refer [format-phone-number]]))
|
||||||
|
|
||||||
|
(defn side-effect! [handler]
|
||||||
|
(fn [db params]
|
||||||
|
(handler db params)
|
||||||
|
db))
|
||||||
|
|
||||||
(defn save-contact
|
(defn save-contact
|
||||||
[_ [_ contact]]
|
[_ [_ contact]]
|
||||||
@ -11,4 +20,82 @@
|
|||||||
(update db :contacts conj contact))
|
(update db :contacts conj contact))
|
||||||
((after save-contact))))
|
((after save-contact))))
|
||||||
|
|
||||||
|
(defn load-contacts! [db _]
|
||||||
|
(let [contacts (contacts/get-contacts)]
|
||||||
|
(assoc db :contacts contacts)))
|
||||||
|
|
||||||
|
(register-handler :load-syng-contacts load-contacts!)
|
||||||
|
|
||||||
|
(def react-native-contacts (js/require "react-native-contacts"))
|
||||||
|
|
||||||
|
(defn contact-name [contact]
|
||||||
|
(->> contact
|
||||||
|
((juxt :givenName :middleName :familyName))
|
||||||
|
(remove s/blank?)
|
||||||
|
(s/join " ")))
|
||||||
|
|
||||||
|
(defn normalize-phone-contacts [contacts]
|
||||||
|
(let [contacts' (js->clj contacts :keywordize-keys true)]
|
||||||
|
(map (fn [{:keys [thumbnailPath phoneNumbers] :as contact}]
|
||||||
|
{:name (contact-name contact)
|
||||||
|
:photo-path thumbnailPath
|
||||||
|
:phone-numbers phoneNumbers}) contacts')))
|
||||||
|
|
||||||
|
(defn fetch-contacts-from-phone!
|
||||||
|
[_ _]
|
||||||
|
(.getAll react-native-contacts
|
||||||
|
(fn [error contacts]
|
||||||
|
(if error
|
||||||
|
(dispatch [:error-on-fetching-loading error])
|
||||||
|
(let [contacts' (normalize-phone-contacts contacts)]
|
||||||
|
(dispatch [:get-contacts-identities contacts']))))))
|
||||||
|
|
||||||
|
(register-handler :sync-contacts
|
||||||
|
(side-effect! fetch-contacts-from-phone!))
|
||||||
|
|
||||||
|
(defn get-contacts-by-hash [contacts]
|
||||||
|
(->> contacts
|
||||||
|
(mapcat (fn [{:keys [phone-numbers] :as contact}]
|
||||||
|
(map (fn [{:keys [number]}]
|
||||||
|
(let [number' (format-phone-number number)]
|
||||||
|
[(encrypt number')
|
||||||
|
(-> contact
|
||||||
|
(assoc :phone-number number')
|
||||||
|
(dissoc :phone-numbers))]))
|
||||||
|
phone-numbers)))
|
||||||
|
(into {})))
|
||||||
|
|
||||||
|
(defn add-identity [contacts-by-hash contacts]
|
||||||
|
(map (fn [{:keys [phone-number-hash whisper-identity]}]
|
||||||
|
(let [contact (contacts-by-hash phone-number-hash)]
|
||||||
|
(assoc contact :whisper-identity whisper-identity)))
|
||||||
|
(js->clj contacts)))
|
||||||
|
|
||||||
|
(defn request-stored-contacts [contacts]
|
||||||
|
(let [contacts-by-hash (get-contacts-by-hash contacts)
|
||||||
|
data (keys contacts-by-hash)]
|
||||||
|
(http-post "get-contacts" {:phone-number-hashes data}
|
||||||
|
(fn [{:keys [contacts]}]
|
||||||
|
(let [contacts' (add-identity contacts-by-hash contacts)]
|
||||||
|
(dispatch [:add-contacts contacts']))))))
|
||||||
|
|
||||||
|
(defn get-identities-by-contacts! [_ [_ contacts]]
|
||||||
|
(request-stored-contacts contacts))
|
||||||
|
|
||||||
|
(register-handler :get-contacts-identities
|
||||||
|
(side-effect! get-identities-by-contacts!))
|
||||||
|
|
||||||
|
(defn save-contacts! [{:keys [new-contacts]} _]
|
||||||
|
(contacts/save-syng-contacts new-contacts))
|
||||||
|
|
||||||
|
(defn add-new-contacts
|
||||||
|
[{:keys [contacts] :as db} [_ new-contacts]]
|
||||||
|
(let [identities (set (map :whisper-identity contacts))
|
||||||
|
new-contacts' (remove #(identities (:whisper-identity %)) new-contacts)]
|
||||||
|
(-> db
|
||||||
|
(update :contacts concat new-contacts')
|
||||||
|
(assoc :new-contacts new-contacts'))))
|
||||||
|
|
||||||
|
(register-handler :add-contacts
|
||||||
|
(after save-contacts!)
|
||||||
|
add-new-contacts)
|
||||||
|
@ -11,10 +11,11 @@
|
|||||||
[syng-im.contacts.views.contact :refer [contact-view]]
|
[syng-im.contacts.views.contact :refer [contact-view]]
|
||||||
[syng-im.components.styles :refer [toolbar-background2]]
|
[syng-im.components.styles :refer [toolbar-background2]]
|
||||||
[syng-im.components.toolbar :refer [toolbar]]
|
[syng-im.components.toolbar :refer [toolbar]]
|
||||||
[syng-im.contacts.styles :as st]))
|
[syng-im.contacts.styles :as st]
|
||||||
|
[syng-im.utils.listview :as lw]))
|
||||||
|
|
||||||
(defn render-row [row _ _]
|
(defn render-row [row _ _]
|
||||||
(list-item [contact-view (js->clj row :keywordize-keys true)]))
|
(list-item [contact-view row]))
|
||||||
|
|
||||||
(defn get-data-source [contacts]
|
(defn get-data-source [contacts]
|
||||||
(clone-with-rows (data-source {:rowHasChanged not=}) contacts))
|
(clone-with-rows (data-source {:rowHasChanged not=}) contacts))
|
||||||
@ -22,14 +23,14 @@
|
|||||||
(defn contact-list-toolbar []
|
(defn contact-list-toolbar []
|
||||||
[toolbar {:title "Contacts"
|
[toolbar {:title "Contacts"
|
||||||
:background-color toolbar-background2
|
:background-color toolbar-background2
|
||||||
:action {:image {:source {:uri :icon_search}
|
:action {:image {:source {:uri :icon_search}
|
||||||
:style st/search-icon}
|
:style st/search-icon}
|
||||||
:handler (fn [])}}])
|
:handler (fn [])}}])
|
||||||
|
|
||||||
(defn contact-list []
|
(defn contact-list []
|
||||||
(let [contacts (subscribe [:get-contacts])]
|
(let [contacts (subscribe [:get :contacts])]
|
||||||
(fn []
|
(fn []
|
||||||
(let [contacts-ds (get-data-source @contacts)]
|
(let [contacts-ds (lw/to-datasource2 @contacts)]
|
||||||
[view st/contacts-list-container
|
[view st/contacts-list-container
|
||||||
[contact-list-toolbar]
|
[contact-list-toolbar]
|
||||||
(when contacts-ds
|
(when contacts-ds
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
(ns syng-im.contacts.subs
|
(ns syng-im.contacts.subs
|
||||||
(:require-macros [reagent.ratom :refer [reaction]])
|
(:require-macros [reagent.ratom :refer [reaction]])
|
||||||
(:require [re-frame.core :refer [register-sub]]))
|
(:require [re-frame.core :refer [register-sub]]))
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,13 +7,12 @@
|
|||||||
(def default-view :discovery)
|
(def default-view :discovery)
|
||||||
|
|
||||||
;; initial state of app-db
|
;; initial state of app-db
|
||||||
(def app-db {:greeting "Hello Clojure in iOS and Android!"
|
(def app-db {:identity-password "replace-me-with-user-entered-password"
|
||||||
:identity-password "replace-me-with-user-entered-password"
|
|
||||||
:identity "me"
|
:identity "me"
|
||||||
:contacts []
|
:contacts []
|
||||||
:current-chat-id "console"
|
:current-chat-id "console"
|
||||||
:chat {:command nil
|
:chat {:command nil
|
||||||
:last-message nil}
|
:last-message nil}
|
||||||
:chats {}
|
:chats {}
|
||||||
:chats-updated-signal 0
|
:chats-updated-signal 0
|
||||||
:show-actions false
|
:show-actions false
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
message-by-id]]
|
message-by-id]]
|
||||||
[syng-im.models.commands :refer [set-commands]]
|
[syng-im.models.commands :refer [set-commands]]
|
||||||
[syng-im.handlers.server :as server]
|
[syng-im.handlers.server :as server]
|
||||||
[syng-im.handlers.contacts :as contacts-service]
|
|
||||||
[syng-im.handlers.suggestions :refer [get-command
|
[syng-im.handlers.suggestions :refer [get-command
|
||||||
handle-command
|
handle-command
|
||||||
get-command-handler
|
get-command-handler
|
||||||
@ -229,19 +228,6 @@
|
|||||||
(user-data/load-phone-number)
|
(user-data/load-phone-number)
|
||||||
db))
|
db))
|
||||||
|
|
||||||
;; -- Sign up --------------------------------------------------------------
|
|
||||||
|
|
||||||
(register-handler :sync-contacts
|
|
||||||
(fn [db [_ handler]]
|
|
||||||
(contacts-service/sync-contacts handler)
|
|
||||||
db))
|
|
||||||
|
|
||||||
;; -- Contacts --------------------------------------------------------------
|
|
||||||
|
|
||||||
(register-handler :load-syng-contacts
|
|
||||||
(fn [db [_ value]]
|
|
||||||
(contacts/load-syng-contacts db)))
|
|
||||||
|
|
||||||
;; -- Chats --------------------------------------------------------------
|
;; -- Chats --------------------------------------------------------------
|
||||||
(defn update-new-participants-selection [db identity add?]
|
(defn update-new-participants-selection [db identity add?]
|
||||||
(update db :new-participants (fn [new-participants]
|
(update db :new-participants (fn [new-participants]
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
(ns syng-im.handlers.contacts
|
|
||||||
(:require-macros [cljs.core.async.macros :refer [go]])
|
|
||||||
(:require [clojure.string :as cstr]
|
|
||||||
[cljs.core.async :as async :refer [chan put! <!]]
|
|
||||||
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
|
||||||
[syng-im.utils.utils :refer [log on-error http-post toast]]
|
|
||||||
[syng-im.utils.crypt :refer [encrypt]]
|
|
||||||
[syng-im.utils.phone-number :refer [format-phone-number]]
|
|
||||||
[syng-im.models.contacts :as contacts-model]
|
|
||||||
[syng-im.utils.logging :as log]))
|
|
||||||
|
|
||||||
(defn- get-contact-name [phone-contact]
|
|
||||||
(cstr/join " "
|
|
||||||
(remove cstr/blank?
|
|
||||||
[(:givenName phone-contact)
|
|
||||||
(:middleName phone-contact)
|
|
||||||
(:familyName phone-contact)])))
|
|
||||||
|
|
||||||
(defn- to-syng-contacts [contacts-by-hash data]
|
|
||||||
(map (fn [server-contact]
|
|
||||||
(let [number-info (get contacts-by-hash
|
|
||||||
(:phone-number-hash server-contact))
|
|
||||||
phone-contact (:contact number-info)]
|
|
||||||
{:phone-number (:number number-info)
|
|
||||||
:whisper-identity (:whisper-identity server-contact)
|
|
||||||
:name (get-contact-name phone-contact)
|
|
||||||
:photo-path (:photo-path phone-contact)}))
|
|
||||||
(js->clj (:contacts data))))
|
|
||||||
|
|
||||||
(defn- get-contacts-by-hash [contacts]
|
|
||||||
(let [numbers-info (reduce (fn [numbers contact]
|
|
||||||
(into numbers
|
|
||||||
(map (fn [c]
|
|
||||||
{:number (format-phone-number (:number c))
|
|
||||||
:contact contact})
|
|
||||||
(:phone-numbers contact))))
|
|
||||||
'()
|
|
||||||
contacts)]
|
|
||||||
(reduce (fn [m number-info]
|
|
||||||
(let [number (:number number-info)
|
|
||||||
hash (encrypt number)]
|
|
||||||
(assoc m hash number-info)))
|
|
||||||
{}
|
|
||||||
numbers-info)))
|
|
||||||
|
|
||||||
(defn- request-syng-contacts [contacts]
|
|
||||||
(let [contacts-by-hash (get-contacts-by-hash contacts)
|
|
||||||
data (keys contacts-by-hash)
|
|
||||||
ch (chan)]
|
|
||||||
(http-post "get-contacts" {:phone-number-hashes data}
|
|
||||||
(fn [data]
|
|
||||||
(put! ch
|
|
||||||
(to-syng-contacts contacts-by-hash data))))
|
|
||||||
ch))
|
|
||||||
|
|
||||||
(defn sync-contacts [handler]
|
|
||||||
(go
|
|
||||||
(let [result (<! (contacts-model/load-phone-contacts))]
|
|
||||||
(if-let [error (:error result)]
|
|
||||||
(on-error error)
|
|
||||||
(let [syng-contacts (<! (request-syng-contacts (:contacts result)))]
|
|
||||||
(contacts-model/save-syng-contacts syng-contacts)
|
|
||||||
(dispatch [:load-syng-contacts])
|
|
||||||
(handler))))))
|
|
@ -5,12 +5,9 @@
|
|||||||
[syng-im.persistence.realm :as realm]
|
[syng-im.persistence.realm :as realm]
|
||||||
[syng-im.persistence.realm :as r]
|
[syng-im.persistence.realm :as r]
|
||||||
[syng-im.persistence.realm-queries :refer [include-query
|
[syng-im.persistence.realm-queries :refer [include-query
|
||||||
exclude-query]]
|
exclude-query]]))
|
||||||
[clojure.string :as s]))
|
|
||||||
|
|
||||||
;; TODO see https://github.com/rt2zz/react-native-contacts/issues/45
|
;; TODO see https://github.com/rt2zz/react-native-contacts/issues/45
|
||||||
(def fake-phone-contacts? false)
|
|
||||||
(def fake-contacts? false)
|
|
||||||
|
|
||||||
(def react-native-contacts (js/require "react-native-contacts"))
|
(def react-native-contacts (js/require "react-native-contacts"))
|
||||||
|
|
||||||
@ -26,43 +23,26 @@
|
|||||||
(defn- generate-contacts [n]
|
(defn- generate-contacts [n]
|
||||||
(map generate-contact (range 1 (inc n))))
|
(map generate-contact (range 1 (inc n))))
|
||||||
|
|
||||||
(defn load-phone-contacts []
|
(defn load-phone-contacts
|
||||||
(let [ch (chan)]
|
([callback] (.getAll react-native-contacts callback))
|
||||||
(if fake-phone-contacts?
|
([]
|
||||||
(put! ch {:error nil, :contacts (generate-contacts 10)})
|
(.getAll react-native-contacts
|
||||||
(.getAll react-native-contacts
|
(fn [error raw-contacts]
|
||||||
(fn [error raw-contacts]
|
(println raw-contacts)
|
||||||
(put! ch
|
{:error error
|
||||||
{:error error
|
:contacts
|
||||||
:contacts
|
(when (not error)
|
||||||
(when (not error)
|
(log raw-contacts)
|
||||||
(log raw-contacts)
|
(map (fn [contact]
|
||||||
(map (fn [contact]
|
(merge contact
|
||||||
(merge contact
|
(generate-contact 1)
|
||||||
(generate-contact 1)
|
{:name (:givenName contact)
|
||||||
{:name (:givenName contact)
|
:photo-path (:thumbnailPath contact)
|
||||||
:photo-path (:thumbnailPath contact)
|
:phone-numbers (:phoneNumbers contact)}))
|
||||||
:phone-numbers (:phoneNumbers contact)}))
|
(js->clj raw-contacts :keywordize-keys true)))}))))
|
||||||
(js->clj raw-contacts :keywordize-keys true)))}))))
|
|
||||||
ch))
|
|
||||||
|
|
||||||
(defn- get-contacts []
|
(defn get-contacts []
|
||||||
(if fake-contacts?
|
(realm/collection->map (realm/get-all :contacts)))
|
||||||
[{:phone-number "123"
|
|
||||||
:whisper-identity "abc"
|
|
||||||
:name "fake"
|
|
||||||
:photo-path ""}]
|
|
||||||
(realm/get-list :contacts)))
|
|
||||||
|
|
||||||
(defn load-syng-contacts [db]
|
|
||||||
(let [contacts (map (fn [contact]
|
|
||||||
(merge contact
|
|
||||||
{:delivery-status (if (< (rand) 0.5) :delivered :seen)
|
|
||||||
:datetime "15:30"
|
|
||||||
:new-messages-count (rand-int 3)
|
|
||||||
:online (< (rand) 0.5)}))
|
|
||||||
(get-contacts))]
|
|
||||||
(assoc db :contacts contacts)))
|
|
||||||
|
|
||||||
(defn- create-contact [{:keys [phone-number whisper-identity name photo-path]}]
|
(defn- create-contact [{:keys [phone-number whisper-identity name photo-path]}]
|
||||||
(realm/create :contacts
|
(realm/create :contacts
|
||||||
|
@ -16,10 +16,6 @@
|
|||||||
[s]
|
[s]
|
||||||
(keywordize-keys (apply hash-map (split s #"[;=]"))))
|
(keywordize-keys (apply hash-map (split s #"[;=]"))))
|
||||||
|
|
||||||
(defn select-chat-last-message [chat]
|
|
||||||
(when-let [last-msg-id (:last-msg-id chat)]
|
|
||||||
(r/single-cljs (r/get-by-field :msgs :msg-id last-msg-id))))
|
|
||||||
|
|
||||||
(defn save-message
|
(defn save-message
|
||||||
[chat-id {:keys [from to msg-id content content-type outgoing
|
[chat-id {:keys [from to msg-id content content-type outgoing
|
||||||
same-author same-direction]
|
same-author same-direction]
|
||||||
|
@ -6,8 +6,7 @@
|
|||||||
[syng-im.utils.types :refer [to-edn-string]]
|
[syng-im.utils.types :refer [to-edn-string]]
|
||||||
[re-frame.db :refer [app-db]]
|
[re-frame.db :refer [app-db]]
|
||||||
[syng-im.db :as db]
|
[syng-im.db :as db]
|
||||||
[syng-im.persistence.simple-kv-store :as kv]
|
[syng-im.persistence.simple-kv-store :as kv]))
|
||||||
[syng-im.utils.logging :as log]))
|
|
||||||
|
|
||||||
(defn set-initialized [db initialized?]
|
(defn set-initialized [db initialized?]
|
||||||
(assoc-in db db/protocol-initialized-path initialized?))
|
(assoc-in db db/protocol-initialized-path initialized?))
|
||||||
@ -23,8 +22,3 @@
|
|||||||
password (:identity-password db)]
|
password (:identity-password db)]
|
||||||
(when encrypted
|
(when encrypted
|
||||||
(read-string (password-decrypt password encrypted)))))
|
(read-string (password-decrypt password encrypted)))))
|
||||||
|
|
||||||
(comment
|
|
||||||
|
|
||||||
(stored-identity @re-frame.db/app-db)
|
|
||||||
)
|
|
||||||
|
@ -5,5 +5,6 @@
|
|||||||
(def country-code (subs locale 3 5))
|
(def country-code (subs locale 3 5))
|
||||||
(set! js/PhoneNumber (js/require "awesome-phonenumber"))
|
(set! js/PhoneNumber (js/require "awesome-phonenumber"))
|
||||||
|
|
||||||
|
;; todo check wrong numbers, .getNumber returns empty string
|
||||||
(defn format-phone-number [number]
|
(defn format-phone-number [number]
|
||||||
(str (.getNumber (js/PhoneNumber. number country-code "international"))))
|
(str (.getNumber (js/PhoneNumber. number country-code "international"))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user