Skip to content

Commit

Permalink
Add leave group chat option
Browse files Browse the repository at this point in the history
  • Loading branch information
cammellos committed Mar 25, 2020
1 parent 6cccd8e commit 56c24d1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/status_im/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,14 @@
:confirm-button-text (i18n/label :t/delete)
:on-accept #(re-frame/dispatch [:group-chats.ui/remove-chat-confirmed chat-id])}}))

(handlers/register-handler-fx
:group-chats.ui/leave-chat-pressed
(fn [_ [_ chat-id group?]]
{:ui/show-confirmation {:title (i18n/label :t/leave-confirmation)
:content (i18n/label :t/leave-chat-confirmation)
:confirm-button-text (i18n/label :t/leave)
:on-accept #(re-frame/dispatch [:group-chats.ui/leave-chat-confirmed chat-id])}}))

(handlers/register-handler-fx
:group-chats.ui/remove-chat-confirmed
(fn [cofx [_ chat-id]]
Expand Down
10 changes: 9 additions & 1 deletion src/status_im/group_chats/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@
"Remove & leave chat"
[{:keys [db] :as cofx} chat-id]
{::json-rpc/call [{:method (json-rpc/call-ext-method (waku/enabled? cofx) "leaveGroupChat")
:params [nil chat-id]
:params [nil chat-id true]
:on-success #(re-frame/dispatch [::chat-updated %])}]})

(fx/defn leave
"Leave chat"
{:events [:group-chats.ui/leave-chat-confirmed]}
[{:keys [db] :as cofx} chat-id]
{::json-rpc/call [{:method (json-rpc/call-ext-method (waku/enabled? cofx) "leaveGroupChat")
:params [nil chat-id false]
:on-success #(re-frame/dispatch [::chat-updated %])}]})

(defn- valid-name? [name]
Expand Down
6 changes: 6 additions & 0 deletions src/status_im/ui/screens/chat/sheets.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@
:accessibility-label :fetch-history-button
:icon :main-icons/arrow-down
:on-press #(hide-sheet-and-dispatch [:chat.ui/fetch-history-pressed chat-id])}]
[list-item/list-item
{:theme :action
:title :t/leave-chat
:accessibility-label :leave-chat-button
:icon :main-icons/arrow-left
:on-press #(hide-sheet-and-dispatch [:group-chats.ui/leave-chat-pressed chat-id])}]
[list-item/list-item
{:theme :action-destructive
:title :t/delete-chat
Expand Down

0 comments on commit 56c24d1

Please sign in to comment.