Skip to content

Commit 642d8a4

Browse files
authored
[CLNP-7306]Fixed a bug that caused a runtime exception when leaving or deleting a channel (#1355)
[fix]: Fixed a bug that caused a runtime exception when leaving or deleting a channel Fixes [CLNP-7306](https://sendbird.atlassian.net/browse/CLNP-7306) ### Changelogs - Fixed a bug that caused a runtime exception when leaving or deleting a channel ### Checklist Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If unsure, ask the members. This is a reminder of what we look for before merging your code. - [x] **All tests pass locally with my changes** - [ ] **I have added tests that prove my fix is effective or that my feature works** - [ ] **Public components / utils / props are appropriately exported** - [ ] I have added necessary documentation (if appropriate) ## External Contributions This project is not yet set up to accept pull requests from external contributors. If you have a pull request that you believe should be accepted, please contact the Developer Relations team <[email protected]> with details and we'll evaluate if we can set up a [CLA](https://en.wikipedia.org/wiki/Contributor_License_Agreement) to allow for the contribution. [CLNP-7306]: https://sendbird.atlassian.net/browse/CLNP-7306?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent 3187ced commit 642d8a4

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/modules/ChannelSettings/context/hooks/useChannelHandler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ export const useChannelHandler = ({
3131
onUserLeft: (channel, user) => {
3232
if (compareIds(channel?.url, channelUrl)) {
3333
logger.info('ChannelSettings: onUserLeft', { channel, user });
34-
forceUpdateUI();
34+
if (user.userId !== sdk.currentUser?.userId) {
35+
forceUpdateUI();
36+
}
3537
}
3638
},
3739
onUserBanned: (channel, user) => {
3840
if (compareIds(channel?.url, channelUrl) && channel.isGroupChannel()) {
3941
logger.info('ChannelSettings: onUserBanned', { channel, user });
40-
forceUpdateUI();
42+
if (user.userId !== sdk.currentUser?.userId) {
43+
forceUpdateUI();
44+
}
4145
}
4246
},
4347
});

src/modules/ChannelSettings/context/hooks/useSetChannel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function useSetChannel({
4242
}
4343

4444
setLoading(true);
45+
4546
const groupChannel = await sdk.groupChannel.getChannel(channelUrl);
4647
if (!signal.aborted) {
4748
logger.info('ChannelSettings | useSetChannel: fetched group channel', groupChannel);

src/modules/GroupChannel/context/hooks/useGroupChannel.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const useGroupChannel = () => {
7777

7878
if (state.currentChannel && !state.hasNext()) {
7979
state.resetNewMessages();
80-
if (!state.disableMarkAsRead) {
80+
if (!state.disableMarkAsRead && state.currentChannel.myMemberState !== 'none') {
8181
markAsReadScheduler.push(state.currentChannel);
8282
}
8383
}
@@ -157,16 +157,16 @@ export const useGroupChannel = () => {
157157
scrollToBottom,
158158
});
159159

160-
const setCurrentChannel = useCallback((channel: GroupChannel) => {
160+
const setCurrentChannel = useCallback((channel: GroupChannel | null) => {
161161
store.setState(state => ({
162162
...state,
163163
currentChannel: channel,
164164
fetchChannelError: null,
165165
quoteMessage: null,
166166
animatedMessageId: null,
167-
nicknamesMap: new Map(
167+
nicknamesMap: channel ? new Map(
168168
channel.members.map(({ userId, nickname }) => [userId, nickname]),
169-
),
169+
) : new Map(),
170170
}), true);
171171
}, []);
172172

0 commit comments

Comments
 (0)