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