tangled
alpha
login
or
join now
margin.at
/
margin
86
fork
atom
Write on the margins of the internet. Powered by the AT Protocol.
margin.at
extension
web
atproto
comments
86
fork
atom
overview
issues
4
pulls
1
pipelines
fix load more
scanash.com
1 month ago
babbce21
8b50abe4
+18
-6
3 changed files
expand all
collapse all
unified
split
web
src
api
client.ts
types.ts
views
core
Feed.tsx
+4
-2
web/src/api/client.ts
···
177
177
}
178
178
: undefined,
179
179
context: raw.context
180
180
-
? raw.context.map((c: any) => ({
180
180
+
? raw.context.map((c) => ({
181
181
uri: c.uri,
182
182
name: c.name,
183
183
icon: c.icon,
···
294
294
return {
295
295
cursor: data.cursor,
296
296
items: groupedItems,
297
297
+
hasMore: normalizedItems.length >= limit,
298
298
+
fetchedCount: normalizedItems.length,
297
299
};
298
300
} catch (e) {
299
301
console.error(e);
300
300
-
return { items: [] };
302
302
+
return { items: [], hasMore: false, fetchedCount: 0 };
301
303
}
302
304
}
303
305
+2
web/src/types.ts
···
94
94
export interface FeedResponse {
95
95
cursor?: string;
96
96
items: AnnotationItem[];
97
97
+
hasMore?: boolean;
98
98
+
fetchedCount?: number;
97
99
}
98
100
99
101
export interface NotificationItem {
+12
-4
web/src/views/core/Feed.tsx
···
53
53
if (cancelled) return;
54
54
const fetched = data?.items || [];
55
55
setItems(fetched);
56
56
-
setHasMore(fetched.length >= LIMIT);
57
57
-
setOffset(fetched.length);
56
56
+
if (data?.hasMore !== undefined) {
57
57
+
setHasMore(data.hasMore);
58
58
+
} else {
59
59
+
setHasMore(fetched.length >= LIMIT);
60
60
+
}
61
61
+
setOffset(data?.fetchedCount ?? fetched.length);
58
62
setLoading(false);
59
63
})
60
64
.catch((e) => {
···
82
86
});
83
87
const fetched = data?.items || [];
84
88
setItems((prev) => [...prev, ...fetched]);
85
85
-
setHasMore(fetched.length >= LIMIT);
86
86
-
setOffset((prev) => prev + fetched.length);
89
89
+
if (data?.hasMore !== undefined) {
90
90
+
setHasMore(data.hasMore);
91
91
+
} else {
92
92
+
setHasMore(fetched.length >= LIMIT);
93
93
+
}
94
94
+
setOffset((prev) => prev + (data?.fetchedCount ?? fetched.length));
87
95
} catch (e) {
88
96
console.error(e);
89
97
} finally {