dont send seen for public messages and remove checkmark
This commit is contained in:
parent
504b0be251
commit
733f2b193f
|
@ -212,7 +212,8 @@
|
||||||
unseen-messages-ids)})
|
unseen-messages-ids)})
|
||||||
|
|
||||||
(defn- send-messages-seen [chat-id message-ids {:keys [db] :as cofx}]
|
(defn- send-messages-seen [chat-id message-ids {:keys [db] :as cofx}]
|
||||||
(when (and (seq message-ids)
|
(when (and (not (get-in db [:chats chat-id :public?]))
|
||||||
|
(seq message-ids)
|
||||||
(not (models/bot-only-chat? db chat-id)))
|
(not (models/bot-only-chat? db chat-id)))
|
||||||
(transport.message/send (protocol/map->MessagesSeen {:message-ids message-ids}) chat-id cofx)))
|
(transport.message/send (protocol/map->MessagesSeen {:message-ids message-ids}) chat-id cofx)))
|
||||||
|
|
||||||
|
@ -237,13 +238,13 @@
|
||||||
(when (or (seq unseen-messages-ids)
|
(when (or (seq unseen-messages-ids)
|
||||||
(seq unseen-system-messages-ids))
|
(seq unseen-system-messages-ids))
|
||||||
(handlers-macro/merge-fx cofx
|
(handlers-macro/merge-fx cofx
|
||||||
{:db (-> (reduce (fn [new-db message-id]
|
{:db (-> (reduce (fn [new-db message-id]
|
||||||
(assoc-in new-db (into messages-path [message-id :user-statuses me]) :seen))
|
(assoc-in new-db (into messages-path [message-id :user-statuses me]) :seen))
|
||||||
db
|
db
|
||||||
(into unseen-messages-ids unseen-system-messages-ids))
|
(into unseen-messages-ids unseen-system-messages-ids))
|
||||||
(update-in [:chats chat-id :unviewed-messages] set/difference unseen-messages-ids unseen-system-messages-ids))}
|
(update-in [:chats chat-id :unviewed-messages] set/difference unseen-messages-ids unseen-system-messages-ids))}
|
||||||
(persist-seen-messages chat-id (into unseen-messages-ids unseen-system-messages-ids))
|
(persist-seen-messages chat-id (into unseen-messages-ids unseen-system-messages-ids))
|
||||||
(send-messages-seen chat-id unseen-messages-ids)))))
|
(send-messages-seen chat-id unseen-messages-ids)))))
|
||||||
|
|
||||||
(defn- fire-off-chat-loaded-event
|
(defn- fire-off-chat-loaded-event
|
||||||
[chat-id {:keys [db]}]
|
[chat-id {:keys [db]}]
|
||||||
|
|
|
@ -65,7 +65,8 @@
|
||||||
:contacts/keys [contacts]} db
|
:contacts/keys [contacts]} db
|
||||||
{:keys [public-key] :as current-account} (:account/account db)
|
{:keys [public-key] :as current-account} (:account/account db)
|
||||||
current-chat? (and (= :chat view-id) (= current-chat-id chat-id))
|
current-chat? (and (= :chat view-id) (= current-chat-id chat-id))
|
||||||
{:keys [last-clock-value] :as chat} (get-in db [:chats chat-id])
|
{:keys [last-clock-value
|
||||||
|
public?] :as chat} (get-in db [:chats chat-id])
|
||||||
request-command (:request-command content)
|
request-command (:request-command content)
|
||||||
command-request? (and (= content-type constants/content-type-command-request)
|
command-request? (and (= content-type constants/content-type-command-request)
|
||||||
request-command)
|
request-command)
|
||||||
|
@ -86,6 +87,7 @@
|
||||||
current-account chat contacts request-command)))
|
current-account chat contacts request-command)))
|
||||||
current-chat?)
|
current-chat?)
|
||||||
(send-message-seen chat-id message-id (and public-key
|
(send-message-seen chat-id message-id (and public-key
|
||||||
|
(not public?)
|
||||||
current-chat?
|
current-chat?
|
||||||
(not (chat-model/bot-only-chat? db chat-id))
|
(not (chat-model/bot-only-chat? db chat-id))
|
||||||
(not (= constants/system from)))))))
|
(not (= constants/system from)))))))
|
||||||
|
|
|
@ -44,17 +44,6 @@
|
||||||
:accessibility-label :chat-message-text}
|
:accessibility-label :chat-message-text}
|
||||||
content])])
|
content])])
|
||||||
|
|
||||||
(defview message-status [{:keys [chat-id contacts]}
|
|
||||||
{:keys [message-id user-statuses outgoing] :as msg}]
|
|
||||||
(letsubs [current-public-key [:get-current-public-key]]
|
|
||||||
(let [delivery-statuses (dissoc user-statuses current-public-key)
|
|
||||||
seen-by-everyone (and (= (count delivery-statuses) (count contacts)
|
|
||||||
(every? (comp (partial = :seen) second)
|
|
||||||
delivery-statuses)))]
|
|
||||||
(when (and outgoing (or (= chat-id const/console-chat-id)
|
|
||||||
seen-by-everyone))
|
|
||||||
[vector-icons/icon :icons/ok {:style styles/status-image}]))))
|
|
||||||
|
|
||||||
(defn message-timestamp [{:keys [timestamp]}]
|
(defn message-timestamp [{:keys [timestamp]}]
|
||||||
(when timestamp
|
(when timestamp
|
||||||
[react/text {:style styles/datetime-text
|
[react/text {:style styles/datetime-text
|
||||||
|
@ -90,8 +79,8 @@
|
||||||
chat-name)]]]))
|
chat-name)]]]))
|
||||||
|
|
||||||
(defview home-list-chat-item-inner-view [{:keys [chat-id name color online
|
(defview home-list-chat-item-inner-view [{:keys [chat-id name color online
|
||||||
group-chat contacts public?
|
group-chat public?
|
||||||
public-key unremovable? :as chat]}]
|
public-key]}]
|
||||||
(letsubs [last-message [:get-last-message chat-id]]
|
(letsubs [last-message [:get-last-message chat-id]]
|
||||||
(let [name (or (i18n/get-contact-translated chat-id :name name)
|
(let [name (or (i18n/get-contact-translated chat-id :name name)
|
||||||
(gfycat/generate-gfy public-key))
|
(gfycat/generate-gfy public-key))
|
||||||
|
@ -105,7 +94,6 @@
|
||||||
[chat-list-item-name name group-chat public? public-key]
|
[chat-list-item-name name group-chat public? public-key]
|
||||||
(when last-message
|
(when last-message
|
||||||
[react/view styles/message-status-container
|
[react/view styles/message-status-container
|
||||||
[message-status chat last-message]
|
|
||||||
[message-timestamp last-message]])]
|
[message-timestamp last-message]])]
|
||||||
[react/view styles/item-lower-container
|
[react/view styles/item-lower-container
|
||||||
[message-content-text last-message]
|
[message-content-text last-message]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
(ns status-im.test.chat.models.message
|
(ns status-im.test.chat.models.message
|
||||||
(:require [cljs.test :refer-macros [deftest is testing]]
|
(:require [cljs.test :refer-macros [deftest is testing]]
|
||||||
|
[status-im.transport.message.v1.protocol :as protocol]
|
||||||
[status-im.chat.models.message :as message]))
|
[status-im.chat.models.message :as message]))
|
||||||
|
|
||||||
(deftest add-to-chat?
|
(deftest add-to-chat?
|
||||||
|
@ -24,3 +25,37 @@
|
||||||
{:message-id "message-id"
|
{:message-id "message-id"
|
||||||
:from "a"
|
:from "a"
|
||||||
:chat-id "a"})))))
|
:chat-id "a"})))))
|
||||||
|
|
||||||
|
(deftest receive-send-seen
|
||||||
|
(let [db {:db {:chats {"chat-id" {}}
|
||||||
|
:account/account {:public-key "a"}
|
||||||
|
:current-chat-id "chat-id"
|
||||||
|
:view-id :chat}}
|
||||||
|
message {:chat-id "chat-id"
|
||||||
|
:from "a"
|
||||||
|
:message-id "1"}
|
||||||
|
extract-seen (comp :payload :message :shh/post)]
|
||||||
|
(testing "it send a seen message when the chat is 1-to-1 and is open"
|
||||||
|
(is (instance? protocol/MessagesSeen
|
||||||
|
(extract-seen (message/receive message db))))
|
||||||
|
(is (= #{"1"} (:message-ids (extract-seen (message/receive message db))))))
|
||||||
|
(testing "it does not send any when the chat is public"
|
||||||
|
(is (nil? (extract-seen
|
||||||
|
(message/receive
|
||||||
|
message
|
||||||
|
(assoc-in db [:db :chats "chat-id" :public?] true))))))
|
||||||
|
(testing "it does not send any when we are in a different chat"
|
||||||
|
(is (nil? (extract-seen
|
||||||
|
(message/receive
|
||||||
|
message
|
||||||
|
(assoc-in db [:db :current-chat-id] :different))))))
|
||||||
|
(testing "it does not send any when we are not in a chat view"
|
||||||
|
(is (nil? (extract-seen
|
||||||
|
(message/receive
|
||||||
|
message
|
||||||
|
(assoc-in db [:db :view-id] :home))))))
|
||||||
|
(testing "it does not send any when no public key is in account"
|
||||||
|
(is (nil? (extract-seen
|
||||||
|
(message/receive
|
||||||
|
message
|
||||||
|
(assoc-in db [:db :account/account :public-key] nil))))))))
|
||||||
|
|
Loading…
Reference in New Issue