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