stream-chat-react-native-core 5.5.0-beta.3 → 5.5.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/ChannelList/ChannelList.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useAddedToChannelNotification.js +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useAddedToChannelNotification.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useChannelDeleted.js +1 -0
- package/lib/commonjs/components/ChannelList/hooks/listeners/useChannelDeleted.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useChannelHidden.js +1 -0
- package/lib/commonjs/components/ChannelList/hooks/listeners/useChannelHidden.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useChannelTruncated.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useChannelUpdated.js +1 -0
- package/lib/commonjs/components/ChannelList/hooks/listeners/useChannelUpdated.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useChannelVisible.js +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useChannelVisible.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessage.js +2 -0
- package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessage.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessageNotification.js +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessageNotification.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useRemovedFromChannelNotification.js +1 -0
- package/lib/commonjs/components/ChannelList/hooks/listeners/useRemovedFromChannelNotification.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useUserPresence.js +1 -0
- package/lib/commonjs/components/ChannelList/hooks/listeners/useUserPresence.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/ChannelList/ChannelList.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useAddedToChannelNotification.js +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useAddedToChannelNotification.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useChannelDeleted.js +1 -0
- package/lib/module/components/ChannelList/hooks/listeners/useChannelDeleted.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useChannelHidden.js +1 -0
- package/lib/module/components/ChannelList/hooks/listeners/useChannelHidden.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useChannelTruncated.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useChannelUpdated.js +1 -0
- package/lib/module/components/ChannelList/hooks/listeners/useChannelUpdated.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useChannelVisible.js +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useChannelVisible.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useNewMessage.js +2 -0
- package/lib/module/components/ChannelList/hooks/listeners/useNewMessage.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useNewMessageNotification.js +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useNewMessageNotification.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useRemovedFromChannelNotification.js +1 -0
- package/lib/module/components/ChannelList/hooks/listeners/useRemovedFromChannelNotification.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useUserPresence.js +1 -0
- package/lib/module/components/ChannelList/hooks/listeners/useUserPresence.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/ChannelList/ChannelList.d.ts +8 -8
- package/lib/typescript/components/ChannelList/hooks/listeners/useAddedToChannelNotification.d.ts +2 -2
- package/lib/typescript/components/ChannelList/hooks/listeners/useChannelDeleted.d.ts +2 -2
- package/lib/typescript/components/ChannelList/hooks/listeners/useChannelHidden.d.ts +2 -2
- package/lib/typescript/components/ChannelList/hooks/listeners/useChannelTruncated.d.ts +2 -2
- package/lib/typescript/components/ChannelList/hooks/listeners/useChannelUpdated.d.ts +2 -2
- package/lib/typescript/components/ChannelList/hooks/listeners/useChannelVisible.d.ts +2 -2
- package/lib/typescript/components/ChannelList/hooks/listeners/useNewMessage.d.ts +1 -1
- package/lib/typescript/components/ChannelList/hooks/listeners/useNewMessageNotification.d.ts +2 -2
- package/lib/typescript/components/ChannelList/hooks/listeners/useRemovedFromChannelNotification.d.ts +2 -2
- package/lib/typescript/components/ChannelList/hooks/listeners/useUserPresence.d.ts +1 -1
- package/lib/typescript/components/ChannelList/hooks/usePaginatedChannels.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/ChannelList/ChannelList.tsx +8 -8
- package/src/components/ChannelList/hooks/listeners/__tests__/useChannelUpdated.test.tsx +2 -1
- package/src/components/ChannelList/hooks/listeners/useAddedToChannelNotification.ts +3 -3
- package/src/components/ChannelList/hooks/listeners/useChannelDeleted.ts +3 -2
- package/src/components/ChannelList/hooks/listeners/useChannelHidden.ts +4 -2
- package/src/components/ChannelList/hooks/listeners/useChannelTruncated.ts +2 -2
- package/src/components/ChannelList/hooks/listeners/useChannelUpdated.ts +4 -2
- package/src/components/ChannelList/hooks/listeners/useChannelVisible.ts +3 -3
- package/src/components/ChannelList/hooks/listeners/useNewMessage.ts +3 -1
- package/src/components/ChannelList/hooks/listeners/useNewMessageNotification.ts +3 -3
- package/src/components/ChannelList/hooks/listeners/useRemovedFromChannelNotification.ts +4 -2
- package/src/components/ChannelList/hooks/listeners/useUserPresence.ts +3 -1
- package/src/components/ChannelList/hooks/usePaginatedChannels.ts +1 -1
- package/src/version.json +1 -1
|
@@ -88,7 +88,7 @@ export type ChannelListProps<
|
|
|
88
88
|
* @overrideType Function
|
|
89
89
|
* */
|
|
90
90
|
onAddedToChannel?: (
|
|
91
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
91
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
92
92
|
event: Event<StreamChatGenerics>,
|
|
93
93
|
) => void;
|
|
94
94
|
/**
|
|
@@ -100,7 +100,7 @@ export type ChannelListProps<
|
|
|
100
100
|
* @overrideType Function
|
|
101
101
|
* */
|
|
102
102
|
onChannelDeleted?: (
|
|
103
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
103
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
104
104
|
event: Event<StreamChatGenerics>,
|
|
105
105
|
) => void;
|
|
106
106
|
/**
|
|
@@ -112,7 +112,7 @@ export type ChannelListProps<
|
|
|
112
112
|
* @overrideType Function
|
|
113
113
|
* */
|
|
114
114
|
onChannelHidden?: (
|
|
115
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
115
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
116
116
|
event: Event<StreamChatGenerics>,
|
|
117
117
|
) => void;
|
|
118
118
|
/**
|
|
@@ -124,7 +124,7 @@ export type ChannelListProps<
|
|
|
124
124
|
* @overrideType Function
|
|
125
125
|
* */
|
|
126
126
|
onChannelTruncated?: (
|
|
127
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
127
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
128
128
|
event: Event<StreamChatGenerics>,
|
|
129
129
|
) => void;
|
|
130
130
|
/**
|
|
@@ -136,7 +136,7 @@ export type ChannelListProps<
|
|
|
136
136
|
* @overrideType Function
|
|
137
137
|
* */
|
|
138
138
|
onChannelUpdated?: (
|
|
139
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
139
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
140
140
|
event: Event<StreamChatGenerics>,
|
|
141
141
|
) => void;
|
|
142
142
|
/**
|
|
@@ -148,7 +148,7 @@ export type ChannelListProps<
|
|
|
148
148
|
* @overrideType Function
|
|
149
149
|
* */
|
|
150
150
|
onChannelVisible?: (
|
|
151
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
151
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
152
152
|
event: Event<StreamChatGenerics>,
|
|
153
153
|
) => void;
|
|
154
154
|
/**
|
|
@@ -161,7 +161,7 @@ export type ChannelListProps<
|
|
|
161
161
|
* @overrideType Function
|
|
162
162
|
* */
|
|
163
163
|
onMessageNew?: (
|
|
164
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
164
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
165
165
|
event: Event<StreamChatGenerics>,
|
|
166
166
|
) => void;
|
|
167
167
|
/**
|
|
@@ -173,7 +173,7 @@ export type ChannelListProps<
|
|
|
173
173
|
* @overrideType Function
|
|
174
174
|
* */
|
|
175
175
|
onRemovedFromChannel?: (
|
|
176
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
176
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
177
177
|
event: Event<StreamChatGenerics>,
|
|
178
178
|
) => void;
|
|
179
179
|
/**
|
|
@@ -35,11 +35,12 @@ describe('useChannelUpdated', () => {
|
|
|
35
35
|
} as unknown as StreamChat;
|
|
36
36
|
|
|
37
37
|
const TestComponent = () => {
|
|
38
|
-
const [channels, setChannels] = useState<Channel[]>([mockChannel]);
|
|
38
|
+
const [channels, setChannels] = useState<Channel[] | null>([mockChannel]);
|
|
39
39
|
|
|
40
40
|
useChannelUpdated({ setChannels });
|
|
41
41
|
|
|
42
42
|
if (
|
|
43
|
+
channels &&
|
|
43
44
|
channels[0].data?.own_capabilities &&
|
|
44
45
|
Object.keys(channels[0].data?.own_capabilities as { [key: string]: boolean }).includes(
|
|
45
46
|
'send_messages',
|
|
@@ -11,9 +11,9 @@ import { getChannel } from '../../utils';
|
|
|
11
11
|
|
|
12
12
|
type Parameters<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> =
|
|
13
13
|
{
|
|
14
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>;
|
|
14
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>;
|
|
15
15
|
onAddedToChannel?: (
|
|
16
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
16
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
17
17
|
event: Event<StreamChatGenerics>,
|
|
18
18
|
) => void;
|
|
19
19
|
};
|
|
@@ -37,7 +37,7 @@ export const useAddedToChannelNotification = <
|
|
|
37
37
|
id: event.channel.id,
|
|
38
38
|
type: event.channel.type,
|
|
39
39
|
});
|
|
40
|
-
setChannels((channels) => uniqBy([channel, ...channels], 'cid'));
|
|
40
|
+
setChannels((channels) => (channels ? uniqBy([channel, ...channels], 'cid') : channels));
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
};
|
|
@@ -8,9 +8,9 @@ import type { DefaultStreamChatGenerics } from '../../../../types/types';
|
|
|
8
8
|
|
|
9
9
|
type Parameters<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> =
|
|
10
10
|
{
|
|
11
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>;
|
|
11
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>;
|
|
12
12
|
onChannelDeleted?: (
|
|
13
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
13
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
14
14
|
event: Event<StreamChatGenerics>,
|
|
15
15
|
) => void;
|
|
16
16
|
};
|
|
@@ -29,6 +29,7 @@ export const useChannelDeleted = <
|
|
|
29
29
|
onChannelDeleted(setChannels, event);
|
|
30
30
|
} else {
|
|
31
31
|
setChannels((channels) => {
|
|
32
|
+
if (!channels) return channels;
|
|
32
33
|
const index = channels.findIndex(
|
|
33
34
|
(channel) => channel.cid === (event.cid || event.channel?.cid),
|
|
34
35
|
);
|
|
@@ -8,9 +8,9 @@ import type { DefaultStreamChatGenerics } from '../../../../types/types';
|
|
|
8
8
|
|
|
9
9
|
type Parameters<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> =
|
|
10
10
|
{
|
|
11
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>;
|
|
11
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>;
|
|
12
12
|
onChannelHidden?: (
|
|
13
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
13
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
14
14
|
event: Event<StreamChatGenerics>,
|
|
15
15
|
) => void;
|
|
16
16
|
};
|
|
@@ -29,6 +29,8 @@ export const useChannelHidden = <
|
|
|
29
29
|
onChannelHidden(setChannels, event);
|
|
30
30
|
} else {
|
|
31
31
|
setChannels((channels) => {
|
|
32
|
+
if (!channels) return channels;
|
|
33
|
+
|
|
32
34
|
const index = channels.findIndex(
|
|
33
35
|
(channel) => channel.cid === (event.cid || event.channel?.cid),
|
|
34
36
|
);
|
|
@@ -9,10 +9,10 @@ import type { DefaultStreamChatGenerics } from '../../../../types/types';
|
|
|
9
9
|
type Parameters<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> =
|
|
10
10
|
{
|
|
11
11
|
refreshList: () => void;
|
|
12
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>;
|
|
12
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>;
|
|
13
13
|
setForceUpdate: React.Dispatch<React.SetStateAction<number>>;
|
|
14
14
|
onChannelTruncated?: (
|
|
15
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
15
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
16
16
|
event: Event<StreamChatGenerics>,
|
|
17
17
|
) => void;
|
|
18
18
|
};
|
|
@@ -8,9 +8,9 @@ import type { DefaultStreamChatGenerics } from '../../../../types/types';
|
|
|
8
8
|
|
|
9
9
|
type Parameters<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> =
|
|
10
10
|
{
|
|
11
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>;
|
|
11
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>;
|
|
12
12
|
onChannelUpdated?: (
|
|
13
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
13
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
14
14
|
event: Event<StreamChatGenerics>,
|
|
15
15
|
) => void;
|
|
16
16
|
};
|
|
@@ -29,6 +29,8 @@ export const useChannelUpdated = <
|
|
|
29
29
|
onChannelUpdated(setChannels, event);
|
|
30
30
|
} else {
|
|
31
31
|
setChannels((channels) => {
|
|
32
|
+
if (!channels) return channels;
|
|
33
|
+
|
|
32
34
|
const index = channels.findIndex(
|
|
33
35
|
(channel) => channel.cid === (event.cid || event.channel?.cid),
|
|
34
36
|
);
|
|
@@ -11,9 +11,9 @@ import { getChannel } from '../../utils';
|
|
|
11
11
|
|
|
12
12
|
type Parameters<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> =
|
|
13
13
|
{
|
|
14
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>;
|
|
14
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>;
|
|
15
15
|
onChannelVisible?: (
|
|
16
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
16
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
17
17
|
event: Event<StreamChatGenerics>,
|
|
18
18
|
) => void;
|
|
19
19
|
};
|
|
@@ -37,7 +37,7 @@ export const useChannelVisible = <
|
|
|
37
37
|
id: event.channel_id,
|
|
38
38
|
type: event.channel_type,
|
|
39
39
|
});
|
|
40
|
-
setChannels((channels) => uniqBy([channel, ...channels], 'cid'));
|
|
40
|
+
setChannels((channels) => (channels ? uniqBy([channel, ...channels], 'cid') : channels));
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
};
|
|
@@ -10,7 +10,7 @@ import { moveChannelUp } from '../../utils';
|
|
|
10
10
|
type Parameters<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> =
|
|
11
11
|
{
|
|
12
12
|
lockChannelOrder: boolean;
|
|
13
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>;
|
|
13
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export const useNewMessage = <
|
|
@@ -24,6 +24,8 @@ export const useNewMessage = <
|
|
|
24
24
|
useEffect(() => {
|
|
25
25
|
const handleEvent = (event: Event<StreamChatGenerics>) => {
|
|
26
26
|
setChannels((channels) => {
|
|
27
|
+
if (!channels) return channels;
|
|
28
|
+
|
|
27
29
|
if (!lockChannelOrder && event.cid && event.channel_type && event.channel_id) {
|
|
28
30
|
const targetChannelIndex = channels.findIndex((c) => c.cid === event.cid);
|
|
29
31
|
|
|
@@ -11,9 +11,9 @@ import { getChannel } from '../../utils';
|
|
|
11
11
|
|
|
12
12
|
type Parameters<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> =
|
|
13
13
|
{
|
|
14
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>;
|
|
14
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>;
|
|
15
15
|
onMessageNew?: (
|
|
16
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
16
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
17
17
|
event: Event<StreamChatGenerics>,
|
|
18
18
|
) => void;
|
|
19
19
|
};
|
|
@@ -37,7 +37,7 @@ export const useNewMessageNotification = <
|
|
|
37
37
|
id: event.channel.id,
|
|
38
38
|
type: event.channel.type,
|
|
39
39
|
});
|
|
40
|
-
setChannels((channels) => uniqBy([channel, ...channels], 'cid'));
|
|
40
|
+
setChannels((channels) => (channels ? uniqBy([channel, ...channels], 'cid') : channels));
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
};
|
|
@@ -8,9 +8,9 @@ import type { DefaultStreamChatGenerics } from '../../../../types/types';
|
|
|
8
8
|
|
|
9
9
|
type Parameters<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> =
|
|
10
10
|
{
|
|
11
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>;
|
|
11
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>;
|
|
12
12
|
onRemovedFromChannel?: (
|
|
13
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>,
|
|
13
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
|
|
14
14
|
event: Event<StreamChatGenerics>,
|
|
15
15
|
) => void;
|
|
16
16
|
};
|
|
@@ -29,6 +29,8 @@ export const useRemovedFromChannelNotification = <
|
|
|
29
29
|
onRemovedFromChannel(setChannels, event);
|
|
30
30
|
} else {
|
|
31
31
|
setChannels((channels) => {
|
|
32
|
+
if (!channels) return channels;
|
|
33
|
+
|
|
32
34
|
const newChannels = channels.filter((channel) => channel.cid !== event.channel?.cid);
|
|
33
35
|
return [...newChannels];
|
|
34
36
|
});
|
|
@@ -8,7 +8,7 @@ import type { DefaultStreamChatGenerics } from '../../../../types/types';
|
|
|
8
8
|
|
|
9
9
|
type Parameters<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> =
|
|
10
10
|
{
|
|
11
|
-
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[]>>;
|
|
11
|
+
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export const useUserPresence = <
|
|
@@ -21,6 +21,8 @@ export const useUserPresence = <
|
|
|
21
21
|
useEffect(() => {
|
|
22
22
|
const handleEvent = (event: Event<StreamChatGenerics>) => {
|
|
23
23
|
setChannels((channels) => {
|
|
24
|
+
if (!channels) return channels;
|
|
25
|
+
|
|
24
26
|
const newChannels = channels.map((channel) => {
|
|
25
27
|
if (!event.user?.id || !channel.state.members[event.user.id]) {
|
|
26
28
|
return channel;
|
|
@@ -221,7 +221,7 @@ export const usePaginatedChannels = <
|
|
|
221
221
|
// when setChannels is used. setChannels is only recommended to be used for overriding
|
|
222
222
|
// event handler. Thus instead of adding if check for channels === null, its better to
|
|
223
223
|
// simply reassign types here.
|
|
224
|
-
setChannels
|
|
224
|
+
setChannels,
|
|
225
225
|
staticChannelsActive,
|
|
226
226
|
};
|
|
227
227
|
};
|
package/src/version.json
CHANGED