alpha
Login
or
Join now
atpota.to
/
flushes.app
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
add pagination to record fetching
author
damedotblog
date
1 year ago
(Jun 14, 2025, 10:27 PM -0400)
commit
c55d86b4
c55d86b418701d60a8426d9a33da41c8e83f43dd
parent
618da8ac
618da8ace0c660de1ad0a20a0c3c456f56773463
+33
-12
1 changed file
Expand all
Collapse all
Unified
Split
app
src
app
profile
[handle]
page.tsx
+33
-12
app/src/app/profile/[handle]/page.tsx
Reviewed
···
139
139
console.log(`Using PDS endpoint: ${serviceEndpoint}`);
140
140
141
141
// Step 3: Fetch records from PDS
142
142
-
const listRecordsUrl = `${serviceEndpoint}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=im.flushing.right.now&limit=100`;
143
143
-
console.log(`Fetching records from: ${listRecordsUrl}`);
142
142
+
let allRecords: any[] = [];
143
143
+
let cursor: string | undefined;
144
144
+
let hasMore = true;
144
145
145
145
-
const recordsResponse = await fetch(listRecordsUrl, {
146
146
-
headers: {
147
147
-
'Accept': 'application/json'
146
146
+
while (hasMore) {
147
147
+
const listRecordsUrl = `${serviceEndpoint}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=im.flushing.right.now&limit=100${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ''}`;
148
148
+
console.log(`Fetching records from: ${listRecordsUrl}`);
149
149
+
150
150
+
const recordsResponse = await fetch(listRecordsUrl, {
151
151
+
headers: {
152
152
+
'Accept': 'application/json'
153
153
+
}
154
154
+
});
155
155
+
156
156
+
if (!recordsResponse.ok) {
157
157
+
throw new Error(`Failed to fetch records: ${recordsResponse.statusText}`);
158
158
+
}
159
159
+
160
160
+
const recordsData = await recordsResponse.json();
161
161
+
console.log(`Fetched ${recordsData.records.length} records${cursor ? ' (next page)' : ''}`);
162
162
+
163
163
+
// Add records to our collection
164
164
+
allRecords = [...allRecords, ...recordsData.records];
165
165
+
166
166
+
// Check if we have more pages
167
167
+
cursor = recordsData.cursor;
168
168
+
hasMore = !!cursor && recordsData.records.length === 100;
169
169
+
170
170
+
if (hasMore) {
171
171
+
console.log(`More records available, cursor: ${cursor}`);
172
172
+
} else {
173
173
+
console.log('No more records to fetch');
148
174
}
149
149
-
});
150
150
-
151
151
-
if (!recordsResponse.ok) {
152
152
-
throw new Error(`Failed to fetch records: ${recordsResponse.statusText}`);
153
175
}
154
176
155
155
-
const recordsData = await recordsResponse.json();
156
156
-
console.log('Records data:', recordsData);
177
177
+
console.log(`Total records fetched: ${allRecords.length}`);
157
178
158
179
// Transform the records into our format
159
159
-
const userEntries = recordsData.records
180
180
+
const userEntries = allRecords
160
181
.map((record: any) => {
161
182
const text = record.value.text || '';
162
183
if (containsBannedWords(text)) return null;