Skip to content

Commit

Permalink
bidi
Browse files Browse the repository at this point in the history
  • Loading branch information
flexsurfer committed Aug 14, 2020
1 parent f9bc183 commit 649a835
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 25 deletions.
10 changes: 6 additions & 4 deletions src/status_im/chat/models.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,12 @@

(defn map-chats [{:keys [db] :as cofx}]
(fn [val]
(merge
(or (get (:chats db) (:chat-id val))
(create-new-chat (:chat-id val) cofx))
val)))
(assoc
(merge
(or (get (:chats db) (:chat-id val))
(create-new-chat (:chat-id val) cofx))
val)
:invitation-admin (:invitation-admin val))))

(defn filter-chats [db]
(fn [val]
Expand Down
9 changes: 9 additions & 0 deletions src/status_im/group_chats/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@
:params [nil current-chat-id selected-participants]
:on-success #(re-frame/dispatch [::chat-updated %])}]})

(fx/defn add-members-from-invitation
"Add members to a group chat"
{:events [:group-chats.ui/add-members-from-invitation]}
[{{:keys [current-chat-id] :as db} :db :as cofx} id participant]
{:db (update db :group-chat/invitations dissoc id)
::json-rpc/call [{:method (json-rpc/call-ext-method (waku/enabled? cofx) "addMembersToGroupChat")
:params [nil current-chat-id [participant]]
:on-success #(re-frame/dispatch [::chat-updated %])}]})

(fx/defn leave
"Leave chat"
{:events [:group-chats.ui/leave-chat-confirmed]}
Expand Down
24 changes: 13 additions & 11 deletions src/status_im/ui/screens/chat/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@
[sheets/actions current-chat])
:height 256}])}]}])

(defn invitation-requests [chat-id invitation-admin]
(when-not invitation-admin
(let [invitations @(re-frame/subscribe [:group-chat/pending-invitations-by-chat-id chat-id])]
(when (seq invitations)
[react/touchable-highlight
{:on-press #(re-frame/dispatch [:navigate-to :group-chat-invite])
:accessibility-label :invitation-requests-button}
[react/view {:style (style/add-contact)}
[react/text {:style style/add-contact-text} "Group membership request"]]]))))
(defn invitation-requests [chat-id admins]
(let [current-pk @(re-frame/subscribe [:multiaccount/public-key])
admin? (get admins current-pk)]
(when admin?
(let [invitations @(re-frame/subscribe [:group-chat/pending-invitations-by-chat-id chat-id])]
(when (seq invitations)
[react/touchable-highlight
{:on-press #(re-frame/dispatch [:navigate-to :group-chat-invite])
:accessibility-label :invitation-requests-button}
[react/view {:style (style/add-contact)}
[react/text {:style style/add-contact-text} "Group membership request"]]])))))

(defn add-contact-bar [public-key]
(let [added? @(re-frame/subscribe [:contacts/contact-added? public-key])]
Expand Down Expand Up @@ -236,14 +238,14 @@
(when panel
(js/setTimeout #(react/dismiss-keyboard!) 100)))]
(fn []
(let [{:keys [chat-id show-input? group-chat invitation-admin] :as current-chat}
(let [{:keys [chat-id show-input? group-chat admins] :as current-chat}
@(re-frame/subscribe [:chats/current-chat])]
[react/view {:style {:flex 1}}
[connectivity/connectivity
[topbar current-chat]
[react/view {:style {:flex 1}}
(if group-chat
[invitation-requests chat-id invitation-admin]
[invitation-requests chat-id admins]
[add-contact-bar chat-id])
[messages-view {:chat current-chat
:bottom-space (max @bottom-space @panel-space)
Expand Down
8 changes: 4 additions & 4 deletions src/status_im/ui/screens/profile/group_chat/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,12 @@
(re-frame/dispatch [:bottom-sheet/hide])
(re-frame/dispatch event))

(defn invitation-sheet [{:keys [chat-id introduction-message id]} contact]
(defn invitation-sheet [{:keys [introduction-message id]} contact]
[react/view
(let [message {:content {:parsed-text
[{:type "paragraph"
:children [{:literal introduction-message}]}]}
:content-type constants/content-type-text}]
;:timestamp-str "9:41 AM"}]
[react/view {:margin-bottom 8}
[react/view {:padding-left 72}
(chat.utils/format-author (multiaccounts/displayed-name contact))]
Expand All @@ -119,7 +118,8 @@
:title "Accept";(i18n/label :t/accept)
:accessibility-label :fetch-history-button
:icon :main-icons/checkmark-circle
:on-press #(hide-sheet-and-dispatch [:chat.ui/fetch-history-pressed chat-id])}]
:on-press #(hide-sheet-and-dispatch
[:group-chats.ui/add-members-from-invitation id (:public-key contact)])}]
[quo/list-item
{:theme :negative
:title (i18n/label :t/decline)
Expand All @@ -142,7 +142,7 @@
members [:contacts/current-chat-contacts]
current-pk [:multiaccount/public-key]]
(let [invite-link (universal-links/generate-link
:group
:group-chat
:external
(str current-pk "&" (js/encodeURI chat-name) "&" chat-id))
invitations @(re-frame/subscribe [:group-chat/pending-invitations-by-chat-id chat-id])]
Expand Down
6 changes: 3 additions & 3 deletions src/status_im/utils/universal_links/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
(def domains {:external "https://join.status.im"
:internal "status-im:/"})

(def links {:public-chat "%s/%s"
(def links {:public-chat "%s/%s"
:private-chat "%s/p/%s"
:group-chat "%s/g/%s"
:user "%s/u/%s"
:browse "%s/b/%s"})
:user "%s/u/%s"
:browse "%s/b/%s"})

(defn generate-link [link-type domain-type param]
(gstring/format (get links link-type)
Expand Down
6 changes: 3 additions & 3 deletions status-go-version.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
"owner": "status-im",
"repo": "status-go",
"version": "v0.56.6",
"commit-sha1": "2d0818d873fee570a73867d8ed4bc8e792215cf1",
"src-sha256": "0d9k0c2srhmm5dpzx3dkzn1h0p60x9zwjzim6x08gp9yd87h3zmv"
"version": "feature/group-chat-invitation",
"commit-sha1": "87c2b5b9f7e6b1cf4adf26bb447aff1e691194f8",
"src-sha256": "1gd3wrb1km8qmma1ps958z29rqsrr8bx595hvassmfjwfhpk71n5"
}

0 comments on commit 649a835

Please sign in to comment.