MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / loadMore

Function loadMore

apps/web/ui/ChannelView/ChatView/index.tsx:213–240  ·  view source on GitHub ↗
(next: boolean = false)

Source from the content-addressed store, hash-verified

211 }, [viewport, isInfiniteScrollLoading]);
212
213 async function loadMore(next: boolean = false) {
214 const key = next ? 'next' : 'prev';
215 if (isInfiniteScrollLoading || isScrolling) return;
216 if (!cursor[key]) return;
217 try {
218 setInfiniteScrollLoading(true);
219 if (cursor[key]) {
220 const data = await api.getThreads({
221 channelId: currentChannel.id,
222 cursor: cursor[key] || undefined,
223 accountId: currentCommunity.id,
224 });
225 if (data) {
226 setCursor({ ...cursor, [key]: data?.nextCursor?.[key] });
227 if (next) {
228 setThreads((threads) => [...threads, ...data.threads]);
229 } else {
230 setThreads((threads) => [...data.threads, ...threads]);
231 }
232 }
233 }
234 setIsScrolling(true);
235 setInfiniteScrollLoading(false);
236 } catch (err) {
237 setError({ ...error, [key]: err });
238 setInfiniteScrollLoading(false);
239 }
240 }
241
242 async function loadMoreNext() {
243 return loadMore(true);

Callers 1

loadMoreNextFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected