[Fixes: #14623] Enable mutual contacts by default and show banner
This commit is contained in:
parent
5c0bd33697
commit
7a5871a03f
|
@ -0,0 +1,13 @@
|
|||
(ns quo2.components.drawers.permission-context.--tests--.permission-context-component-spec
|
||||
(:require [quo2.components.drawers.permission-context.view :as permission-context]
|
||||
[react-native.core :as rn]
|
||||
[test-helpers.component :as h]))
|
||||
|
||||
(h/describe "permission context"
|
||||
(h/test
|
||||
(h/render [permission-context/view
|
||||
[rn/text
|
||||
{:accessibility-label :accessibility-id}
|
||||
"a sample label"]])
|
||||
(-> (js/expect (h/get-by-label-text :accessibility-id))
|
||||
(.toBeTruthy))))
|
|
@ -0,0 +1,16 @@
|
|||
(ns quo2.components.drawers.permission-context.style
|
||||
(:require [quo2.foundations.colors :as colors]))
|
||||
|
||||
(def radius 20)
|
||||
(def container
|
||||
{:padding-top 16
|
||||
:padding-bottom 48
|
||||
:padding-horizontal 20
|
||||
:shadow-offset {:width 0
|
||||
:height 2}
|
||||
:shadow-radius radius
|
||||
:border-top-left-radius radius
|
||||
:border-top-right-radius radius
|
||||
:elevation 2
|
||||
:shadow-opacity 1
|
||||
:shadow-color colors/shadow})
|
|
@ -0,0 +1,8 @@
|
|||
(ns quo2.components.drawers.permission-context.view
|
||||
(:require [react-native.core :as rn]
|
||||
[quo2.components.drawers.permission-context.style :as style]))
|
||||
|
||||
(defn view
|
||||
[children]
|
||||
[rn/view {:style style/container}
|
||||
children])
|
|
@ -4,6 +4,7 @@
|
|||
[quo2.components.counter.--tests--.counter-component-spec]
|
||||
[quo2.components.dividers.--tests--.divider-label-component-spec]
|
||||
[quo2.components.drawers.--tests--.action-drawers-component-spec]
|
||||
[quo2.components.drawers.permission-context.--tests--.permission-context-component-spec]
|
||||
[quo2.components.markdown.--tests--.text-component-spec]
|
||||
[quo2.components.selectors.--tests--.selectors-component-spec]
|
||||
[quo2.components.selectors.filter.component-spec]))
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
[status-im.contact.block :as contact.block]
|
||||
[status-im.contact.db :as contact.db]
|
||||
[status-im.data-store.contacts :as contacts-store]
|
||||
[status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||
[utils.re-frame :as rf]
|
||||
[status-im2.navigation.events :as navigation]
|
||||
[taoensso.timbre :as log]))
|
||||
|
@ -151,15 +150,6 @@
|
|||
#(re-frame/dispatch [:sanitize-messages-and-process-response %]))
|
||||
(navigation/navigate-back)))
|
||||
|
||||
(rf/defn switch-mutual-contact-requests-enabled
|
||||
{:events [:multiaccounts.ui/switch-mutual-contact-requests-enabled]}
|
||||
[cofx enabled?]
|
||||
(multiaccounts.update/multiaccount-update
|
||||
cofx
|
||||
:mutual-contact-enabled?
|
||||
enabled?
|
||||
nil))
|
||||
|
||||
(rf/defn set-search-query
|
||||
{:events [:contacts/set-search-query]}
|
||||
[{:keys [db] :as cofx} value]
|
||||
|
|
|
@ -86,8 +86,9 @@
|
|||
(get-in db [:contacts/contacts public-key]))
|
||||
|
||||
(defn added?
|
||||
([contact]
|
||||
(:added contact))
|
||||
([{:keys [contact-request-state]}]
|
||||
(or (= constants/contact-request-state-mutual contact-request-state)
|
||||
(= constants/contact-request-state-sent contact-request-state)))
|
||||
([db public-key]
|
||||
(added? (get-in db [:contacts/contacts public-key]))))
|
||||
|
||||
|
@ -98,27 +99,28 @@
|
|||
(blocked? (get-in db [:contacts/contacts public-key]))))
|
||||
|
||||
(defn active?
|
||||
"Checks that the user is added to the contact and not blocked"
|
||||
"Checks that we are mutual contacts"
|
||||
([contact]
|
||||
(and (:added contact)
|
||||
(and (= constants/contact-request-state-mutual
|
||||
(:contact-request-state contact))
|
||||
(not (:blocked contact))))
|
||||
([db public-key]
|
||||
(active? (get-in db [:contacts/contacts public-key]))))
|
||||
|
||||
(defn enrich-contact
|
||||
([contact] (enrich-contact contact nil nil))
|
||||
([{:keys [added public-key] :as contact} setting own-public-key]
|
||||
([{:keys [public-key] :as contact} setting own-public-key]
|
||||
(cond-> (-> contact
|
||||
(dissoc :ens-verified-at :ens-verification-retries)
|
||||
(assoc :blocked? (:blocked contact)
|
||||
:active? (active? contact)
|
||||
:added? added)
|
||||
:added? (added? contact))
|
||||
(multiaccounts/contact-with-names))
|
||||
(and setting
|
||||
(not= public-key own-public-key)
|
||||
(or (= setting constants/profile-pictures-visibility-none)
|
||||
(and (= setting constants/profile-pictures-visibility-contacts-only)
|
||||
(not added))))
|
||||
(not (added? contact)))))
|
||||
(dissoc :images))))
|
||||
|
||||
(defn enrich-contacts
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
transactions-management-enabled?
|
||||
wakuv2-flag
|
||||
current-fleet
|
||||
webview-debug
|
||||
mutual-contact-requests-enabled?]}]
|
||||
webview-debug]}]
|
||||
(keep
|
||||
identity
|
||||
[{:size :small
|
||||
|
@ -115,17 +114,7 @@
|
|||
#(re-frame/dispatch
|
||||
[:multiaccounts.ui/waku-bloom-filter-mode-switched (not waku-bloom-filter-mode)])
|
||||
:accessory :switch
|
||||
:active waku-bloom-filter-mode}
|
||||
{:size :small
|
||||
:title (i18n/label :t/mutual-contact-requests)
|
||||
:accessibility-label :mutual-contact-requests-switch
|
||||
:container-margin-bottom 8
|
||||
:on-press
|
||||
#(re-frame/dispatch
|
||||
[:multiaccounts.ui/switch-mutual-contact-requests-enabled
|
||||
(not mutual-contact-requests-enabled?)])
|
||||
:accessory :switch
|
||||
:active mutual-contact-requests-enabled?}]))
|
||||
:active waku-bloom-filter-mode}]))
|
||||
|
||||
(defn- flat-list-data
|
||||
[options]
|
||||
|
@ -146,8 +135,7 @@
|
|||
communities-enabled? [:communities/enabled?]
|
||||
transactions-management-enabled? [:wallet/transactions-management-enabled?]
|
||||
current-log-level [:log-level/current-log-level]
|
||||
current-fleet [:fleets/current-fleet]
|
||||
mutual-contact-requests-enabled? [:mutual-contact-requests/enabled?]]
|
||||
current-fleet [:fleets/current-fleet]]
|
||||
[list/flat-list
|
||||
{:data (flat-list-data
|
||||
{:network-name network-name
|
||||
|
@ -158,7 +146,6 @@
|
|||
:dev-mode? false
|
||||
:wakuv2-flag wakuv2-flag
|
||||
:waku-bloom-filter-mode waku-bloom-filter-mode
|
||||
:webview-debug webview-debug
|
||||
:mutual-contact-requests-enabled? mutual-contact-requests-enabled?})
|
||||
:webview-debug webview-debug})
|
||||
:key-fn (fn [_ i] (str i))
|
||||
:render-fn render-item}]))
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
[quo.design-system.colors :as colors]
|
||||
[quo.react :as quo.react]
|
||||
[quo.react-native :as rn]
|
||||
[re-frame.core :as re-frame]
|
||||
[re-frame.core :as rf]
|
||||
re-frame.db
|
||||
[reagent.core :as reagent]
|
||||
[status-im.constants :as constants]
|
||||
|
@ -42,13 +42,13 @@
|
|||
|
||||
(defn invitation-requests
|
||||
[chat-id admins]
|
||||
(let [current-pk @(re-frame/subscribe [:multiaccount/public-key])
|
||||
(let [current-pk @(rf/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])]
|
||||
(let [invitations @(rf/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])
|
||||
{:on-press #(rf/dispatch [:navigate-to :group-chat-invite])
|
||||
:accessibility-label :invitation-requests-button}
|
||||
[react/view {:style (style/add-contact)}
|
||||
[react/text {:style style/add-contact-text}
|
||||
|
@ -56,11 +56,11 @@
|
|||
|
||||
(defn add-contact-bar
|
||||
[public-key]
|
||||
(when-not (or @(re-frame/subscribe [:contacts/contact-added? public-key])
|
||||
@(re-frame/subscribe [:contacts/contact-blocked? public-key]))
|
||||
(when-not (or @(rf/subscribe [:contacts/contact-added? public-key])
|
||||
@(rf/subscribe [:contacts/contact-blocked? public-key]))
|
||||
[react/touchable-highlight
|
||||
{:on-press
|
||||
#(re-frame/dispatch [:contact.ui/add-to-contact-pressed public-key])
|
||||
#(rf/dispatch [:contact.ui/add-to-contact-pressed public-key])
|
||||
:accessibility-label :add-to-contacts-button}
|
||||
[react/view {:style (style/add-contact)}
|
||||
[icons/icon :main-icons/add
|
||||
|
@ -69,7 +69,7 @@
|
|||
|
||||
(defn contact-request
|
||||
[]
|
||||
(let [contact-request @(re-frame/subscribe [:chats/sending-contact-request])]
|
||||
(let [contact-request @(rf/subscribe [:chats/sending-contact-request])]
|
||||
[react/view {:style style/contact-request}
|
||||
[react/image
|
||||
{:source (resources/get-image :hand-wave)
|
||||
|
@ -92,7 +92,7 @@
|
|||
[quo/button
|
||||
{:style {:width "100%"}
|
||||
:accessibility-label :contact-request--button
|
||||
:on-press #(re-frame/dispatch [:chat.ui/send-contact-request])}
|
||||
:on-press #(rf/dispatch [:chat.ui/send-contact-request])}
|
||||
(i18n/label :t/contact-request)]])]))
|
||||
|
||||
(defn chat-intro
|
||||
|
@ -101,7 +101,6 @@
|
|||
chat-type
|
||||
group-chat
|
||||
invitation-admin
|
||||
mutual-contact-requests-enabled?
|
||||
contact-name
|
||||
color
|
||||
loading-messages?
|
||||
|
@ -136,25 +135,23 @@
|
|||
:no-messages? no-messages?}]
|
||||
[react/text {:style (assoc style/intro-header-description :margin-bottom 32)}
|
||||
(str (i18n/label :t/empty-chat-description-one-to-one) contact-name)])
|
||||
(when (and mutual-contact-requests-enabled?
|
||||
(= chat-type constants/one-to-one-chat-type)
|
||||
(or (= contact-request-state constants/contact-request-state-none)
|
||||
(= contact-request-state constants/contact-request-state-received)
|
||||
(= contact-request-state constants/contact-request-state-dismissed)))
|
||||
[contact-request])])
|
||||
(when
|
||||
(= chat-type constants/one-to-one-chat-type)
|
||||
(or (= contact-request-state constants/contact-request-state-none)
|
||||
(= contact-request-state constants/contact-request-state-received)
|
||||
(= contact-request-state constants/contact-request-state-dismissed)))
|
||||
[contact-request]])
|
||||
|
||||
(defn chat-intro-one-to-one
|
||||
[{:keys [chat-id] :as opts}]
|
||||
(let [contact @(re-frame/subscribe [:contacts/contact-by-identity chat-id])
|
||||
mutual-contact-requests-enabled? @(re-frame/subscribe [:mutual-contact-requests/enabled?])
|
||||
contact-names @(re-frame/subscribe [:contacts/contact-two-names-by-identity
|
||||
chat-id])]
|
||||
(let [contact @(rf/subscribe [:contacts/contact-by-identity chat-id])
|
||||
contact-names @(rf/subscribe [:contacts/contact-two-names-by-identity
|
||||
chat-id])]
|
||||
[chat-intro
|
||||
(assoc opts
|
||||
:mutual-contact-requests-enabled? mutual-contact-requests-enabled?
|
||||
:contact-name (first contact-names)
|
||||
:contact-request-state (or (:contact-request-state contact)
|
||||
constants/contact-request-state-none))]))
|
||||
:contact-name (first contact-names)
|
||||
:contact-request-state (or (:contact-request-state contact)
|
||||
constants/contact-request-state-none))]))
|
||||
|
||||
(defn chat-intro-header-container
|
||||
[{:keys [group-chat invitation-admin
|
||||
|
@ -217,8 +214,8 @@
|
|||
(defn invitation-bar
|
||||
[chat-id]
|
||||
(let [{:keys [state chat-id] :as invitation}
|
||||
(first @(re-frame/subscribe [:group-chat/invitations-by-chat-id chat-id]))
|
||||
{:keys [retry? message]} @(re-frame/subscribe [:chats/current-chat-membership])
|
||||
(first @(rf/subscribe [:group-chat/invitations-by-chat-id chat-id]))
|
||||
{:keys [retry? message]} @(rf/subscribe [:chats/current-chat-membership])
|
||||
message-length (count message)]
|
||||
[react/view {:margin-horizontal 16 :margin-top 10}
|
||||
(cond
|
||||
|
@ -238,13 +235,13 @@
|
|||
[quo/button
|
||||
{:type :secondary
|
||||
:accessibility-label :retry-button
|
||||
:on-press #(re-frame/dispatch [:group-chats.ui/membership-retry])}
|
||||
:on-press #(rf/dispatch [:group-chats.ui/membership-retry])}
|
||||
(i18n/label :t/mailserver-retry)]
|
||||
:left
|
||||
[quo/button
|
||||
{:type :secondary
|
||||
:accessibility-label :remove-group-button
|
||||
:on-press #(re-frame/dispatch [:group-chats.ui/remove-chat-confirmed chat-id])}
|
||||
:on-press #(rf/dispatch [:group-chats.ui/remove-chat-confirmed chat-id])}
|
||||
(i18n/label :t/remove-group)]}]
|
||||
:else
|
||||
[toolbar/toolbar
|
||||
|
@ -255,7 +252,7 @@
|
|||
:accessibility-label :introduce-yourself-button
|
||||
:disabled (or (string/blank? message)
|
||||
(> message-length chat.group/message-max-length))
|
||||
:on-press #(re-frame/dispatch [:send-group-chat-membership-request])}
|
||||
:on-press #(rf/dispatch [:send-group-chat-membership-request])}
|
||||
(i18n/label :t/request-membership)]}])]))
|
||||
|
||||
(defn get-space-keeper-ios
|
||||
|
@ -289,9 +286,9 @@
|
|||
|
||||
(defn list-footer
|
||||
[{:keys [chat-id] :as chat}]
|
||||
(let [loading-messages? @(re-frame/subscribe [:chats/loading-messages? chat-id])
|
||||
no-messages? @(re-frame/subscribe [:chats/chat-no-messages? chat-id])
|
||||
all-loaded? @(re-frame/subscribe [:chats/all-loaded? chat-id])]
|
||||
(let [loading-messages? @(rf/subscribe [:chats/loading-messages? chat-id])
|
||||
no-messages? @(rf/subscribe [:chats/chat-no-messages? chat-id])
|
||||
all-loaded? @(rf/subscribe [:chats/all-loaded? chat-id])]
|
||||
[react/view {:style (when platform/android? {:scaleY -1})}
|
||||
(if (or loading-messages? (not chat-id) (not all-loaded?))
|
||||
[react/view {:height 324 :align-items :center :justify-content :center}
|
||||
|
@ -340,15 +337,15 @@
|
|||
(defn list-on-end-reached
|
||||
[]
|
||||
(if @state/scrolling
|
||||
(re-frame/dispatch [:chat.ui/load-more-messages-for-current-chat])
|
||||
(utils/set-timeout #(re-frame/dispatch [:chat.ui/load-more-messages-for-current-chat])
|
||||
(rf/dispatch [:chat.ui/load-more-messages-for-current-chat])
|
||||
(utils/set-timeout #(rf/dispatch [:chat.ui/load-more-messages-for-current-chat])
|
||||
(if platform/low-device? 700 200))))
|
||||
|
||||
(defn get-render-data
|
||||
[{:keys [group-chat chat-id public? community-id admins space-keeper show-input? edit-enabled
|
||||
in-pinned-view?]}]
|
||||
(let [current-public-key @(re-frame/subscribe [:multiaccount/public-key])
|
||||
community @(re-frame/subscribe [:communities/community community-id])
|
||||
(let [current-public-key @(rf/subscribe [:multiaccount/public-key])
|
||||
community @(rf/subscribe [:communities/community community-id])
|
||||
group-admin? (get admins current-public-key)
|
||||
community-admin? (when community (community :admin))
|
||||
message-pin-enabled (and (not public?)
|
||||
|
@ -371,17 +368,15 @@
|
|||
[{:keys [chat
|
||||
bottom-space
|
||||
pan-responder
|
||||
mutual-contact-requests-enabled?
|
||||
space-keeper
|
||||
show-input?]}]
|
||||
(let [{:keys [group-chat chat-type chat-id public? community-id admins]} chat
|
||||
|
||||
messages @(re-frame/subscribe [:chats/raw-chat-messages-stream chat-id])
|
||||
messages @(rf/subscribe [:chats/raw-chat-messages-stream chat-id])
|
||||
one-to-one? (= chat-type constants/one-to-one-chat-type)
|
||||
contact-added? (when one-to-one? @(re-frame/subscribe [:contacts/contact-added? chat-id]))
|
||||
contact-added? (when one-to-one? @(rf/subscribe [:contacts/contact-added? chat-id]))
|
||||
should-send-contact-request?
|
||||
(and
|
||||
mutual-contact-requests-enabled?
|
||||
one-to-one?
|
||||
(not contact-added?))]
|
||||
|
||||
|
@ -423,13 +418,13 @@
|
|||
[]
|
||||
(when (and (not @navigation.state/curr-modal) (= (get @re-frame.db/app-db :view-id) :chat))
|
||||
(react/hw-back-remove-listener navigate-back-handler)
|
||||
(re-frame/dispatch [:close-chat])
|
||||
(re-frame/dispatch [:navigate-back])))
|
||||
(rf/dispatch [:close-chat])
|
||||
(rf/dispatch [:navigate-back])))
|
||||
|
||||
(defn topbar-content
|
||||
[]
|
||||
(let [window-width @(re-frame/subscribe [:dimensions/window-width])
|
||||
{:keys [group-chat chat-id] :as chat-info} @(re-frame/subscribe [:chats/current-chat])]
|
||||
(let [window-width @(rf/subscribe [:dimensions/window-width])
|
||||
{:keys [group-chat chat-id] :as chat-info} @(rf/subscribe [:chats/current-chat])]
|
||||
[react/touchable-highlight
|
||||
{:on-press #(when-not group-chat
|
||||
(debounce/dispatch-and-chill [:chat.ui/show-profile chat-id] 1000))
|
||||
|
@ -452,9 +447,9 @@
|
|||
[react/view {:flex 1 :left 52 :right 52 :top 0 :bottom 0 :position :absolute}
|
||||
[topbar-content]]
|
||||
[react/touchable-highlight
|
||||
{:on-press-in #(re-frame/dispatch [:bottom-sheet/show-sheet
|
||||
{:content (fn [] [sheets/current-chat-actions])
|
||||
:height 256}])
|
||||
{:on-press-in #(rf/dispatch [:bottom-sheet/show-sheet
|
||||
{:content (fn [] [sheets/current-chat-actions])
|
||||
:height 256}])
|
||||
:accessibility-label :chat-menu-button
|
||||
:style {:right 0
|
||||
:top 0
|
||||
|
@ -481,26 +476,28 @@
|
|||
set-active-panel (get-set-active-panel active-panel)
|
||||
on-close #(set-active-panel nil)]
|
||||
(fn []
|
||||
(let [{:keys [chat-id show-input? group-chat admins invitation-admin] :as chat}
|
||||
;;we want to react only on these fields, do not use full chat map here
|
||||
@(re-frame/subscribe [:chats/current-chat-chat-view])
|
||||
mutual-contact-requests-enabled? @(re-frame/subscribe [:mutual-contact-requests/enabled?])
|
||||
max-bottom-space (max @bottom-space @panel-space)]
|
||||
(let [{:keys [chat-id
|
||||
show-input?
|
||||
group-chat
|
||||
admins
|
||||
invitation-admin]
|
||||
:as chat}
|
||||
@(rf/subscribe [:chats/current-chat-chat-view])
|
||||
max-bottom-space (max @bottom-space
|
||||
@panel-space)]
|
||||
[:<>
|
||||
[topbar]
|
||||
[connectivity/loading-indicator]
|
||||
(when chat-id
|
||||
(if group-chat
|
||||
[invitation-requests chat-id admins]
|
||||
(when-not mutual-contact-requests-enabled? [add-contact-bar chat-id])))
|
||||
(when group-chat
|
||||
[invitation-requests chat-id admins]))
|
||||
;;MESSAGES LIST
|
||||
[messages-view
|
||||
{:chat chat
|
||||
:bottom-space max-bottom-space
|
||||
:pan-responder pan-responder
|
||||
:mutual-contact-requests-enabled? mutual-contact-requests-enabled?
|
||||
:space-keeper space-keeper
|
||||
:show-input? show-input?}]
|
||||
{:chat chat
|
||||
:bottom-space max-bottom-space
|
||||
:pan-responder pan-responder
|
||||
:space-keeper space-keeper
|
||||
:show-input? show-input?}]
|
||||
(when (and group-chat invitation-admin)
|
||||
[accessory/view
|
||||
{:y position-y
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
(ns status-im2.contexts.chat.messages.contact-requests.bottom-drawer
|
||||
(:require
|
||||
[i18n.i18n :as i18n]
|
||||
[utils.re-frame :as rf]
|
||||
[quo2.core :as quo]
|
||||
[quo2.components.drawers.permission-context.view :as permission-context]
|
||||
[status-im2.common.constants :as constants]))
|
||||
|
||||
(defn view
|
||||
[contact-id contact-request-state]
|
||||
(let [names (rf/sub [:contacts/contact-two-names-by-identity contact-id])]
|
||||
[permission-context/view
|
||||
[quo/button
|
||||
{:type :ghost
|
||||
:on-press #(rf/dispatch [:chat.ui/show-profile contact-id])
|
||||
:before :i/communities}
|
||||
(cond
|
||||
(or (= contact-request-state
|
||||
constants/contact-request-state-none)
|
||||
(= contact-request-state
|
||||
constants/contact-request-state-received))
|
||||
(i18n/label :t/contact-request-chat-add {:name (first names)})
|
||||
(= contact-request-state
|
||||
constants/contact-request-state-sent)
|
||||
|
||||
(i18n/label :t/contact-request-chat-pending))]]))
|
|
@ -131,17 +131,10 @@
|
|||
[{:keys [chat
|
||||
pan-responder
|
||||
show-input?]}]
|
||||
(let [{:keys [group-chat chat-type chat-id public? community-id admins]} chat
|
||||
mutual-contact-requests-enabled? (rf/sub [:mutual-contact-requests/enabled?])
|
||||
messages (rf/sub [:chats/raw-chat-messages-stream chat-id])
|
||||
one-to-one? (= chat-type constants/one-to-one-chat-type)
|
||||
contact-added? (when one-to-one? (rf/sub [:contacts/contact-added? chat-id]))
|
||||
should-send-contact-request?
|
||||
(and
|
||||
mutual-contact-requests-enabled?
|
||||
one-to-one?
|
||||
(not contact-added?))
|
||||
bottom-space 15]
|
||||
(let [{:keys [group-chat chat-id public? community-id admins]} chat
|
||||
messages (rf/sub [:chats/raw-chat-messages-stream
|
||||
chat-id])
|
||||
bottom-space 15]
|
||||
[rn/view
|
||||
{:style {:flex 1}}
|
||||
;;DO NOT use anonymous functions for handlers
|
||||
|
@ -152,7 +145,7 @@
|
|||
:ref list-ref
|
||||
:header [list-header chat]
|
||||
:footer [list-footer chat]
|
||||
:data (when-not should-send-contact-request? messages)
|
||||
:data messages
|
||||
:render-data (get-render-data {:group-chat group-chat
|
||||
:chat-id chat-id
|
||||
:public? public?
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
[status-im.ui2.screens.chat.pin-limit-popover.view :as pin-limit-popover]
|
||||
[status-im2.common.constants :as constants]
|
||||
[status-im2.contexts.chat.messages.list.view :as messages.list]
|
||||
[status-im2.contexts.chat.messages.contact-requests.bottom-drawer :as
|
||||
contact-requests.bottom-drawer]
|
||||
[status-im2.contexts.chat.messages.pin.banner.view :as pin.banner] ;;TODO move to status-im2
|
||||
[status-im2.navigation.state :as navigation.state]
|
||||
[utils.debounce :as debounce]
|
||||
|
@ -62,8 +64,11 @@
|
|||
|
||||
(defn chat-render
|
||||
[]
|
||||
(let [;;NOTE: we want to react only on these fields, do not use full chat map here
|
||||
{:keys [chat-id show-input?] :as chat} (rf/sub [:chats/current-chat-chat-view])]
|
||||
(let [{:keys [chat-id
|
||||
contact-request-state
|
||||
show-input?]
|
||||
:as chat}
|
||||
(rf/sub [:chats/current-chat-chat-view])]
|
||||
[rn/keyboard-avoiding-view {:style {:position :relative :flex 1}}
|
||||
[rn/view
|
||||
{:style {:position :absolute
|
||||
|
@ -74,14 +79,15 @@
|
|||
|
||||
[pin.banner/banner chat-id]
|
||||
[not-implemented/not-implemented
|
||||
[pin-limit-popover/pin-limit-popover chat-id]]
|
||||
]
|
||||
[pin-limit-popover/pin-limit-popover chat-id]]]
|
||||
[page-nav]
|
||||
|
||||
|
||||
[messages.list/messages-list {:chat chat :show-input? show-input?}]
|
||||
(when show-input?
|
||||
[composer/composer chat-id])]))
|
||||
(cond (and (not show-input?)
|
||||
contact-request-state)
|
||||
[contact-requests.bottom-drawer/view chat-id contact-request-state]
|
||||
|
||||
show-input?
|
||||
[composer/composer chat-id])]))
|
||||
|
||||
(defn chat
|
||||
[]
|
||||
|
|
|
@ -171,11 +171,10 @@
|
|||
:<- [:multiaccount/public-key]
|
||||
:<- [:communities/current-community]
|
||||
:<- [:contacts/blocked-set]
|
||||
:<- [:contacts/contacts]
|
||||
:<- [:contacts/contacts-raw]
|
||||
:<- [:chat/inputs]
|
||||
:<- [:mutual-contact-requests/enabled?]
|
||||
(fn [[{:keys [group-chat chat-id] :as current-chat} my-public-key community blocked-users-set contacts
|
||||
inputs mutual-contact-requests-enabled?]]
|
||||
inputs]]
|
||||
(when current-chat
|
||||
(cond-> current-chat
|
||||
(chat.models/public-chat? current-chat)
|
||||
|
@ -191,23 +190,35 @@
|
|||
(assoc :show-input? true)
|
||||
|
||||
(not group-chat)
|
||||
(assoc :show-input?
|
||||
(and
|
||||
(or
|
||||
(not mutual-contact-requests-enabled?)
|
||||
(get-in inputs [chat-id :metadata :sending-contact-request])
|
||||
(and mutual-contact-requests-enabled?
|
||||
(= constants/contact-request-state-mutual
|
||||
(get-in contacts [chat-id :contact-request-state]))))
|
||||
(not (contains? blocked-users-set chat-id))))))))
|
||||
(assoc
|
||||
:contact-request-state (get-in contacts [chat-id :contact-request-state])
|
||||
:show-input?
|
||||
(and
|
||||
(or
|
||||
(get-in inputs [chat-id :metadata :sending-contact-request])
|
||||
(= constants/contact-request-state-mutual
|
||||
(get-in contacts [chat-id :contact-request-state])))
|
||||
(not (contains? blocked-users-set chat-id))))))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:chats/current-chat-chat-view
|
||||
:<- [:chats/current-chat]
|
||||
(fn [current-chat]
|
||||
(select-keys current-chat
|
||||
[:chat-id :show-input? :group-chat :admins :invitation-admin :public? :chat-type :color
|
||||
:chat-name :synced-to :synced-from :community-id :emoji])))
|
||||
[:chat-id
|
||||
:show-input?
|
||||
:group-chat
|
||||
:admins
|
||||
:invitation-admin
|
||||
:public?
|
||||
:chat-type
|
||||
:color
|
||||
:contact-request-state
|
||||
:chat-name
|
||||
:synced-to
|
||||
:synced-from
|
||||
:community-id
|
||||
:emoji])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:current-chat/metadata
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
(ns status-im2.subs.chat.chats-test
|
||||
(:require [cljs.test :refer [is testing]]
|
||||
[re-frame.db :as rf-db]
|
||||
[test-helpers.unit :as h]
|
||||
[status-im2.common.constants :as constants]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(def public-key "0xpk")
|
||||
(def multiaccount {:public-key public-key})
|
||||
(def chat-id "1")
|
||||
(def chat {:chat-id chat-id})
|
||||
|
||||
(def private-group-chat
|
||||
(assoc
|
||||
chat
|
||||
:members #{{:id public-key}}
|
||||
:group-chat true
|
||||
:chat-type constants/private-group-chat-type))
|
||||
|
||||
(def one-to-one-chat
|
||||
(assoc
|
||||
chat
|
||||
:chat-type
|
||||
constants/one-to-one-chat-type))
|
||||
|
||||
(h/deftest-sub :chats/current-chat
|
||||
[sub-name]
|
||||
(testing "private group chat, user is a member"
|
||||
(let [chats {chat-id private-group-chat}]
|
||||
(swap! rf-db/app-db assoc
|
||||
:multiaccount multiaccount
|
||||
:current-chat-id chat-id
|
||||
:chats chats)
|
||||
(is (true? (:show-input? (rf/sub [sub-name]))))))
|
||||
(testing "private group chat, user is not member"
|
||||
(let [chats {chat-id (dissoc private-group-chat :members)}]
|
||||
(swap! rf-db/app-db assoc
|
||||
:multiaccount multiaccount
|
||||
:current-chat-id chat-id
|
||||
:chats chats)
|
||||
(is (not (:show-input? (rf/sub [sub-name]))))))
|
||||
(testing "one to one chat, mutual contacts"
|
||||
(let [chats {chat-id one-to-one-chat}]
|
||||
(swap! rf-db/app-db assoc
|
||||
:contacts/contacts {chat-id {:contact-request-state constants/contact-request-state-mutual}}
|
||||
:multiaccount multiaccount
|
||||
:current-chat-id chat-id
|
||||
:chats chats)
|
||||
(is (:show-input? (rf/sub [sub-name])))))
|
||||
(testing "one to one chat, not a contact"
|
||||
(let [chats {chat-id one-to-one-chat}]
|
||||
(swap! rf-db/app-db assoc
|
||||
:contacts/contacts {chat-id {:contact-request-state constants/contact-request-state-sent}}
|
||||
:multiaccount multiaccount
|
||||
:current-chat-id chat-id
|
||||
:chats chats)
|
||||
(is (not (:show-input? (rf/sub [sub-name])))))))
|
|
@ -23,12 +23,6 @@
|
|||
(fn [multiaccount]
|
||||
(get multiaccount :profile-pictures-show-to)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:mutual-contact-requests/enabled?
|
||||
:<- [:multiaccount]
|
||||
(fn [settings]
|
||||
(boolean (:mutual-contact-enabled? settings))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::profile-pictures-visibility
|
||||
:<- [:multiaccount]
|
||||
|
|
|
@ -1935,5 +1935,7 @@
|
|||
"who-are-you-looking-for": "Who are you looking for ?",
|
||||
"close-contact-search": "Close contact search",
|
||||
"selected-count-from-max": "{{selected}}/{{max}}",
|
||||
"online": "Online"
|
||||
"online": "Online",
|
||||
"contact-request-chat-pending": "Your contact request is pending",
|
||||
"contact-request-chat-add": "Add {{name}} to send a message"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue