summaryrefslogtreecommitdiff
path: root/src/Erebos
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2025-08-03 17:00:53 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2025-08-03 18:49:13 +0200
commit7deb4043e385f7e16b59c7c22711b9941bb73005 (patch)
treefddf19797f775adf57db1bc53f1826ee496a7040 /src/Erebos
parent14c7041ba4c1ba30767a47da62ecf2fdddfe0b66 (diff)
Print received messages only for selected conversation
Changelog: CLI: Print received messages only for selected conversation
Diffstat (limited to 'src/Erebos')
-rw-r--r--src/Erebos/Chatroom.hs6
-rw-r--r--src/Erebos/Conversation.hs11
2 files changed, 12 insertions, 5 deletions
diff --git a/src/Erebos/Chatroom.hs b/src/Erebos/Chatroom.hs
index 74456ff..579d530 100644
--- a/src/Erebos/Chatroom.hs
+++ b/src/Erebos/Chatroom.hs
@@ -17,6 +17,7 @@ module Erebos.Chatroom (
joinChatroomAs, joinChatroomAsByStateData,
leaveChatroom, leaveChatroomByStateData,
getMessagesSinceState,
+ isSameChatroom,
ChatroomSetChange(..),
watchChatrooms,
@@ -422,6 +423,11 @@ leaveChatroomByStateData lookupData = sendRawChatroomMessageByStateData lookupDa
getMessagesSinceState :: ChatroomState -> ChatroomState -> [ChatMessage]
getMessagesSinceState cur old = threadToListSince (roomStateMessageData old) (roomStateMessageData cur)
+isSameChatroom :: ChatroomState -> ChatroomState -> Bool
+isSameChatroom rstate rstate' =
+ let roots = filterAncestors . concatMap storedRoots . roomStateData
+ in intersectsSorted (roots rstate) (roots rstate')
+
data ChatroomSetChange = AddedChatroom ChatroomState
| RemovedChatroom ChatroomState
diff --git a/src/Erebos/Conversation.hs b/src/Erebos/Conversation.hs
index 445b997..f9724c2 100644
--- a/src/Erebos/Conversation.hs
+++ b/src/Erebos/Conversation.hs
@@ -11,6 +11,7 @@ module Erebos.Conversation (
directMessageConversation,
chatroomConversation,
chatroomConversationByStateData,
+ isChatroomStateConversation,
reloadConversation,
lookupConversations,
@@ -36,8 +37,6 @@ import Erebos.DirectMessage
import Erebos.Identity
import Erebos.State
import Erebos.Storable
-import Erebos.Storage.Merge
-import Erebos.Util
data Message = DirectMessageMessage DirectMessage Bool
@@ -74,9 +73,7 @@ data Conversation
isSameConversation :: Conversation -> Conversation -> Bool
isSameConversation (DirectMessageConversation t) (DirectMessageConversation t')
= sameIdentity (msgPeer t) (msgPeer t')
-isSameConversation (ChatroomConversation c) (ChatroomConversation c')
- = let roots = filterAncestors . concatMap storedRoots . roomStateData
- in intersectsSorted (roots c) (roots c')
+isSameConversation (ChatroomConversation rstate) (ChatroomConversation rstate') = isSameChatroom rstate rstate'
isSameConversation _ _ = False
directMessageConversation :: MonadHead LocalState m => ComposedIdentity -> m Conversation
@@ -91,6 +88,10 @@ chatroomConversation rstate = chatroomConversationByStateData (head $ roomStateD
chatroomConversationByStateData :: MonadHead LocalState m => Stored ChatroomStateData -> m (Maybe Conversation)
chatroomConversationByStateData sdata = fmap ChatroomConversation <$> findChatroomByStateData sdata
+isChatroomStateConversation :: ChatroomState -> Conversation -> Bool
+isChatroomStateConversation rstate (ChatroomConversation rstate') = isSameChatroom rstate rstate'
+isChatroomStateConversation _ _ = False
+
reloadConversation :: MonadHead LocalState m => Conversation -> m Conversation
reloadConversation (DirectMessageConversation thread) = directMessageConversation (msgPeer thread)
reloadConversation cur@(ChatroomConversation rstate) =