Skip to content

Commit c99b563

Browse files
committed
Rely less on model.chatting
1 parent fdfc2a7 commit c99b563

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/Client/Im/Contacts.purs

+6-9
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ setMessageStatus webSocket userId newStatus model =
7878
model
7979
{ contacts = updatedContacts
8080
} /\
81-
[ setIt
82-
userId
83-
(messageIdsUpdated <<< DM.maybe [] _.history $ SIC.findContact userId model.contacts)
84-
updatedContacts
81+
[ setIt userId (messageIdsUpdated <<< DM.maybe [] _.history $ SIC.findContact userId model.contacts)
8582
]
8683

8784
where
@@ -94,16 +91,16 @@ setMessageStatus webSocket userId newStatus model =
9491
| needsUpdate entry = entry { status = newStatus }
9592
| otherwise = entry
9693

97-
updateContact userId contact
98-
| contact.user.id == userId = contact { history = map updateStatus contact.history }
94+
updateContact ui contact
95+
| contact.user.id == ui = contact { history = map updateStatus contact.history }
9996
| otherwise = contact
10097

101-
setIt userId messages contacts = liftEffect do
98+
setIt ui messages = liftEffect do
10299
CIW.sendPayload webSocket $ ChangeStatus
103100
{ status: newStatus
104-
, ids: [ Tuple userId messages ]
101+
, ids: [ Tuple ui messages ]
105102
}
106-
CIUN.updateTabCount userId contacts
103+
CIUN.updateTabCount model.user.id updatedContacts
107104
pure Nothing
108105

109106
-- | Update message status to unread upon openning the site or receveing from new contacts

test/Client/Im/Chat.purs

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ tests = do
7777
TU.test "sendMessage adds markdown image to history" do
7878
date ← liftEffect $ map DateTimeWrapper EN.nowDateTime
7979
let
80-
{ chatting } = DT.fst <<< CIC.sendMessage 3 true (Image caption image) date webSocket $ model
80+
{ chatting } = DT.fst <<< CIC.sendMessage (SU.fromJust model.chatting) true (Image caption image) date webSocket $ model
8181
{ selectedImage = Just image
8282
, imageCaption = Just caption
8383
}
@@ -88,7 +88,7 @@ tests = do
8888
TU.test "sendMessage resets input fields" do
8989
date ← liftEffect $ map DateTimeWrapper EN.nowDateTime
9090
let
91-
{ selectedImage, imageCaption } = DT.fst <<< CIC.sendMessage 3 true content date webSocket $ model
91+
{ selectedImage, imageCaption } = DT.fst <<< CIC.sendMessage (SU.fromJust model.chatting) true content date webSocket $ model
9292
{ selectedImage = Just image
9393
, imageCaption = Just caption
9494
}

0 commit comments

Comments
 (0)