mirror of
https://github.com/status-im/status-react.git
synced 2025-02-05 07:35:00 +00:00
Sort pinned messages by date
Signed-off-by: Brian Sztamfater <brian@status.im>
This commit is contained in:
parent
2a6cb978ba
commit
0acca32e78
@ -992,6 +992,15 @@
|
||||
(fn [pin-messages [_ chat-id]]
|
||||
(get pin-messages chat-id {})))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:chats/pinned-sorted-list
|
||||
:<- [::pin-messages]
|
||||
(fn [pin-messages [_ chat-id]]
|
||||
(->>
|
||||
(get pin-messages chat-id {})
|
||||
vals
|
||||
(sort-by :pinned-at <))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:chats/message-reactions
|
||||
:<- [:multiaccount/public-key]
|
||||
|
@ -44,10 +44,10 @@
|
||||
(def list-key-fn #(or (:message-id %) (:value %)))
|
||||
|
||||
(defn pinned-messages-limit-list [chat-id]
|
||||
(let [pinned-messages @(re-frame/subscribe [:chats/pinned chat-id])]
|
||||
(let [pinned-messages @(re-frame/subscribe [:chats/pinned-sorted-list chat-id])]
|
||||
[list/flat-list
|
||||
{:key-fn list-key-fn
|
||||
:data (reverse (vals pinned-messages))
|
||||
:data (reverse pinned-messages)
|
||||
:render-data {:chat-id chat-id}
|
||||
:render-fn render-pin-fn
|
||||
:on-scroll-to-index-failed identity
|
||||
|
@ -11,7 +11,9 @@
|
||||
[quo.react :as quo.react]
|
||||
[status-im.ui.components.topbar :as topbar]
|
||||
[status-im.ui.screens.chat.views :as chat]
|
||||
[status-im.ui.components.list.views :as list]))
|
||||
[status-im.ui.components.list.views :as list]
|
||||
[status-im.ui.screens.chat.message.message :as message]
|
||||
[status-im.utils.datetime :as time]))
|
||||
|
||||
(defn pins-topbar [chat]
|
||||
(let [{:keys [group-chat chat-id chat-name]} chat
|
||||
@ -51,16 +53,37 @@
|
||||
|
||||
(def list-ref #(reset! messages-list-ref %))
|
||||
|
||||
(def list-key-fn #(or (:message-id %) (:value %)))
|
||||
|
||||
(defn render-fn [{:keys [outgoing whisper-timestamp] :as message}
|
||||
_
|
||||
_
|
||||
{:keys [group-chat public? current-public-key space-keeper show-input? message-pin-enabled edit-enabled in-pinned-view?]}]
|
||||
[react/view {:style (when (and platform/android? (not in-pinned-view?)) {:scaleY -1})}
|
||||
[message/chat-message
|
||||
(assoc message
|
||||
:incoming-group (and group-chat (not outgoing))
|
||||
:group-chat group-chat
|
||||
:public? public?
|
||||
:current-public-key current-public-key
|
||||
:show-input? show-input?
|
||||
:message-pin-enabled message-pin-enabled
|
||||
:edit-enabled edit-enabled
|
||||
:display-username? (not outgoing)
|
||||
:pinned true
|
||||
:timestamp-str (time/timestamp->time whisper-timestamp))
|
||||
space-keeper]])
|
||||
|
||||
(defn pinned-messages-view [{:keys [chat pan-responder space-keeper]}]
|
||||
(let [{:keys [group-chat chat-id public? community-id admins]} chat
|
||||
pinned-messages @(re-frame/subscribe [:chats/raw-chat-pin-messages-stream chat-id])]
|
||||
pinned-messages @(re-frame/subscribe [:chats/pinned-sorted-list chat-id])]
|
||||
(if (= (count pinned-messages) 0)
|
||||
[pinned-messages-empty]
|
||||
;;do not use anonymous functions for handlers
|
||||
[list/flat-list
|
||||
(merge
|
||||
pan-responder
|
||||
{:key-fn chat/list-key-fn
|
||||
{:key-fn list-key-fn
|
||||
:ref list-ref
|
||||
:data (reverse pinned-messages)
|
||||
:render-data (chat/get-render-data {:group-chat group-chat
|
||||
@ -72,7 +95,7 @@
|
||||
:show-input? false
|
||||
:edit-enabled false
|
||||
:in-pinned-view? true})
|
||||
:render-fn chat/render-fn
|
||||
:render-fn render-fn
|
||||
:content-container-style {:padding-top 16
|
||||
:padding-bottom 16}})])))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user