mirror of
https://github.com/status-im/status-mobile.git
synced 2025-03-01 08:40:50 +00:00
start chat with contact
This commit is contained in:
parent
780b12049e
commit
af0ed4c3a9
@ -52,7 +52,7 @@
|
|||||||
(dispatch [:initialize-chats])
|
(dispatch [:initialize-chats])
|
||||||
(dispatch [:initialize-protocol])
|
(dispatch [:initialize-protocol])
|
||||||
(dispatch [:load-user-phone-number])
|
(dispatch [:load-user-phone-number])
|
||||||
(dispatch [:load-syng-contacts])
|
(dispatch [:load-contacts])
|
||||||
;; load commands from remote server (todo: uncomment)
|
;; load commands from remote server (todo: uncomment)
|
||||||
;; (dispatch [:load-commands])
|
;; (dispatch [:load-commands])
|
||||||
(dispatch [:init-console-chat])
|
(dispatch [:init-console-chat])
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
(ns syng-im.chat.handlers
|
(ns syng-im.chat.handlers
|
||||||
(:require [re-frame.core :refer [register-handler enrich after debug]]
|
(:require [re-frame.core :refer [register-handler enrich after debug dispatch]]
|
||||||
[syng-im.models.commands :as commands]
|
[syng-im.models.commands :as commands]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[syng-im.chat.suggestions :as suggestions]
|
[syng-im.chat.suggestions :as suggestions]
|
||||||
@ -10,7 +10,9 @@
|
|||||||
[syng-im.utils.random :as random]
|
[syng-im.utils.random :as random]
|
||||||
[syng-im.components.react :as r]
|
[syng-im.components.react :as r]
|
||||||
[syng-im.handlers.sign-up :as sign-up-service]
|
[syng-im.handlers.sign-up :as sign-up-service]
|
||||||
[syng-im.models.chats :as chats]))
|
[syng-im.models.chats :as chats]
|
||||||
|
[syng-im.navigation.handlers :as nav]
|
||||||
|
[syng-im.models.chats :as c]))
|
||||||
|
|
||||||
(register-handler :set-show-actions
|
(register-handler :set-show-actions
|
||||||
(fn [db [_ show-actions]]
|
(fn [db [_ show-actions]]
|
||||||
@ -236,15 +238,16 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn load-messages!
|
(defn load-messages!
|
||||||
[db _]
|
([db] (load-messages! db nil))
|
||||||
db
|
([db _]
|
||||||
(->> (:current-chat-id db)
|
(->> (:current-chat-id db)
|
||||||
messages/get-messages
|
messages/get-messages
|
||||||
(assoc db :messages)))
|
(assoc db :messages))))
|
||||||
|
|
||||||
(defn init-chat
|
(defn init-chat
|
||||||
[{:keys [messages current-chat-id] :as db} _]
|
([db] (init-chat db nil))
|
||||||
(assoc-in db [:chats current-chat-id :messages] messages))
|
([{:keys [messages current-chat-id] :as db} _]
|
||||||
|
(assoc-in db [:chats current-chat-id :messages] messages)))
|
||||||
|
|
||||||
(register-handler :init-chat
|
(register-handler :init-chat
|
||||||
(-> load-messages!
|
(-> load-messages!
|
||||||
@ -256,9 +259,11 @@
|
|||||||
(let [chats (->> loaded-chats
|
(let [chats (->> loaded-chats
|
||||||
(map (fn [{:keys [chat-id] :as chat}]
|
(map (fn [{:keys [chat-id] :as chat}]
|
||||||
[chat-id chat]))
|
[chat-id chat]))
|
||||||
(into {}))]
|
(into {}))
|
||||||
|
ids (set (keys chats))]
|
||||||
(-> db
|
(-> db
|
||||||
(assoc :chats chats)
|
(assoc :chats chats)
|
||||||
|
(assoc :chats-ids ids)
|
||||||
(dissoc :loaded-chats))))
|
(dissoc :loaded-chats))))
|
||||||
|
|
||||||
(defn load-chats!
|
(defn load-chats!
|
||||||
@ -268,7 +273,6 @@
|
|||||||
(register-handler :initialize-chats
|
(register-handler :initialize-chats
|
||||||
((enrich initialize-chats) load-chats!))
|
((enrich initialize-chats) load-chats!))
|
||||||
|
|
||||||
|
|
||||||
(defn store-message!
|
(defn store-message!
|
||||||
[{:keys [new-message]} [_ {chat-id :from}]]
|
[{:keys [new-message]} [_ {chat-id :from}]]
|
||||||
(messages/save-message chat-id new-message))
|
(messages/save-message chat-id new-message))
|
||||||
@ -288,3 +292,51 @@
|
|||||||
(fn [db [_ {chat-id :group-id :as msg}]]
|
(fn [db [_ {chat-id :group-id :as msg}]]
|
||||||
(messages/save-message chat-id msg)
|
(messages/save-message chat-id msg)
|
||||||
db))
|
db))
|
||||||
|
|
||||||
|
(defn load-chat!
|
||||||
|
[{:keys [chats current-chat-id] :as db}]
|
||||||
|
(when-not (chats current-chat-id)
|
||||||
|
(c/create-chat {}))
|
||||||
|
db)
|
||||||
|
|
||||||
|
(defmethod nav/preload-data! :chat
|
||||||
|
[{:keys [current-chat-id] :as db} [_ _ id]]
|
||||||
|
(-> db
|
||||||
|
(assoc :current-chat-id (or id current-chat-id))
|
||||||
|
load-messages!
|
||||||
|
init-chat))
|
||||||
|
|
||||||
|
(defn prepare-chat
|
||||||
|
[{:keys [contacts] :as db} [_ contcat-id]]
|
||||||
|
(let [name (get-in contacts [contcat-id :name])
|
||||||
|
chat {:chat-id contcat-id
|
||||||
|
:name name
|
||||||
|
:group-chat false
|
||||||
|
:is-active true
|
||||||
|
:timestamp (.getTime (js/Date.))
|
||||||
|
;; todo how to choose color?
|
||||||
|
;; todo do we need to have some color for not group chat?
|
||||||
|
:contacts [{:identity contcat-id
|
||||||
|
:text-color :#FFFFFF
|
||||||
|
:background-color :#AB7967}]}]
|
||||||
|
(assoc db :new-chat chat)))
|
||||||
|
|
||||||
|
(defn add-chat [{:keys [new-chat] :as db} [_ chat-id]]
|
||||||
|
(-> db
|
||||||
|
(update :chats assoc chat-id new-chat)
|
||||||
|
(update :chats-ids conj chat-id)))
|
||||||
|
|
||||||
|
(defn save-chat!
|
||||||
|
[{:keys [new-chat]} _]
|
||||||
|
(chats/create-chat new-chat))
|
||||||
|
|
||||||
|
(defn open-chat!
|
||||||
|
[_ [_ chat-id]]
|
||||||
|
(dispatch [:navigate-to :chat chat-id]))
|
||||||
|
|
||||||
|
(register-handler :start-chat
|
||||||
|
(-> prepare-chat
|
||||||
|
((enrich add-chat))
|
||||||
|
((after save-chat!))
|
||||||
|
((after open-chat!))
|
||||||
|
debug))
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
(ns syng-im.chat.screen
|
(ns syng-im.chat.screen
|
||||||
|
(:require-macros [syng-im.utils.views :refer [defview]])
|
||||||
(:require [clojure.string :as s]
|
(:require [clojure.string :as s]
|
||||||
[re-frame.core :refer [subscribe dispatch]]
|
[re-frame.core :refer [subscribe dispatch]]
|
||||||
[syng-im.components.react :refer [view
|
[syng-im.components.react :refer [view
|
||||||
@ -8,7 +9,7 @@
|
|||||||
touchable-highlight
|
touchable-highlight
|
||||||
list-view
|
list-view
|
||||||
list-item]]
|
list-item]]
|
||||||
[syng-im.chat.styles.chat :as st]
|
[syng-im.chat.styles.screen :as st]
|
||||||
[syng-im.resources :as res]
|
[syng-im.resources :as res]
|
||||||
[syng-im.utils.listview :refer [to-datasource]]
|
[syng-im.utils.listview :refer [to-datasource]]
|
||||||
[syng-im.components.invertible-scroll-view :refer [invertible-scroll-view]]
|
[syng-im.components.invertible-scroll-view :refer [invertible-scroll-view]]
|
||||||
@ -91,7 +92,7 @@
|
|||||||
|
|
||||||
(defn actions-list-view []
|
(defn actions-list-view []
|
||||||
(let [{:keys [group-chat active]}
|
(let [{:keys [group-chat active]}
|
||||||
(subscribe [:chat-properties [:group-chat :name :contacts :active]])]
|
(subscribe [:chat-properties [:group-chat :active]])]
|
||||||
(when-let [actions (when (and @group-chat @active)
|
(when-let [actions (when (and @group-chat @active)
|
||||||
[{:title "Add Contact to chat"
|
[{:title "Add Contact to chat"
|
||||||
:icon :menu_group
|
:icon :menu_group
|
||||||
@ -160,25 +161,23 @@
|
|||||||
[chat-photo {}]
|
[chat-photo {}]
|
||||||
[contact-online {:online true}]]])])))
|
[contact-online {:online true}]]])])))
|
||||||
|
|
||||||
(defn messages-view [group-chat]
|
(defview messages-view [group-chat]
|
||||||
(let [messages (subscribe [:chat :messages])
|
[messages [:chat :messages]
|
||||||
contacts (subscribe [:chat :contacts])]
|
contacts [:chat :contacts]]
|
||||||
(fn [group-chat]
|
(let [contacts' (contacts-by-identity contacts)]
|
||||||
(let [contacts' (contacts-by-identity @contacts)]
|
|
||||||
[list-view {:renderRow (message-row contacts' group-chat)
|
[list-view {:renderRow (message-row contacts' group-chat)
|
||||||
:renderScrollComponent #(invertible-scroll-view (js->clj %))
|
:renderScrollComponent #(invertible-scroll-view (js->clj %))
|
||||||
:onEndReached #(dispatch [:load-more-messages])
|
:onEndReached #(dispatch [:load-more-messages])
|
||||||
:enableEmptySections true
|
:enableEmptySections true
|
||||||
:dataSource (to-datasource @messages)}]))))
|
:dataSource (to-datasource messages)}]))
|
||||||
|
|
||||||
(defn chat []
|
(defview chat []
|
||||||
(let [is-active (subscribe [:chat :is-active])
|
[is-active [:chat :is-active]
|
||||||
group-chat (subscribe [:chat :group-chat])
|
group-chat [:chat :group-chat]
|
||||||
show-actions-atom (subscribe [:show-actions])]
|
show-actions-atom [:show-actions]]
|
||||||
(fn []
|
|
||||||
[view st/chat-view
|
[view st/chat-view
|
||||||
[toolbar]
|
[toolbar]
|
||||||
[messages-view @group-chat]
|
[messages-view group-chat]
|
||||||
(when @group-chat [typing-all])
|
(when group-chat [typing-all])
|
||||||
(when is-active [chat-message-new])
|
(when is-active [chat-message-new])
|
||||||
(when @show-actions-atom [actions-view])])))
|
(when show-actions-atom [actions-view])])
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
(ns syng-im.chat.styles.chat
|
(ns syng-im.chat.styles.screen
|
||||||
(:require [syng-im.components.styles :refer [font
|
(:require [syng-im.components.styles :refer [font
|
||||||
title-font
|
title-font
|
||||||
color-white
|
color-white
|
@ -76,3 +76,7 @@
|
|||||||
(fn [db _]
|
(fn [db _]
|
||||||
(let [current-chat-id (:current-chat-id @db)]
|
(let [current-chat-id (:current-chat-id @db)]
|
||||||
(reaction (get-in @db [:chats current-chat-id])))))
|
(reaction (get-in @db [:chats current-chat-id])))))
|
||||||
|
|
||||||
|
(register-sub :get-chat
|
||||||
|
(fn [db [_ chat-id]]
|
||||||
|
(reaction (get-in @db [:chats chat-id]))))
|
||||||
|
@ -12,15 +12,18 @@
|
|||||||
(contacts/save-contacts [contact]))
|
(contacts/save-contacts [contact]))
|
||||||
|
|
||||||
(register-handler :add-contact
|
(register-handler :add-contact
|
||||||
(-> (fn [db [_ contact]]
|
(-> (fn [db [_ {:keys [whisper-identity] :as contact}]]
|
||||||
(update db :contacts conj contact))
|
(update db :contacts assoc whisper-identity contact))
|
||||||
((after save-contact))))
|
((after save-contact))))
|
||||||
|
|
||||||
(defn load-contacts! [db _]
|
(defn load-contacts! [db _]
|
||||||
(let [contacts (contacts/get-contacts)]
|
(let [contacts (->> (contacts/get-contacts)
|
||||||
|
(map (fn [{:keys [whisper-identity] :as contact}]
|
||||||
|
[whisper-identity contact]))
|
||||||
|
(into {}))]
|
||||||
(assoc db :contacts contacts)))
|
(assoc db :contacts contacts)))
|
||||||
|
|
||||||
(register-handler :load-syng-contacts load-contacts!)
|
(register-handler :load-contacts load-contacts!)
|
||||||
|
|
||||||
;; TODO see https://github.com/rt2zz/react-native-contacts/issues/45
|
;; TODO see https://github.com/rt2zz/react-native-contacts/issues/45
|
||||||
(def react-native-contacts (js/require "react-native-contacts"))
|
(def react-native-contacts (js/require "react-native-contacts"))
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
(ns syng-im.contacts.screen
|
(ns syng-im.contacts.screen
|
||||||
(:require-macros
|
(:require-macros [syng-im.utils.views :refer [defview]])
|
||||||
[natal-shell.data-source :refer [data-source clone-with-rows]]
|
|
||||||
[natal-shell.core :refer [with-error-view]])
|
|
||||||
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||||
[syng-im.components.react :refer [view text
|
[syng-im.components.react :refer [view text
|
||||||
image
|
image
|
||||||
@ -17,9 +15,6 @@
|
|||||||
(defn render-row [row _ _]
|
(defn render-row [row _ _]
|
||||||
(list-item [contact-view row]))
|
(list-item [contact-view row]))
|
||||||
|
|
||||||
(defn get-data-source [contacts]
|
|
||||||
(clone-with-rows (data-source {:rowHasChanged not=}) contacts))
|
|
||||||
|
|
||||||
(defn contact-list-toolbar []
|
(defn contact-list-toolbar []
|
||||||
[toolbar {:title "Contacts"
|
[toolbar {:title "Contacts"
|
||||||
:background-color toolbar-background2
|
:background-color toolbar-background2
|
||||||
@ -27,14 +22,14 @@
|
|||||||
:style st/search-icon}
|
:style st/search-icon}
|
||||||
:handler (fn [])}}])
|
:handler (fn [])}}])
|
||||||
|
|
||||||
(defn contact-list []
|
(defview contact-list []
|
||||||
(let [contacts (subscribe [:get :contacts])]
|
[contacts [:get-contacts]]
|
||||||
(fn []
|
|
||||||
(let [contacts-ds (lw/to-datasource @contacts)]
|
|
||||||
[view st/contacts-list-container
|
[view st/contacts-list-container
|
||||||
[contact-list-toolbar]
|
[contact-list-toolbar]
|
||||||
(when contacts-ds
|
;; todo what if there is no contacts, should we show some information
|
||||||
[list-view {:dataSource contacts-ds
|
;; about this?
|
||||||
|
(when contacts
|
||||||
|
[list-view {:dataSource (lw/to-datasource contacts)
|
||||||
:enableEmptySections true
|
:enableEmptySections true
|
||||||
:renderRow render-row
|
:renderRow render-row
|
||||||
:style st/contacts-list}])]))))
|
:style st/contacts-list}])])
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
(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]]))
|
||||||
|
|
||||||
|
(register-sub :get-contacts
|
||||||
|
(fn [db _]
|
||||||
|
(let [contacts (reaction (:contacts @db))]
|
||||||
|
(reaction (vals @contacts)))))
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
(ns syng-im.contacts.views.contact
|
(ns syng-im.contacts.views.contact
|
||||||
|
(:require-macros [syng-im.utils.views :refer [defview]])
|
||||||
(:require [syng-im.components.react :refer [view touchable-highlight]]
|
(:require [syng-im.components.react :refer [view touchable-highlight]]
|
||||||
[re-frame.core :refer [dispatch]]
|
[re-frame.core :refer [dispatch subscribe]]
|
||||||
[syng-im.contacts.views.contact-inner :refer [contact-inner-view]]))
|
[syng-im.contacts.views.contact-inner :refer [contact-inner-view]]))
|
||||||
|
|
||||||
(defn contact-view [contact]
|
(defn on-press [chat whisper-identity]
|
||||||
[touchable-highlight {:onPress #(dispatch [:navigate-to :chat])}
|
(if chat
|
||||||
|
#(dispatch [:navigate-to :chat whisper-identity])
|
||||||
|
#(dispatch [:start-chat whisper-identity])))
|
||||||
|
|
||||||
|
(defview contact-view [{:keys [whisper-identity] :as contact}]
|
||||||
|
[chat [:get-chat whisper-identity]]
|
||||||
|
[touchable-highlight
|
||||||
|
{:onPress (on-press chat whisper-identity)}
|
||||||
[view {} [contact-inner-view contact]]])
|
[view {} [contact-inner-view contact]]])
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
(def app-db {:identity-password "replace-me-with-user-entered-password"
|
(def app-db {:identity-password "replace-me-with-user-entered-password"
|
||||||
:identity "me"
|
:identity "me"
|
||||||
:contacts []
|
:contacts []
|
||||||
|
:contacts-ids #{}
|
||||||
:current-chat-id "console"
|
:current-chat-id "console"
|
||||||
:chat {:command nil
|
:chat {:command nil
|
||||||
:last-message nil}
|
:last-message nil}
|
||||||
@ -39,4 +40,3 @@
|
|||||||
[:chats chat-id :command-requests])
|
[:chats chat-id :command-requests])
|
||||||
(defn chat-command-request-path [chat-id msg-id]
|
(defn chat-command-request-path [chat-id msg-id]
|
||||||
[:chats chat-id :command-requests msg-id])
|
[:chats chat-id :command-requests msg-id])
|
||||||
(def updated-current-tag-signal-path [:current-tag-updated-signal])
|
|
||||||
|
@ -75,52 +75,56 @@
|
|||||||
(defn find-command [commands command-key]
|
(defn find-command [commands command-key]
|
||||||
(first (filter #(= command-key (:command %)) commands)))
|
(first (filter #(= command-key (:command %)) commands)))
|
||||||
|
|
||||||
(defn get-chat-command-content [db]
|
(defn get-chat-command-content
|
||||||
(get-in db (db/chat-command-content-path (:current-chat-id db))))
|
[{:keys [current-chat-id] :as db}]
|
||||||
|
(get-in db (db/chat-command-content-path current-chat-id)))
|
||||||
|
|
||||||
(defn set-chat-command-content [db content]
|
(defn set-chat-command-content
|
||||||
(assoc-in db
|
[{:keys [current-chat-id] :as db} content]
|
||||||
[:chats (:current-chat-id db) :command-input :content]
|
(assoc-in db [:chats current-chat-id :command-input :content] content))
|
||||||
content))
|
|
||||||
|
|
||||||
(defn get-chat-command [db]
|
(defn get-chat-command
|
||||||
(get-in db (db/chat-command-path (:current-chat-id db))))
|
[{:keys [current-chat-id] :as db}]
|
||||||
|
(get-in db (db/chat-command-path current-chat-id)))
|
||||||
|
|
||||||
(defn set-response-chat-command [db msg-id command-key]
|
(defn set-response-chat-command
|
||||||
(let [chat-id (:current-chat-id db)]
|
[{:keys [current-chat-id] :as db} msg-id command-key]
|
||||||
(-> db
|
(update-in db [:chats current-chat-id :command-input] merge
|
||||||
(assoc-in [:chats chat-id :command-input :content] nil)
|
{:content nil
|
||||||
(assoc-in [:chats chat-id :command-input :command]
|
:command (get-command db command-key)
|
||||||
(get-command db command-key))
|
:to-msg-id msg-id}))
|
||||||
(assoc-in [:chats chat-id :command-input :to-msg-id] msg-id))))
|
|
||||||
|
|
||||||
(defn set-chat-command [db command-key]
|
(defn set-chat-command [db command-key]
|
||||||
(set-response-chat-command db nil command-key))
|
(set-response-chat-command db nil command-key))
|
||||||
|
|
||||||
(defn get-chat-command-to-msg-id [db]
|
(defn get-chat-command-to-msg-id
|
||||||
(get-in db (db/chat-command-to-msg-id-path (:current-chat-id db))))
|
[{:keys [current-chat-id] :as db}]
|
||||||
|
(get-in db (db/chat-command-to-msg-id-path current-chat-id)))
|
||||||
|
|
||||||
(defn stage-command [db command-info]
|
(defn stage-command
|
||||||
(update-in db (db/chat-staged-commands-path (:current-chat-id db))
|
[{:keys [current-chat-id] :as db} command-info]
|
||||||
(fn [staged-commands]
|
(update-in db (db/chat-staged-commands-path current-chat-id)
|
||||||
(if staged-commands
|
#(if %
|
||||||
(conj staged-commands command-info)
|
(conj % command-info)
|
||||||
[command-info]))))
|
[command-info])))
|
||||||
|
|
||||||
(defn unstage-command [db staged-command]
|
(defn unstage-command [db staged-command]
|
||||||
(update-in db (db/chat-staged-commands-path (:current-chat-id db))
|
(update-in db (db/chat-staged-commands-path (:current-chat-id db))
|
||||||
(fn [staged-commands]
|
(fn [staged-commands]
|
||||||
(filterv #(not= % staged-command) staged-commands))))
|
(filterv #(not= % staged-command) staged-commands))))
|
||||||
|
|
||||||
(defn clear-staged-commands [db]
|
(defn clear-staged-commands
|
||||||
(assoc-in db (db/chat-staged-commands-path (:current-chat-id db)) []))
|
[{:keys [current-chat-id] :as db}]
|
||||||
|
(assoc-in db (db/chat-staged-commands-path current-chat-id) []))
|
||||||
|
|
||||||
(defn get-chat-command-request [db]
|
(defn get-chat-command-request
|
||||||
(get-in db (db/chat-command-request-path (:current-chat-id db)
|
[{:keys [current-chat-id] :as db}]
|
||||||
|
(get-in db (db/chat-command-request-path current-chat-id
|
||||||
(get-chat-command-to-msg-id db))))
|
(get-chat-command-to-msg-id db))))
|
||||||
|
|
||||||
(defn set-chat-command-request [db msg-id handler]
|
(defn set-chat-command-request
|
||||||
(update-in db (db/chat-command-requests-path (:current-chat-id db))
|
[{:keys [current-chat-id] :as db} msg-id handler]
|
||||||
|
(update-in db (db/chat-command-requests-path current-chat-id)
|
||||||
#(assoc % msg-id handler)))
|
#(assoc % msg-id handler)))
|
||||||
|
|
||||||
(defn parse-command-msg-content [commands content]
|
(defn parse-command-msg-content [commands content]
|
||||||
|
@ -4,29 +4,27 @@
|
|||||||
[syng-im.components.react :refer [view list-view list-item]]
|
[syng-im.components.react :refer [view list-view list-item]]
|
||||||
[syng-im.components.toolbar :refer [toolbar]]
|
[syng-im.components.toolbar :refer [toolbar]]
|
||||||
[syng-im.utils.listview :refer [to-datasource]]
|
[syng-im.utils.listview :refer [to-datasource]]
|
||||||
[syng-im.participants.views.contact
|
[syng-im.participants.views.contact :refer [participant-contact]]
|
||||||
:refer [participant-contact]]
|
|
||||||
[reagent.core :as r]
|
[reagent.core :as r]
|
||||||
[syng-im.participants.styles :as st]))
|
[syng-im.participants.styles :as st]))
|
||||||
|
|
||||||
(defn new-participants-toolbar [navigator]
|
(defn new-participants-toolbar []
|
||||||
[toolbar
|
[toolbar
|
||||||
{:navigator navigator
|
{:title "Add Participants"
|
||||||
:title "Add Participants"
|
|
||||||
:action {:image {:source res/v ;; {:uri "icon_search"}
|
:action {:image {:source res/v ;; {:uri "icon_search"}
|
||||||
:style st/new-participant-image}
|
:style st/new-participant-image}
|
||||||
:handler #(dispatch [:add-new-participants navigator])}}])
|
:handler #(dispatch [:add-new-participants])}}])
|
||||||
|
|
||||||
(defn new-participants-row
|
(defn new-participants-row
|
||||||
[row _ _]
|
[row _ _]
|
||||||
(list-item [participant-contact row]))
|
(list-item [participant-contact row]))
|
||||||
|
|
||||||
(defn new-participants [{:keys [navigator]}]
|
(defn new-participants []
|
||||||
(let [contacts (subscribe [:all-new-contacts])]
|
(let [contacts (subscribe [:all-new-contacts])]
|
||||||
(fn []
|
(fn []
|
||||||
(let [contacts-ds (to-datasource @contacts)]
|
(let [contacts-ds (to-datasource @contacts)]
|
||||||
[view st/participants-container
|
[view st/participants-container
|
||||||
[new-participants-toolbar navigator]
|
[new-participants-toolbar]
|
||||||
[list-view {:dataSource contacts-ds
|
[list-view {:dataSource contacts-ds
|
||||||
:renderRow new-participants-row
|
:renderRow new-participants-row
|
||||||
:style st/participants-list}]]))))
|
:style st/participants-list}]]))))
|
||||||
|
@ -23,11 +23,6 @@
|
|||||||
(fn [db _]
|
(fn [db _]
|
||||||
(reaction (:signed-up @db))))
|
(reaction (:signed-up @db))))
|
||||||
|
|
||||||
(register-sub
|
|
||||||
:get-contacts
|
|
||||||
(fn [db _]
|
|
||||||
(reaction (:contacts @db))))
|
|
||||||
|
|
||||||
(register-sub :all-contacts
|
(register-sub :all-contacts
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(let [contacts (reaction (:contacts @db))]
|
(let [contacts (reaction (:contacts @db))]
|
||||||
@ -44,7 +39,7 @@
|
|||||||
(map :identity)
|
(map :identity)
|
||||||
set)]
|
set)]
|
||||||
(fn #(current-participants (:whisper-identity %))
|
(fn #(current-participants (:whisper-identity %))
|
||||||
@contacts))))))
|
(vals @contacts)))))))
|
||||||
|
|
||||||
(register-sub :all-new-contacts
|
(register-sub :all-new-contacts
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user