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

@ -42,7 +42,12 @@
(defn f-send-button (defn f-send-button
[props state animations window-height images? btn-opacity z-index edit] [props state animations window-height images? btn-opacity z-index edit]
(let [{:keys [text-value]} state (let [{:keys [text-value]} state
customization-color (rf/sub [:profile/customization-color])] 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 [] (rn/use-effect (fn []
;; Handle send button opacity animation and z-index when input content changes ;; Handle send button opacity animation and z-index when input content changes
(if (or (seq @text-value) images?) (if (or (seq @text-value) images?)
@ -60,7 +65,7 @@
[quo/button [quo/button
{:icon-only? true {:icon-only? true
:size 32 :size 32
:customization-color customization-color :customization-color (or contact-customization-color chat-color profile-customization-color)
:accessibility-label :send-message-button :accessibility-label :send-message-button
:on-press #(send-message props state animations window-height edit)} :on-press #(send-message props state animations window-height edit)}
:i/arrow-up]])) :i/arrow-up]]))

View File

@ -30,10 +30,14 @@
(defn pinned-message (defn pinned-message
[{:keys [from quoted-message timestamp-str]}] [{:keys [from quoted-message timestamp-str]}]
(let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity from]) (let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity from])
customization-color (rf/sub [:profile/customization-color])] 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 [quo/system-message
{:type :pinned {:type :pinned
:pinned-by primary-name :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] :child [reply/quoted-message quoted-message false true]
:timestamp timestamp-str}])) :timestamp timestamp-str}]))

View File

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

View File

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

View File

@ -253,6 +253,13 @@
multiaccount multiaccount
(contact.db/find-contact-by-address contacts address)))) (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 (re-frame/reg-sub
:contacts/filtered-active-sections :contacts/filtered-active-sections
:<- [:contacts/active-sections] :<- [:contacts/active-sections]