add/remove participants
This commit is contained in:
parent
ae1918a2ae
commit
cd45d3420e
|
@ -67,8 +67,8 @@
|
|||
|
||||
(defn on-action-selected [position]
|
||||
(case position
|
||||
0 (dispatch [:show-add-participants])
|
||||
1 (dispatch [:show-remove-participants])
|
||||
0 (dispatch [:navigate-to :add-participants])
|
||||
1 (dispatch [:navigate-to :remove-participants])
|
||||
2 (dispatch [:leave-group-chat])))
|
||||
|
||||
(defn overlay [{:keys [on-click-outside]} items]
|
||||
|
@ -119,13 +119,13 @@
|
|||
:icon :menu_group
|
||||
:icon-style {:width 25
|
||||
:height 19}
|
||||
:handler #(dispatch [:show-add-participants])}
|
||||
:handler #(dispatch [:navigate-to :add-participants])}
|
||||
{:title "Remove Contact from chat"
|
||||
:subtitle "Alex, John"
|
||||
:icon :search_gray_copy
|
||||
:icon-style {:width 17
|
||||
:height 17}
|
||||
:handler #(dispatch [:show-remove-participants])}
|
||||
:handler #(dispatch [:navigate-to :remove-participants])}
|
||||
{:title "Leave Chat"
|
||||
:icon :muted
|
||||
:icon-style {:width 18
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
(ns syng-im.group-settings.handlers
|
||||
(:require [re-frame.core :refer [register-handler debug dispatch after]]
|
||||
[syng-im.persistence.realm :as r]
|
||||
[syng-im.models.messages :refer [clear-history]]
|
||||
[clojure.string :as s]))
|
||||
[syng-im.models.messages :refer [clear-history]]))
|
||||
|
||||
(defn save-chat-property!
|
||||
[db-name property-name]
|
||||
|
|
|
@ -168,7 +168,7 @@
|
|||
[scroll-view st/body
|
||||
[chat-name]
|
||||
[text {:style st/members-text} "Members"]
|
||||
[touchable-highlight {:on-press #(dispatch [:show-add-participants])}
|
||||
[touchable-highlight {:on-press #(dispatch [:navigate-to :add-participants])}
|
||||
[view st/add-members-container
|
||||
[icon :add-gray st/add-members-icon]
|
||||
[text {:style st/add-members-text}
|
||||
|
|
|
@ -38,9 +38,10 @@
|
|||
syng-im.chat.handlers
|
||||
[syng-im.group-settings.handlers :refer [delete-chat]]
|
||||
syng-im.navigation.handlers
|
||||
syng-im.discovery.handlers
|
||||
syng-im.contacts.handlers
|
||||
syng-im.new-group.handlers))
|
||||
syng-im.discovery.handlers
|
||||
syng-im.new-group.handlers
|
||||
syng-im.participants.handlers))
|
||||
|
||||
;; -- Middleware ------------------------------------------------------------
|
||||
;;
|
||||
|
|
|
@ -51,21 +51,6 @@
|
|||
(fn [db _]
|
||||
(push-view db :contact-list)))
|
||||
|
||||
(defn clear-new-participants [db]
|
||||
(assoc db :new-participants #{}))
|
||||
|
||||
(register-handler :show-remove-participants
|
||||
(fn [db _]
|
||||
(-> db
|
||||
(push-view :remove-participants)
|
||||
clear-new-participants)))
|
||||
|
||||
(register-handler :show-add-participants
|
||||
(fn [db _]
|
||||
(-> db
|
||||
(push-view :add-participants)
|
||||
clear-new-participants)))
|
||||
|
||||
(defn show-profile
|
||||
[db [_ identity]]
|
||||
(-> db
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
(defn on-toggle [whisper-identity]
|
||||
(fn [checked?]
|
||||
(println checked?)
|
||||
(let [action (if checked? :select-contact :deselect-contact)]
|
||||
(dispatch [action whisper-identity]))))
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
(ns syng-im.participants.handlers
|
||||
(:require [syng-im.navigation.handlers :as nav]
|
||||
[re-frame.core :refer [register-handler debug]]))
|
||||
|
||||
(defmethod nav/preload-data! :add-participants
|
||||
[db _]
|
||||
(assoc db :new-participants #{}))
|
||||
|
||||
(defmethod nav/preload-data! :remove-participants
|
||||
[db _]
|
||||
(assoc db :new-participants #{}))
|
||||
|
||||
(defn deselect-participant
|
||||
[db [_ id]]
|
||||
(update db :new-participants disj id))
|
||||
|
||||
(register-handler :deselect-participant deselect-participant)
|
||||
|
||||
(defn select-participant
|
||||
[db [_ id]]
|
||||
(update db :new-participants conj id))
|
||||
|
||||
(register-handler :select-participant (debug select-participant))
|
|
@ -1,3 +1,7 @@
|
|||
(ns syng-im.participants.subs)
|
||||
(ns syng-im.participants.subs
|
||||
(:require-macros [reagent.ratom :refer [reaction]])
|
||||
(:require [re-frame.core :refer [register-sub]]
|
||||
[syng-im.utils.subs :as u]))
|
||||
|
||||
()
|
||||
(register-sub :is-participant-selected?
|
||||
(u/contains-sub :new-participants))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
(ns syng-im.participants.views.contact
|
||||
(:require-macros [syng-im.utils.views :refer [defview]])
|
||||
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||
[syng-im.components.react :refer [view]]
|
||||
[syng-im.contacts.views.contact-inner :refer [contact-inner-view]]
|
||||
|
@ -6,14 +7,17 @@
|
|||
[reagent.core :as r]
|
||||
[syng-im.participants.styles :as st]))
|
||||
|
||||
(defn participant-contact [{:keys [whisper-identity] :as contact}]
|
||||
;; todo must be moved to handlers
|
||||
(let [checked (r/atom false)]
|
||||
(fn [{:keys [whisper-identity] :as contact}]
|
||||
[view st/participant-container
|
||||
[item-checkbox {:onToggle (fn [checked?]
|
||||
(reset! checked checked?)
|
||||
(dispatch [:select-new-participant whisper-identity checked?]))
|
||||
:checked @checked
|
||||
:size 30}]
|
||||
[contact-inner-view contact]])))
|
||||
;; todo duplication
|
||||
(defn on-toggle [whisper-identity]
|
||||
(fn [checked?]
|
||||
(let [action (if checked? :select-participant :deselect-participant)]
|
||||
(dispatch [action whisper-identity]))))
|
||||
|
||||
(defview participant-contact
|
||||
[{:keys [whisper-identity] :as contact}]
|
||||
[checked [:is-participant-selected? whisper-identity]]
|
||||
[view st/participant-container
|
||||
[item-checkbox {:onToggle (on-toggle whisper-identity)
|
||||
:checked checked
|
||||
:size 30}]
|
||||
[contact-inner-view contact]])
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
syng-im.group-settings.subs
|
||||
syng-im.discovery.subs
|
||||
syng-im.contacts.subs
|
||||
syng-im.new-group.subs))
|
||||
syng-im.new-group.subs
|
||||
syng-im.participants.subs))
|
||||
|
||||
(register-sub :get
|
||||
(fn [db [_ k]]
|
||||
|
|
Loading…
Reference in New Issue