Use last-message-timestamp in mainchat

We use the timestamp of the last message in the chat preview.
In case there's no message, the old timestamp will be displayed (last
time the chat has been updated).

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Andrea Maria Piana 2019-08-30 15:55:56 +02:00
parent aa4bf1f26b
commit 12c08b1398
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
7 changed files with 14 additions and 5 deletions

View File

@ -146,6 +146,7 @@
:message-groups {} :message-groups {}
:last-message-content nil :last-message-content nil
:last-message-content-type nil :last-message-content-type nil
:last-message-timestamp nil
:unviewed-messages-count 0 :unviewed-messages-count 0
:deleted-at-clock-value last-message-clock-value})} :deleted-at-clock-value last-message-clock-value})}
(messages-store/delete-messages-by-chat-id chat-id) (messages-store/delete-messages-by-chat-id chat-id)

View File

@ -224,7 +224,7 @@
(defn- update-last-message [all-chats chat-id] (defn- update-last-message [all-chats chat-id]
(let [{:keys [messages message-groups]} (let [{:keys [messages message-groups]}
(get all-chats chat-id) (get all-chats chat-id)
{:keys [content content-type clock-value]} {:keys [content content-type clock-value timestamp]}
(->> (chat.db/sort-message-groups message-groups messages) (->> (chat.db/sort-message-groups message-groups messages)
last last
second second
@ -234,6 +234,7 @@
(chat-model/upsert-chat (chat-model/upsert-chat
{:chat-id chat-id {:chat-id chat-id
:last-message-content content :last-message-content content
:last-message-timestamp timestamp
:last-message-content-type content-type}))) :last-message-content-type content-type})))
(fx/defn update-last-messages (fx/defn update-last-messages
@ -348,6 +349,7 @@
(chat-model/upsert-chat (chat-model/upsert-chat
{:chat-id chat-id {:chat-id chat-id
:timestamp now :timestamp now
:last-message-timestamp (:timestamp message)
:last-message-content (:content message) :last-message-content (:content message)
:last-message-content-type (:content-type message) :last-message-content-type (:content-type message)
:last-clock-value (:clock-value message)}) :last-clock-value (:clock-value message)})

View File

@ -22,6 +22,7 @@
{:keys [chat-id {:keys [chat-id
unviewed-messages-count unviewed-messages-count
last-message-content last-message-content
last-message-timestamp
last-message-content-type]}] last-message-content-type]}]
(let [removed-messages-ids (keep (let [removed-messages-ids (keep
(fn [[message-id {:keys [from]}]] (fn [[message-id {:keys [from]}]]
@ -39,6 +40,7 @@
assoc assoc
:unviewed-messages-count unviewed-messages-count :unviewed-messages-count unviewed-messages-count
:last-message-content last-message-content :last-message-content last-message-content
:last-message-timestamp last-message-timestamp
:last-message-content-type last-message-content-type))] :last-message-content-type last-message-content-type))]
(fx/merge cofx (fx/merge cofx
{:db db} {:db db}

View File

@ -117,6 +117,7 @@
:unviewed-messages-count :unviewedMessagesCount :unviewed-messages-count :unviewedMessagesCount
:last-message-content :lastMessageContent :last-message-content :lastMessageContent
:last-message-content-type :lastMessageContentType :last-message-content-type :lastMessageContentType
:last-message-timestamp :lastMessageTimestamp
:deleted-at-clock-value :deletedAtClockValue :deleted-at-clock-value :deletedAtClockValue
:is-active :active :is-active :active
:last-clock-value :lastClockValue}) :last-clock-value :lastClockValue})
@ -135,6 +136,7 @@
:unviewedMessagesCount :unviewed-messages-count :unviewedMessagesCount :unviewed-messages-count
:lastMessageContent :last-message-content :lastMessageContent :last-message-content
:lastMessageContentType :last-message-content-type :lastMessageContentType :last-message-content-type
:lastMessageTimestamp :last-message-timestamp
:deletedAtClockValue :deleted-at-clock-value :deletedAtClockValue :deleted-at-clock-value
:active :is-active :active :is-active
:lastClockValue :last-clock-value}) :lastClockValue :last-clock-value})

View File

@ -25,13 +25,14 @@
color public? public-key color public? public-key
timestamp chat-name timestamp chat-name
last-message-content last-message-content
last-message-timestamp
last-message-content-type] last-message-content-type]
:as chat-item}] :as chat-item}]
(views/letsubs [photo-path [:contacts/chat-photo chat-id] (views/letsubs [photo-path [:contacts/chat-photo chat-id]
unviewed-messages-count [:chats/unviewed-messages-count chat-id] unviewed-messages-count [:chats/unviewed-messages-count chat-id]
current-chat-id [:chats/current-chat-id]] current-chat-id [:chats/current-chat-id]]
(let [last-message {:content last-message-content (let [last-message {:content last-message-content
:timestamp timestamp :timestamp (if (pos? last-message-timestamp) last-message-timestamp timestamp)
:content-type last-message-content-type} :content-type last-message-content-type}
name (or chat-name name (or chat-name
(gfycat/generate-gfy public-key)) (gfycat/generate-gfy public-key))

View File

@ -91,6 +91,7 @@
name color online name color online
group-chat public? group-chat public?
public-key contact public-key contact
last-message-timestamp
timestamp timestamp
last-message-content last-message-content
last-message-content-type]} home-item last-message-content-type]} home-item
@ -110,7 +111,7 @@
[react/view styles/item-upper-container [react/view styles/item-upper-container
[chat-list-item-name truncated-chat-name group-chat public? public-key] [chat-list-item-name truncated-chat-name group-chat public? public-key]
[react/view styles/message-status-container [react/view styles/message-status-container
[message-timestamp timestamp]]] [message-timestamp (if (pos? last-message-timestamp) last-message-timestamp timestamp)]]]
[react/view styles/item-lower-container [react/view styles/item-lower-container
(let [{:keys [tribute-status tribute-label]} (:tribute-to-talk contact)] (let [{:keys [tribute-status tribute-label]} (:tribute-to-talk contact)]
(if (not (#{:require :pending} tribute-status)) (if (not (#{:require :pending} tribute-status))

View File

@ -3,6 +3,6 @@
"owner": "status-im", "owner": "status-im",
"repo": "status-go", "repo": "status-go",
"version": "develop", "version": "develop",
"commit-sha1": "b8ea79a3f005116ce1496a75a26e107b9e6c9c10", "commit-sha1": "1a47893e75bccc99af3ce4b2c7fbedf6481dae6a",
"src-sha256": "0xxvh9sxn1rh7ll2lyirqb1zjm2szbi759xnhc3rz7fk1j4srmvz" "src-sha256": "1mcdm48bs9wz2nndicss3kia0rm4zk861a7qv6qaxjw12y6n8man"
} }