Thread viewer for Bluesky

show users in the list even if they had 0 posts

Changed files
+26 -7
+26 -7
posting_stats_page.js
··· 19 19 /** @type {json[]} */ 20 20 autocompleteResults = []; 21 21 22 + /** @type {Record<string, json>} */ 23 + selectedUsers = {}; 24 + 22 25 constructor() { 23 26 this.pageElement = $id('posting_stats_page'); 24 27 this.form = $(this.pageElement.querySelector('form'), HTMLFormElement); ··· 37 40 this.userList = $(this.pageElement.querySelector('.selected-users')); 38 41 this.autocomplete = $(this.pageElement.querySelector('.autocomplete')); 39 42 40 - this.selectedUsers = new Set(); 41 43 this.userProgress = {}; 42 44 this.appView = new BlueskyAPI('public.api.bsky.app', false); 43 45 ··· 163 165 164 166 async fetchAutocomplete(query) { 165 167 let users = await accountAPI.autocompleteUsers(query); 166 - users = users.filter(u => !this.selectedUsers.has(u.did)); 168 + 169 + let selectedDIDs = new Set(Object.keys(this.selectedUsers)); 170 + users = users.filter(u => !selectedDIDs.has(u.did)); 167 171 168 172 this.autocompleteResults = users; 169 173 this.autocompleteIndex = -1; ··· 242 246 return; 243 247 } 244 248 245 - this.selectedUsers.add(user.did); 249 + this.selectedUsers[user.did] = user; 246 250 247 251 let row = this.makeUserRow(user, true); 248 252 this.userList.append(row); ··· 268 272 remove.addEventListener('click', (e) => { 269 273 e.preventDefault(); 270 274 row.remove(); 271 - this.selectedUsers.delete(user.did); 275 + delete this.selectedUsers[user.did]; 272 276 }); 273 277 274 278 row.append(remove); ··· 318 322 319 323 this.updateResultsTable(posts, startTime, requestedDays, { showReposts: false }); 320 324 } else if (scanType == 'users') { 321 - let dids = Array.from(this.selectedUsers); 325 + let dids = Object.keys(this.selectedUsers); 322 326 323 327 if (dids.length == 0) { 324 328 return; ··· 343 347 let posts = datasets.flat(); 344 348 345 349 this.updateResultsTable(posts, startTime, requestedDays, { 346 - showTotal: false, showPercentages: false, countFetchedDays: false 350 + showTotal: false, 351 + showPercentages: false, 352 + countFetchedDays: false, 353 + users: Object.values(this.selectedUsers) 347 354 }); 348 355 } else { 349 356 this.startScan(startTime, requestedDays); ··· 421 428 * @param {json[]} posts 422 429 * @param {number} startTime 423 430 * @param {number} requestedDays 424 - * @param {{ showTotal?: boolean, showPercentages?: boolean, showReposts?: boolean, countFetchedDays?: boolean }} [options] 431 + * @param {{ 432 + * showTotal?: boolean, 433 + * showPercentages?: boolean, 434 + * showReposts?: boolean, 435 + * countFetchedDays?: boolean, 436 + * users?: json[] 437 + * }} [options] 425 438 */ 426 439 427 440 updateResultsTable(posts, startTime, requestedDays, options = {}) { ··· 459 472 460 473 let timeLimit = startTime - requestedDays * 86400 * 1000; 461 474 posts = posts.filter(x => (feedPostTime(x) > timeLimit)); 475 + 476 + if (options.users) { 477 + for (let user of options.users) { 478 + users[user.handle] = { handle: user.handle, own: 0, reposts: 0, avatar: user.avatar }; 479 + } 480 + } 462 481 463 482 for (let item of posts) { 464 483 if (item.reply) { continue; }