mirror of
https://github.com/status-im/status-mobile.git
synced 2025-02-16 02:28:19 +00:00
Fix pinned messages (#14787)
This commit is contained in:
parent
ba89ac3fcf
commit
4020b4fdef
@ -2,10 +2,10 @@
|
||||
(:require [quo2.foundations.colors :as colors]))
|
||||
|
||||
(defn message-container
|
||||
[in-pinned-view? pinned mentioned last-in-group?]
|
||||
(merge (when (and (not in-pinned-view?) (or mentioned pinned))
|
||||
[in-pinned-view? pinned-by mentioned last-in-group?]
|
||||
(merge (when (and (not in-pinned-view?) (or mentioned pinned-by))
|
||||
{:background-color colors/primary-50-opa-5
|
||||
:margin-bottom 4})
|
||||
(when (or mentioned pinned last-in-group?)
|
||||
(when (or mentioned pinned-by last-in-group?)
|
||||
{:margin-top 8})
|
||||
{:border-radius 16}))
|
||||
|
@ -156,14 +156,14 @@
|
||||
[status/status outgoing-status])]]]])))])
|
||||
|
||||
(defn message-with-reactions
|
||||
[{:keys [pinned pinned-by mentioned in-pinned-view? content-type
|
||||
[{:keys [pinned-by mentioned in-pinned-view? content-type
|
||||
last-in-group? message-id messages-ids]
|
||||
:as message-data}
|
||||
{:keys [chat-id] :as context}]
|
||||
[rn/view
|
||||
{:style (style/message-container in-pinned-view? pinned mentioned last-in-group?)
|
||||
{:style (style/message-container in-pinned-view? pinned-by mentioned last-in-group?)
|
||||
:accessibility-label :chat-item}
|
||||
(when pinned
|
||||
(when pinned-by
|
||||
[pin/pinned-by-view pinned-by])
|
||||
(if (#{constants/content-type-system-text constants/content-type-community
|
||||
constants/content-type-contact-request}
|
||||
|
@ -10,16 +10,18 @@
|
||||
[status-im2.common.not-implemented :as not-implemented]))
|
||||
|
||||
(defn pin-message
|
||||
[{:keys [chat-id pinned] :as message-data}]
|
||||
(let [pinned-messages (rf/sub [:chats/pinned chat-id])]
|
||||
(if (and (not pinned) (> (count pinned-messages) 2))
|
||||
[{:keys [chat-id pinned pinned-by] :as message-data}]
|
||||
(let [pinned-messages (rf/sub [:chats/pinned chat-id])
|
||||
message-not-pinned? (and (empty? pinned-by) (not pinned))]
|
||||
(if (and message-not-pinned? (> (count pinned-messages) 2))
|
||||
(do
|
||||
(js/setTimeout (fn [] (rf/dispatch [:dismiss-keyboard])) 500)
|
||||
(rf/dispatch [:pin-message/show-pin-limit-modal chat-id]))
|
||||
(rf/dispatch [:pin-message/send-pin-message (assoc message-data :pinned (not pinned))]))))
|
||||
(rf/dispatch [:pin-message/send-pin-message
|
||||
(assoc message-data :pinned message-not-pinned?)]))))
|
||||
|
||||
(defn get-actions
|
||||
[{:keys [outgoing content pinned outgoing-status] :as message-data}
|
||||
[{:keys [outgoing content pinned-by outgoing-status] :as message-data}
|
||||
{:keys [edit-enabled show-input? can-delete-message-for-everyone? community? message-pin-enabled]}]
|
||||
(concat
|
||||
(when (and outgoing edit-enabled)
|
||||
@ -44,12 +46,12 @@
|
||||
(when message-pin-enabled
|
||||
[{:type :main
|
||||
:on-press #(pin-message message-data)
|
||||
:label (i18n/label (if pinned
|
||||
:label (i18n/label (if pinned-by
|
||||
(if community? :t/unpin-from-channel :t/unpin-from-chat)
|
||||
(if community? :t/pin-to-channel :t/pin-to-chat)))
|
||||
:icon :i/pin
|
||||
:id (if pinned :unpin :pin)}])
|
||||
(when-not pinned
|
||||
:id (if pinned-by :unpin :pin)}])
|
||||
(when-not pinned-by
|
||||
[{:type :danger
|
||||
:on-press (fn []
|
||||
(rf/dispatch
|
||||
|
Loading…
x
Reference in New Issue
Block a user