feat: system messge icon based on contact customization color (#19558)

Signed-off-by: yqrashawn <namy.19@gmail.com>
This commit is contained in:
yqrashawn 2024-04-12 20:46:09 +08:00 committed by GitHub
parent f8cc85f5e2
commit 00b0755a73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 35 additions and 12 deletions

View File

@ -41,8 +41,13 @@
(defn f-send-button
[props state animations window-height images? btn-opacity z-index edit]
(let [{:keys [text-value]} state
customization-color (rf/sub [:profile/customization-color])]
(let [{:keys [text-value]} state
profile-customization-color (rf/sub [:profile/customization-color])
{:keys [chat-id chat-type]
chat-color :color} (rf/sub [:chats/current-chat-chat-view])
contact-customization-color (when (= chat-type constants/one-to-one-chat-type)
(rf/sub [:contacts/contact-customization-color-by-address
chat-id]))]
(rn/use-effect (fn []
;; Handle send button opacity animation and z-index when input content changes
(if (or (seq @text-value) images?)
@ -60,7 +65,7 @@
[quo/button
{:icon-only? true
:size 32
:customization-color customization-color
:customization-color (or contact-customization-color chat-color profile-customization-color)
:accessibility-label :send-message-button
:on-press #(send-message props state animations window-height edit)}
:i/arrow-up]]))

View File

@ -29,11 +29,15 @@
(defn pinned-message
[{:keys [from quoted-message timestamp-str]}]
(let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity from])
customization-color (rf/sub [:profile/customization-color])]
(let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity from])
one-to-one-chat? (rf/sub [:current-chat/one-to-one-chat?])
current-chat-color (rf/sub [:chats/current-chat-color])
contact-customization-color (rf/sub [:contacts/contact-customization-color-by-address from])]
[quo/system-message
{:type :pinned
:pinned-by primary-name
:customization-color customization-color
:customization-color (if one-to-one-chat?
contact-customization-color
current-chat-color)
:child [reply/quoted-message quoted-message false true]
:timestamp timestamp-str}]))

View File

@ -79,16 +79,17 @@
(defn system-message-contact-request
[{:keys [chat-id timestamp-str from]} type]
(let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity chat-id])
contact (rf/sub [:contacts/contact-by-address chat-id])
photo-path (when (seq (:images contact)) (rf/sub [:chats/photo-path chat-id]))
customization-color (rf/sub [:profile/customization-color])
public-key (rf/sub [:profile/public-key])]
(let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity chat-id])
{:keys [images]
contact-customization-color
:customization-color} (rf/sub [:contacts/contact-by-address chat-id])
photo-path (when (seq images) (rf/sub [:chats/photo-path chat-id]))
public-key (rf/sub [:profile/public-key])]
[quo/system-message
{:type type
:timestamp timestamp-str
:display-name primary-name
:customization-color customization-color
:customization-color contact-customization-color
:photo-path photo-path
:incoming? (not= public-key from)}]))

View File

@ -187,6 +187,12 @@
:description
:last-message])))
(re-frame/reg-sub
:chats/current-chat-color
:<- [:chats/current-raw-chat]
(fn [current-chat]
(:color current-chat)))
(re-frame/reg-sub
:chats/community-channel-ui-details-by-id
:<- [:chats/chats]

View File

@ -253,6 +253,13 @@
multiaccount
(contact.db/find-contact-by-address contacts address))))
(re-frame/reg-sub
:contacts/contact-customization-color-by-address
(fn [[_ address]]
[(re-frame/subscribe [:contacts/contact-by-address address])])
(fn [[contact]]
(:customization-color contact)))
(re-frame/reg-sub
:contacts/filtered-active-sections
:<- [:contacts/active-sections]