fix everyone is displaying as online in community channel and chat list (#14431)

also fixes issue with visibility status popover not opening
This commit is contained in:
Parvesh Monu 2022-11-24 19:45:27 +05:30 committed by GitHub
parent 14c243803f
commit 9e7db45d08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 17 deletions

View File

@ -57,6 +57,7 @@
status-im.wallet-connect.core status-im.wallet-connect.core
status-im.wallet-connect-legacy.core status-im.wallet-connect-legacy.core
status-im.network.net-info status-im.network.net-info
status-im.visibility-status-popover.core
[status-im.multiaccounts.model :as multiaccounts.model])) [status-im.multiaccounts.model :as multiaccounts.model]))
(re-frame/reg-fx (re-frame/reg-fx

View File

@ -25,17 +25,11 @@
(re-frame/dispatch (re-frame/dispatch
[:visibility-status-updates/delayed-visibility-status-update status-type])) [: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 [] (defn calculate-button-height-and-dispatch-popover []
(.measure (.measure
@button-ref @button-ref
(fn [_ _ _ _ _ py] (fn [_ _ _ _ _ page-y]
(dispatch-popover (dispatch-popover page-y))))
(if (and platform/android? true)
(- py (:status-bar-height @rn/navigation-const))
py)))))
(defn profile-visibility-status-dot [status-type color] (defn profile-visibility-status-dot [status-type color]
(let [automatic? (= status-type (let [automatic? (= status-type

View File

@ -309,7 +309,8 @@
(let [response-to (:response-to (:content message)) (let [response-to (:response-to (:content message))
display-name (first (rf/sub [:contacts/contact-two-names-by-identity from])) display-name (first (rf/sub [:contacts/contact-two-names-by-identity from]))
contact (rf/sub [:contacts/contact-by-address 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? (if deleted-for-me?
[system-message/system-message [system-message/system-message
{:type :deleted {:type :deleted
@ -333,7 +334,7 @@
[user-avatar/user-avatar {:full-name display-name [user-avatar/user-avatar {:full-name display-name
:profile-picture photo-path :profile-picture photo-path
:status-indicator? true :status-indicator? true
:online? true :online? online?
:size :small :size :small
:ring? false}]])] :ring? false}]])]
[rn/view {:style (style/message-author-wrapper)} [rn/view {:style (style/message-author-wrapper)}

View File

@ -92,13 +92,15 @@
:style (style/timestamp)} :style (style/timestamp)}
(time/to-short-str 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 (if group-chat
[quo/group-avatar {:color color [quo/group-avatar {:color color
:size :medium}] :size :medium}]
[quo/user-avatar {:full-name display-name (let [online? (rf/sub [:visibility-status-updates/online? chat-id])]
:profile-picture photo-path [quo/user-avatar {:full-name display-name
:size :small}])) :online? online?
:profile-picture photo-path
:size :small}])))
(defn chat-list-item [item] (defn chat-list-item [item]
(let [{:keys [chat-id color group-chat last-message timestamp name unviewed-mentions-count (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-press (open-chat chat-id)
:on-long-press #(rf/dispatch [:bottom-sheet/show-sheet :on-long-press #(rf/dispatch [:bottom-sheet/show-sheet
{:content (fn [] [actions/actions item false])}])}) {: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}} [rn/view {:style {:margin-left 8}}
[name-view display-name contact timestamp] [name-view display-name contact timestamp]
(if (string/blank? (get-in last-message [:content :parsed-text])) (if (string/blank? (get-in last-message [:content :parsed-text]))

View File

@ -1,6 +1,7 @@
(ns status-im2.subs.general (ns status-im2.subs.general
(:require [re-frame.core :as re-frame] (:require [re-frame.core :as re-frame]
[status-im.utils.build :as build] [status-im.utils.build :as build]
[status-im.constants :as constants]
[status-im.multiaccounts.model :as multiaccounts.model] [status-im.multiaccounts.model :as multiaccounts.model]
[status-im.ethereum.core :as ethereum] [status-im.ethereum.core :as ethereum]
[status-im.ethereum.tokens :as tokens] [status-im.ethereum.tokens :as tokens]
@ -8,9 +9,22 @@
(re-frame/reg-sub (re-frame/reg-sub
:visibility-status-updates/visibility-status-update :visibility-status-updates/visibility-status-update
:<- [:multiaccount/public-key]
:<- [:multiaccount/current-user-visibility-status]
:<- [:visibility-status-updates] :<- [:visibility-status-updates]
(fn [visibility-status-updates [_ public-key]] (fn [[my-public-key my-status-update status-updates] [_ public-key]]
(get visibility-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 (re-frame/reg-sub
:multiaccount/logged-in? :multiaccount/logged-in?