From 9e7db45d08a535a05775970ff6257c4c8ef2f1c5 Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Thu, 24 Nov 2022 19:45:27 +0530 Subject: [PATCH] fix everyone is displaying as online in community channel and chat list (#14431) also fixes issue with visibility status popover not opening --- src/status_im/events.cljs | 1 + .../profile/visibility_status/views.cljs | 10 ++-------- .../ui2/screens/chat/messages/message.cljs | 5 +++-- .../chat/home/chat_list_item/view.cljs | 12 +++++++----- src/status_im2/subs/general.cljs | 18 ++++++++++++++++-- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/status_im/events.cljs b/src/status_im/events.cljs index af4a938b60..d7f4230f0b 100644 --- a/src/status_im/events.cljs +++ b/src/status_im/events.cljs @@ -57,6 +57,7 @@ status-im.wallet-connect.core status-im.wallet-connect-legacy.core status-im.network.net-info + status-im.visibility-status-popover.core [status-im.multiaccounts.model :as multiaccounts.model])) (re-frame/reg-fx diff --git a/src/status_im/ui/screens/profile/visibility_status/views.cljs b/src/status_im/ui/screens/profile/visibility_status/views.cljs index 007d6e5d5b..bfafd20c93 100644 --- a/src/status_im/ui/screens/profile/visibility_status/views.cljs +++ b/src/status_im/ui/screens/profile/visibility_status/views.cljs @@ -25,17 +25,11 @@ (re-frame/dispatch [:visibility-status-updates/delayed-visibility-status-update status-type])) -;; In new ui, we are allowing switcher to overlap status-bar (draw over status bar) -;; that's why the measure will return height including, the height of the status bar in android -;; for calculating the correct position of the button on the profile screen, we have to decrease this height (defn calculate-button-height-and-dispatch-popover [] (.measure @button-ref - (fn [_ _ _ _ _ py] - (dispatch-popover - (if (and platform/android? true) - (- py (:status-bar-height @rn/navigation-const)) - py))))) + (fn [_ _ _ _ _ page-y] + (dispatch-popover page-y)))) (defn profile-visibility-status-dot [status-type color] (let [automatic? (= status-type diff --git a/src/status_im/ui2/screens/chat/messages/message.cljs b/src/status_im/ui2/screens/chat/messages/message.cljs index 1357c9b123..24541bd668 100644 --- a/src/status_im/ui2/screens/chat/messages/message.cljs +++ b/src/status_im/ui2/screens/chat/messages/message.cljs @@ -309,7 +309,8 @@ (let [response-to (:response-to (:content message)) display-name (first (rf/sub [:contacts/contact-two-names-by-identity from])) contact (rf/sub [:contacts/contact-by-address from]) - photo-path (when-not (empty? (:images contact)) (rf/sub [:chats/photo-path from]))] + photo-path (when-not (empty? (:images contact)) (rf/sub [:chats/photo-path from])) + online? (rf/sub [:visibility-status-updates/online? from])] (if deleted-for-me? [system-message/system-message {:type :deleted @@ -333,7 +334,7 @@ [user-avatar/user-avatar {:full-name display-name :profile-picture photo-path :status-indicator? true - :online? true + :online? online? :size :small :ring? false}]])] [rn/view {:style (style/message-author-wrapper)} diff --git a/src/status_im2/contexts/chat/home/chat_list_item/view.cljs b/src/status_im2/contexts/chat/home/chat_list_item/view.cljs index 4618dfa39f..736c55bfef 100644 --- a/src/status_im2/contexts/chat/home/chat_list_item/view.cljs +++ b/src/status_im2/contexts/chat/home/chat_list_item/view.cljs @@ -92,13 +92,15 @@ :style (style/timestamp)} (time/to-short-str timestamp)]]) -(defn avatar-view [group-chat color display-name photo-path] +(defn avatar-view [group-chat color display-name photo-path chat-id] (if group-chat [quo/group-avatar {:color color :size :medium}] - [quo/user-avatar {:full-name display-name - :profile-picture photo-path - :size :small}])) + (let [online? (rf/sub [:visibility-status-updates/online? chat-id])] + [quo/user-avatar {:full-name display-name + :online? online? + :profile-picture photo-path + :size :small}]))) (defn chat-list-item [item] (let [{:keys [chat-id color group-chat last-message timestamp name unviewed-mentions-count @@ -110,7 +112,7 @@ :on-press (open-chat chat-id) :on-long-press #(rf/dispatch [:bottom-sheet/show-sheet {:content (fn [] [actions/actions item false])}])}) - [avatar-view group-chat color display-name photo-path] + [avatar-view group-chat color display-name photo-path chat-id] [rn/view {:style {:margin-left 8}} [name-view display-name contact timestamp] (if (string/blank? (get-in last-message [:content :parsed-text])) diff --git a/src/status_im2/subs/general.cljs b/src/status_im2/subs/general.cljs index a616309c22..434df97750 100644 --- a/src/status_im2/subs/general.cljs +++ b/src/status_im2/subs/general.cljs @@ -1,6 +1,7 @@ (ns status-im2.subs.general (:require [re-frame.core :as re-frame] [status-im.utils.build :as build] + [status-im.constants :as constants] [status-im.multiaccounts.model :as multiaccounts.model] [status-im.ethereum.core :as ethereum] [status-im.ethereum.tokens :as tokens] @@ -8,9 +9,22 @@ (re-frame/reg-sub :visibility-status-updates/visibility-status-update + :<- [:multiaccount/public-key] + :<- [:multiaccount/current-user-visibility-status] :<- [:visibility-status-updates] - (fn [visibility-status-updates [_ public-key]] - (get visibility-status-updates public-key))) + (fn [[my-public-key my-status-update status-updates] [_ public-key]] + (if (= public-key my-public-key) + my-status-update + (get status-updates public-key)))) + +(re-frame/reg-sub + :visibility-status-updates/online? + (fn [[_ public-key]] + [(re-frame/subscribe [:visibility-status-updates/visibility-status-update public-key])]) + (fn [[status-update]] + (let [visibility-status-type (:status-type status-update)] + (or (= visibility-status-type constants/visibility-status-automatic) + (= visibility-status-type constants/visibility-status-always-online))))) (re-frame/reg-sub :multiaccount/logged-in?