Fix group chat invitation actions based on state
Fix decline button color and Check if user was removed from group invite Signed-off-by: Gheorghe Pinzaru <feross95@gmail.com>
This commit is contained in:
parent
8c42e717c1
commit
36f9436e12
|
@ -35,6 +35,8 @@
|
||||||
(def invitation-state-requested 1)
|
(def invitation-state-requested 1)
|
||||||
(def invitation-state-rejected 2)
|
(def invitation-state-rejected 2)
|
||||||
(def invitation-state-approved 3)
|
(def invitation-state-approved 3)
|
||||||
|
(def invitation-state-granted 4)
|
||||||
|
(def invitation-state-removed 5)
|
||||||
|
|
||||||
(def message-type-one-to-one 1)
|
(def message-type-one-to-one 1)
|
||||||
(def message-type-public-group 2)
|
(def message-type-public-group 2)
|
||||||
|
|
|
@ -168,3 +168,11 @@
|
||||||
(assoc acc id inv))
|
(assoc acc id inv))
|
||||||
%
|
%
|
||||||
invitations))})
|
invitations))})
|
||||||
|
|
||||||
|
(defn member-removed? [{:keys [membership-update-events]} pk]
|
||||||
|
(->> membership-update-events
|
||||||
|
(filter #(contains? (set (:members %)) pk))
|
||||||
|
(sort-by :clockValue >)
|
||||||
|
first
|
||||||
|
:type
|
||||||
|
(= constants/invitation-state-removed)))
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
[status-im.ethereum.transactions.core :as transactions]
|
[status-im.ethereum.transactions.core :as transactions]
|
||||||
[status-im.fleet.core :as fleet]
|
[status-im.fleet.core :as fleet]
|
||||||
[status-im.group-chats.db :as group-chats.db]
|
[status-im.group-chats.db :as group-chats.db]
|
||||||
|
[status-im.group-chats.core :as group-chat]
|
||||||
[status-im.i18n :as i18n]
|
[status-im.i18n :as i18n]
|
||||||
[status-im.multiaccounts.core :as multiaccounts]
|
[status-im.multiaccounts.core :as multiaccounts]
|
||||||
[status-im.multiaccounts.db :as multiaccounts.db]
|
[status-im.multiaccounts.db :as multiaccounts.db]
|
||||||
|
@ -867,6 +868,13 @@
|
||||||
(fn [[invitations]]
|
(fn [[invitations]]
|
||||||
(filter #(= constants/invitation-state-requested (:state %)) invitations)))
|
(filter #(= constants/invitation-state-requested (:state %)) invitations)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:group-chat/removed-from-current-chat?
|
||||||
|
:<- [:chats/current-raw-chat]
|
||||||
|
:<- [:multiaccount/public-key]
|
||||||
|
(fn [[current-chat pk]]
|
||||||
|
(group-chat/member-removed? current-chat pk)))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:chats/transaction-status
|
:chats/transaction-status
|
||||||
;;TODO address here for transactions
|
;;TODO address here for transactions
|
||||||
|
|
|
@ -19,12 +19,11 @@
|
||||||
(i18n/label :t/join-group-chat)])
|
(i18n/label :t/join-group-chat)])
|
||||||
|
|
||||||
(defn decline-chat [chat-id]
|
(defn decline-chat [chat-id]
|
||||||
[react/touchable-highlight
|
[quo/button
|
||||||
{:on-press
|
{:type :secondary
|
||||||
#(debounce/dispatch-and-chill [:group-chats.ui/leave-chat-confirmed chat-id] 2000)
|
:accessibility-label :decline-chat-button
|
||||||
:accessibility-label :decline-chat-button}
|
:on-press #(debounce/dispatch-and-chill [:group-chats.ui/leave-chat-confirmed chat-id] 2000)}
|
||||||
[react/text {:style style/decline-chat}
|
(i18n/label :t/group-chat-decline-invitation)])
|
||||||
(i18n/label :t/group-chat-decline-invitation)]])
|
|
||||||
|
|
||||||
(defn request-membership [{:keys [state introduction-message] :as invitation}]
|
(defn request-membership [{:keys [state introduction-message] :as invitation}]
|
||||||
(let [{:keys [message retry?]} @(re-frame/subscribe [:chats/current-chat-membership])]
|
(let [{:keys [message retry?]} @(re-frame/subscribe [:chats/current-chat-membership])]
|
||||||
|
@ -64,10 +63,11 @@
|
||||||
(defview group-chat-footer
|
(defview group-chat-footer
|
||||||
[chat-id invitation-admin]
|
[chat-id invitation-admin]
|
||||||
(letsubs [{:keys [joined?]} [:group-chat/inviter-info chat-id]
|
(letsubs [{:keys [joined?]} [:group-chat/inviter-info chat-id]
|
||||||
|
removed? [:group-chat/removed-from-current-chat?]
|
||||||
invitations [:group-chat/invitations-by-chat-id chat-id]]
|
invitations [:group-chat/invitations-by-chat-id chat-id]]
|
||||||
(if invitation-admin
|
(if invitation-admin
|
||||||
[request-membership (first invitations)]
|
[request-membership (first invitations)]
|
||||||
(when-not joined?
|
(when (and (not joined?) (not removed?))
|
||||||
[react/view {:style style/group-chat-join-footer}
|
[react/view {:style style/group-chat-join-footer}
|
||||||
[react/view {:style style/group-chat-join-container}
|
[react/view {:style style/group-chat-join-container}
|
||||||
[join-chat-button chat-id]
|
[join-chat-button chat-id]
|
||||||
|
|
|
@ -104,13 +104,10 @@
|
||||||
|
|
||||||
(def group-chat-join-container
|
(def group-chat-join-container
|
||||||
{:flex 1
|
{:flex 1
|
||||||
|
:padding-bottom 40
|
||||||
:align-items :center
|
:align-items :center
|
||||||
:justify-content :center})
|
:justify-content :center})
|
||||||
|
|
||||||
(def decline-chat
|
|
||||||
{:color colors/blue
|
|
||||||
:margin-bottom 40})
|
|
||||||
|
|
||||||
(def are-you-friends-bubble
|
(def are-you-friends-bubble
|
||||||
{:border-radius 8
|
{:border-radius 8
|
||||||
:border-width 1
|
:border-width 1
|
||||||
|
|
Loading…
Reference in New Issue