+7
-1
api.js
+7
-1
api.js
···
230
230
}
231
231
}
232
232
233
-
/** @param {string} uri, @returns {Promise<json[]>} */
233
+
/** @param {string} uri, @returns {Promise<string[]>} */
234
234
235
235
async getReplies(uri) {
236
236
let json = await this.getRequest('blue.feeds.post.getReplies', { uri });
···
278
278
return await this.getRequest('app.bsky.feed.searchPosts', params);
279
279
}
280
280
281
+
/** @param {string} [cursor], @returns {Promise<json>} */
282
+
281
283
async loadNotifications(cursor) {
282
284
let params = { limit: 100 };
283
285
···
288
290
return await this.getRequest('app.bsky.notification.listNotifications', params);
289
291
}
290
292
293
+
/** @param {string} [cursor], @returns {Promise<{ cursor: string | undefined, posts: json[] }>} */
294
+
291
295
async loadMentions(cursor) {
292
296
let response = await this.loadNotifications(cursor);
293
297
let mentions = response.notifications.filter(x => ['reply', 'mention'].includes(x.reason));
···
301
305
302
306
return { cursor: response.cursor, posts };
303
307
}
308
+
309
+
/** @param {number} days, @returns {Promise<json[]>} */
304
310
305
311
async loadTimeline(days, options = {}) {
306
312
let now = new Date();
+22
-3
minisky.js
+22
-3
minisky.js
···
179
179
return await this.parseResponse(response);
180
180
}
181
181
182
+
/**
183
+
* @typedef {MiniskyOptions & {
184
+
* field: string,
185
+
* breakWhen?: (obj: json) => boolean,
186
+
* onPageLoad?: (obj: json[]) => { cancel: true },
187
+
* }} FetchAllOptions
188
+
*
189
+
* @param {string} method
190
+
* @param {json | null} params
191
+
* @param {FetchAllOptions} [options]
192
+
* @returns {Promise<json[]>}
193
+
*/
194
+
182
195
async fetchAll(method, params, options) {
183
196
if (!options || !options.field) {
184
197
throw new RequestError("'field' option is required");
···
194
207
let items = response[options.field];
195
208
let cursor = response.cursor;
196
209
197
-
if (options.breakWhen && items.some(x => options.breakWhen(x))) {
198
-
items = items.filter(x => !options.breakWhen(x));
199
-
cursor = null;
210
+
if (options.breakWhen) {
211
+
let test = options.breakWhen;
212
+
213
+
if (items.some(x => test(x))) {
214
+
items = items.filter(x => !test(x));
215
+
cursor = null;
216
+
}
200
217
}
201
218
202
219
data = data.concat(items);
···
233
250
return {};
234
251
}
235
252
}
253
+
254
+
/** @param {json} options, @param {string[]} list, @returns {json} */
236
255
237
256
sliceOptions(options, list) {
238
257
let newOptions = {};