Skip to content

Commit d685271

Browse files
authored
Merge pull request #267 from sendbird/fix/real-time-read-receipts
[CLNP-7628] fix: read receipts not updating in real-time
2 parents 231250c + ad8eae1 commit d685271

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

packages/uikit-chat-hooks/src/__tests__/common/useMessageOutgoingStatus.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,20 @@ describe('useMessageOutgoingStatus', () => {
183183
});
184184

185185
act(() => {
186-
sdk.__emit('channel', 'group_onUnreadMemberStatusUpdated', channel);
186+
sdk.__emit('channel', 'group_onUserMarkedRead', channel);
187187
});
188188

189189
await waitFor(() => {
190190
expect(forceUpdate).toHaveBeenCalledTimes(2);
191191
});
192+
193+
act(() => {
194+
sdk.__emit('channel', 'group_onUserMarkedUnread', channel);
195+
});
196+
197+
await waitFor(() => {
198+
expect(forceUpdate).toHaveBeenCalledTimes(3);
199+
});
192200
});
193201

194202
it('should not trigger forceUpdate if event not emitted', async () => {
@@ -220,7 +228,8 @@ describe('useMessageOutgoingStatus', () => {
220228

221229
act(() => {
222230
sdk.__emit('channel', 'group_onUndeliveredMemberStatusUpdated', channel);
223-
sdk.__emit('channel', 'group_onUnreadMemberStatusUpdated', channel);
231+
sdk.__emit('channel', 'group_onUserMarkedRead', channel);
232+
sdk.__emit('channel', 'group_onUserMarkedUnread', channel);
224233
});
225234

226235
await waitFor(() => {

packages/uikit-chat-hooks/src/common/useMessageOutgoingStatus.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ export const useMessageOutgoingStatus = (
2323

2424
forceUpdate();
2525
},
26-
onUnreadMemberStatusUpdated(eventChannel) {
26+
onUserMarkedRead(eventChannel) {
27+
if (isDifferentChannel(channel, eventChannel)) return;
28+
if (!isMyMessage(message, currentUser?.userId)) return;
29+
30+
forceUpdate();
31+
},
32+
onUserMarkedUnread(eventChannel) {
2733
if (isDifferentChannel(channel, eventChannel)) return;
2834
if (!isMyMessage(message, currentUser?.userId)) return;
2935

packages/uikit-react-native/src/domain/groupChannel/component/GroupChannelMessageList.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,6 @@ const GroupChannelMessageList = (props: GroupChannelProps['MessageList']) => {
256256
lazyScrollToBottom({ animated: true, timeout: 250 });
257257
}
258258
},
259-
onChannelChanged(channel) {
260-
if (isDifferentChannel(channel, props.channel)) return;
261-
},
262259
});
263260

264261
useEffect(() => {

0 commit comments

Comments
 (0)