[Fixes: #9492] Consider system messages always in their own group

System messages should always display the user picture, and should never
be grouped.

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Andrea Maria Piana 2019-11-20 09:17:09 +01:00
parent 7d1812cc94
commit ddbfc78e08
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
2 changed files with 31 additions and 0 deletions

View File

@ -37,6 +37,8 @@
We check the time, and the author"
[a b]
(and
(not (:system-message? a))
(not (:system-message? b))
(= (:from a) (:from b))
(<= (js/Math.abs (- (:whisper-timestamp a) (:whisper-timestamp b))) group-ms)))

View File

@ -168,3 +168,32 @@
(s/->seq)
(nth 2)
:message-id)))))))
(deftest same-group-test
(testing "two messages from the same author and close together"
(is (s/same-group? {:whisper-timestamp 1
:from "1"}
{:whisper-timestamp 2
:from "1"})))
(testing "two messages from the same author, close together, first system-message"
(is (not (s/same-group? {:whisper-timestamp 1
:system-message? true
:from "1"}
{:whisper-timestamp 2
:from "1"}))))
(testing "two messages from the same author, close together, second system-message"
(is (not (s/same-group? {:whisper-timestamp 1
:from "1"}
{:whisper-timestamp 2
:system-message? true
:from "1"}))))
(testing "two messages from the same author and far apart"
(is (not (s/same-group? {:whisper-timestamp 1
:from "1"}
{:whisper-timestamp 2000000
:from "1"}))))
(testing "two messages not from the same author and close together"
(is (not (s/same-group? {:whisper-timestamp 1
:from "2"}
{:whisper-timestamp 2
:from "1"})))))