Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarBasem committed Dec 20, 2022
1 parent 4ccd15b commit 68cd4c4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions src/status_im/group_chats/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@

(fx/defn remove-members
{:events [:group-chats.ui/remove-members-pressed]}
[{{:keys [current-chat-id deselected-members]} :db :as cofx}]
[{{:keys [current-chat-id]} :db :as cofx}]
{::json-rpc/call [{:method "wakuext_removeMembersFromGroupChat"
:params [nil current-chat-id deselected-members]
:params [nil current-chat-id (get-in cofx [:db :group-chat/deselected-members])]
:js-response true
:on-success #(re-frame/dispatch [:chat-updated % true])
:on-error #()}]})
Expand Down Expand Up @@ -88,9 +88,9 @@
(fx/defn add-members
"Add members to a group chat"
{:events [:group-chats.ui/add-members-pressed]}
[{{:keys [current-chat-id selected-participants]} :db :as cofx}]
[{{:keys [current-chat-id]} :db :as cofx}]
{::json-rpc/call [{:method "wakuext_addMembersToGroupChat"
:params [nil current-chat-id selected-participants]
:params [nil current-chat-id (get-in cofx [:db :group-chat/selected-participants])]
:js-response true
:on-success #(re-frame/dispatch [:chat-updated % true])}]})

Expand Down Expand Up @@ -187,12 +187,12 @@
(fx/defn deselect-member
{:events [:deselect-member]}
[{:keys [db]} id]
{:db (update db :deselected-members conj id)})
{:db (update db :group-chat/deselected-members conj id)})

(fx/defn undo-deselect-member
{:events [:undo-deselect-member]}
[{:keys [db]} id]
{:db (update db :deselected-members disj id)})
{:db (update db :group-chat/deselected-members disj id)})

(fx/defn deselect-contact
{:events [:deselect-contact]}
Expand All @@ -207,22 +207,22 @@
(fx/defn deselect-participant
{:events [:deselect-participant]}
[{:keys [db]} id]
{:db (update db :selected-participants disj id)})
{:db (update db :group-chat/selected-participants disj id)})

(fx/defn select-participant
{:events [:select-participant]}
[{:keys [db]} id]
{:db (update db :selected-participants conj id)})
{:db (update db :group-chat/selected-participants conj id)})

(fx/defn clear-added-participants
{:events [:group/clear-added-participants]}
[{db :db}]
{:db (assoc db :selected-participants #{})})
{:db (assoc db :group-chat/selected-participants #{})})

(fx/defn clear-removed-members
{:events [:group/clear-removed-members]}
[{db :db}]
{:db (assoc db :deselected-members #{})})
{:db (assoc db :group-chat/deselected-members #{})})

(fx/defn show-group-chat-profile
{:events [:show-group-chat-profile]}
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/group/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
(views/defview add-participants-toggle-list []
(views/letsubs [contacts [:contacts/all-contacts-not-in-current-chat]
current-chat [:chats/current-chat]
selected-contacts-count [:selected-participants-count]]
selected-contacts-count [:group-chat/selected-participants-count]]
(let [current-participants-count (count (:contacts current-chat))]
[kb-presentation/keyboard-avoiding-view {:style styles/group-container}
[topbar/topbar {:use-insets false
Expand Down
4 changes: 2 additions & 2 deletions src/status_im/ui2/screens/chat/group_details/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
(fn []
(let [{window-height :height} (rn/use-window-dimensions)
safe-area (safe-area/use-safe-area)
selected-participants (rf/sub [:selected-participants])
deselected-members (rf/sub [:deselected-members])]
selected-participants (rf/sub [:group-chat/selected-participants])
deselected-members (rf/sub [:group-chat/deselected-members])]
[rn/view {:style {:height (- window-height (:top safe-area))}}
[rn/touchable-opacity
{:on-press #(rf/dispatch [:bottom-sheet/hide])
Expand Down
4 changes: 2 additions & 2 deletions src/status_im2/setup/db.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
:group/selected-contacts #{}
:chats {}
:current-chat-id nil
:selected-participants #{}
:deselected-members #{}
:group-chat/selected-participants #{}
:group-chat/deselected-members #{}
:sync-state :done
:link-previews-whitelist []
:app-state "active"
Expand Down
4 changes: 2 additions & 2 deletions src/status_im2/subs/chat/chats.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@
(count (filter-selected-contacts selected-contacts contacts))))

(re-frame/reg-sub
:selected-participants-count
:<- [:selected-participants]
:group-chat/selected-participants-count
:<- [:group-chat/selected-participants]
(fn [selected-participants]
(count selected-participants)))

Expand Down
2 changes: 1 addition & 1 deletion src/status_im2/subs/general.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@

(re-frame/reg-sub
:is-participant-selected?
:<- [:selected-participants]
:<- [:group-chat/selected-participants]
(fn [selected-participants [_ element]]
(-> selected-participants
(contains? element))))
Expand Down
4 changes: 2 additions & 2 deletions src/status_im2/subs/root.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
(reg-root-key-sub :new-chat-name :new-chat-name)
(reg-root-key-sub :group-chat-profile/editing? :group-chat-profile/editing?)
(reg-root-key-sub :group-chat-profile/profile :group-chat-profile/profile)
(reg-root-key-sub :selected-participants :selected-participants)
(reg-root-key-sub :deselected-members :deselected-members)
(reg-root-key-sub :group-chat/selected-participants :group-chat/selected-participants)
(reg-root-key-sub :group-chat/deselected-members :group-chat/deselected-members)
(reg-root-key-sub :chat/inputs :chat/inputs)
(reg-root-key-sub :chat/memberships :chat/memberships)
(reg-root-key-sub :camera-roll/photos :camera-roll/photos)
Expand Down

0 comments on commit 68cd4c4

Please sign in to comment.