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-legacy.core
status-im.network.net-info
status-im.visibility-status-popover.core
[status-im.multiaccounts.model :as multiaccounts.model]))
(re-frame/reg-fx

View File

@ -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

View File

@ -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)}

View File

@ -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]))

View File

@ -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?