Skip to content

Commit c108dd9

Browse files
sravan-sSravan S
andauthored
Fix: Suppress NO ACK error(#119)
Call markAsRead inside try/catch block This error occurs in codesandbox Especially when multiple users are running same sandbox Error is command no ACK error that comes from markAsRead called in quick succession This is a stop gap solution Need to find proper fix. Fixes: sendbird.atlassian.net/browse/UIKIT-1619 Co-authored-by: Sravan S <sravan@sendbird.com>
1 parent 6d29122 commit c108dd9

File tree

7 files changed

+40
-8
lines changed

7 files changed

+40
-8
lines changed

src/smart-components/Conversation/hooks/useGetChannel.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ function useSetChannel({ channelUrl, sdkInit }, {
2020

2121
logger.info('Channel: Mark as read', groupChannel);
2222
// this order is important - this mark as read should update the event handler up above
23-
groupChannel.markAsRead();
23+
try {
24+
groupChannel.markAsRead();
25+
} catch {
26+
//
27+
}
2428
})
2529
.catch((e) => {
2630
logger.warning('Channel | useSetChannel fetch channel failed', { channelUrl, e });

src/smart-components/Conversation/hooks/useHandleChannelEvents.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ function useHandleChannelEvents({ currentGroupChannel, sdkInit, hasMoreToBottom
4747
if (scrollToEnd) {
4848
try {
4949
setTimeout(() => {
50-
currentGroupChannel.markAsRead();
50+
try {
51+
currentGroupChannel.markAsRead();
52+
} catch {
53+
//
54+
}
5155
scrollIntoLast();
5256
});
5357
} catch (error) {

src/smart-components/Conversation/hooks/useHandleReconnect.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ function useHandleReconnect(
9090
logger.error('Channel: Fetching messages failed', error);
9191
})
9292
.finally(() => {
93-
currentGroupChannel.markAsRead?.();
93+
try {
94+
currentGroupChannel.markAsRead?.();
95+
} catch {
96+
//
97+
}
9498
});
9599
});
96100
}

src/smart-components/Conversation/hooks/useInitialMessagesFetch.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ function useInitialMessagesFetch({
119119
if (!intialTimeStamp) {
120120
setTimeout(() => utils.scrollIntoLast());
121121
}
122-
currentGroupChannel.markAsRead();
122+
try {
123+
currentGroupChannel.markAsRead();
124+
} catch {
125+
//
126+
}
123127
});
124128
} else {
125129
currentGroupChannel.getMessagesByTimestamp(
@@ -160,7 +164,11 @@ function useInitialMessagesFetch({
160164
if (!intialTimeStamp) {
161165
setTimeout(() => utils.scrollIntoLast());
162166
}
163-
currentGroupChannel.markAsRead();
167+
try {
168+
currentGroupChannel.markAsRead();
169+
} catch {
170+
//
171+
}
164172
});
165173
}
166174
}

src/smart-components/Conversation/hooks/useScrollCallback.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ function useScrollCallback({
7070
cb([null, error]);
7171
})
7272
.finally(() => {
73-
currentGroupChannel.markAsRead();
73+
try {
74+
currentGroupChannel.markAsRead();
75+
} catch {
76+
//
77+
}
7478
});
7579
}, [currentGroupChannel, lastMessageTimeStamp, replyType]);
7680
}

src/smart-components/Conversation/hooks/useScrollDownCallback.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ function useScrollDownCallback({
7373
cb([null, error]);
7474
})
7575
.finally(() => {
76-
currentGroupChannel.markAsRead();
76+
try {
77+
currentGroupChannel.markAsRead();
78+
} catch {
79+
//
80+
}
7781
});
7882
}, [currentGroupChannel, latestFetchedMessageTimeStamp, hasMoreToBottom, replyType]);
7983
}

src/smart-components/Conversation/index.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,11 @@ export const ConversationPanel = (props) => {
337337
utils.scrollIntoLast();
338338
// there is no scroll
339339
if (scrollRef.current.scrollTop === 0) {
340-
currentGroupChannel.markAsRead();
340+
try {
341+
currentGroupChannel.markAsRead();
342+
} catch {
343+
//
344+
}
341345
messagesDispatcher({
342346
type: messageActionTypes.MARK_AS_READ,
343347
});

0 commit comments

Comments
 (0)