+11
-16
api.js
+11
-16
api.js
···
278
return await this.getRequest('app.bsky.feed.searchPosts', params);
279
}
280
281
-
/** @param {string} [cursor], @returns {Promise<json>} */
282
-
283
-
async loadNotifications(cursor) {
284
-
let params = { limit: 100 };
285
-
286
-
if (cursor) {
287
-
params.cursor = cursor;
288
-
}
289
290
-
return await this.getRequest('app.bsky.notification.listNotifications', params);
291
}
292
293
/**
···
296
*/
297
298
async loadMentions(cursor) {
299
-
let response = await this.loadNotifications(cursor);
300
-
let mentions = response.notifications.filter(x => ['reply', 'mention'].includes(x.reason));
301
-
let uris = mentions.map(x => x['uri']);
302
-
let posts = [];
303
304
for (let i = 0; i < uris.length; i += 25) {
305
-
let batch = await this.loadPosts(uris.slice(i, i + 25));
306
-
posts = posts.concat(batch);
307
}
308
309
-
return { cursor: response.cursor, posts };
310
}
311
312
/**
···
278
return await this.getRequest('app.bsky.feed.searchPosts', params);
279
}
280
281
+
/** @param {json} [params], @returns {Promise<json>} */
282
283
+
async loadNotifications(params) {
284
+
return await this.getRequest('app.bsky.notification.listNotifications', params || {});
285
}
286
287
/**
···
290
*/
291
292
async loadMentions(cursor) {
293
+
let response = await this.loadNotifications({ cursor: cursor ?? '', limit: 100, reasons: ['reply', 'mention'] });
294
+
let uris = response.notifications.map(x => x.uri);
295
+
let batches = [];
296
297
for (let i = 0; i < uris.length; i += 25) {
298
+
let batch = this.loadPosts(uris.slice(i, i + 25));
299
+
batches.push(batch);
300
}
301
302
+
let postGroups = await Promise.all(batches);
303
+
304
+
return { cursor: response.cursor, posts: postGroups.flat() };
305
}
306
307
/**