Skip to content

Commit 2095dc0

Browse files
committed
chore: clean up usePaginatedChannels hook
1 parent 15b6719 commit 2095dc0

File tree

1 file changed

+0
-27
lines changed

1 file changed

+0
-27
lines changed

package/src/components/ChannelList/hooks/usePaginatedChannels.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,9 @@ export const usePaginatedChannels = <
6565
setForceUpdate,
6666
sort = {},
6767
}: Parameters<StreamChatGenerics>) => {
68-
// const [channels, setChannels] = useState<Channel<StreamChatGenerics>[] | null>(null);
6968
const [error, setError] = useState<Error | undefined>(undefined);
7069
const [staticChannelsActive, setStaticChannelsActive] = useState<boolean>(false);
71-
// const [activeQueryType, setActiveQueryType] = useState<QueryType | null>('queryLocalDB');
7270
const activeQueryType = useRef<QueryType | null>('queryLocalDB');
73-
// const [hasNextPage, setHasNextPage] = useState<boolean>(false);
7471
const activeChannels = useActiveChannelsRefContext();
7572
const isMountedRef = useIsMountedRef();
7673
const { client } = useChatContext<StreamChatGenerics>();
@@ -113,7 +110,6 @@ export const usePaginatedChannels = <
113110
setError(undefined);
114111
activeRequestId.current++;
115112
const currentRequestId = activeRequestId.current;
116-
// setActiveQueryType(queryType);
117113
activeQueryType.current = queryType;
118114

119115
const newOptions = {
@@ -139,21 +135,7 @@ export const usePaginatedChannels = <
139135
});
140136
}
141137

142-
// const newChannels =
143-
// queryType === 'loadChannels' && !staticChannelsActive && channels
144-
// ? [...channels, ...channelQueryResponse]
145-
// : channelQueryResponse.map((c) => {
146-
// const existingChannel = client.activeChannels[c.cid];
147-
// if (existingChannel) {
148-
// return existingChannel;
149-
// }
150-
//
151-
// return c;
152-
// });
153-
154-
// setChannels(newChannels);
155138
setStaticChannelsActive(false);
156-
// setHasNextPage(channelQueryResponse.length >= newOptions.limit);
157139
isQueryingRef.current = false;
158140
} catch (err: unknown) {
159141
isQueryingRef.current = false;
@@ -166,7 +148,6 @@ export const usePaginatedChannels = <
166148
// querying.current check is needed in order to make sure the next query call doesnt flick an error
167149
// state and then succeed (reconnect case)
168150
if (retryCount === MAX_NUMBER_OF_RETRIES && !isQueryingRef.current) {
169-
// setActiveQueryType(null);
170151
activeQueryType.current = null;
171152
console.warn(err);
172153

@@ -181,7 +162,6 @@ export const usePaginatedChannels = <
181162
return queryChannels(queryType, retryCount + 1);
182163
}
183164

184-
// setActiveQueryType(null);
185165
activeQueryType.current = null;
186166
};
187167

@@ -219,7 +199,6 @@ export const usePaginatedChannels = <
219199
const sortStr = useMemo(() => JSON.stringify(sort), [sort]);
220200

221201
useEffect(() => {
222-
console.log('TRIGGERING', !channelManager, ready);
223202
const loadOfflineChannels = async () => {
224203
if (!client?.user?.id) return;
225204

@@ -244,7 +223,6 @@ export const usePaginatedChannels = <
244223
return false;
245224
}
246225

247-
// setActiveQueryType(null);
248226
activeQueryType.current = null;
249227

250228
return true;
@@ -293,11 +271,6 @@ export const usePaginatedChannels = <
293271
channels,
294272
error,
295273
hasNextPage,
296-
// loadingChannels:
297-
// activeQueryType.current === 'queryLocalDB'
298-
// ? true
299-
// : (activeQueryType.current === 'reload' || activeQueryType.current === null) &&
300-
// channels === null,
301274
loadingChannels:
302275
activeQueryType.current === 'queryLocalDB'
303276
? true

0 commit comments

Comments
 (0)