Thread viewer for Bluesky

fixed/silenced some typescript warnings

+7
models.js
··· 71 71 pageRoot; 72 72 73 73 /** 74 + * Info about the author of the "grandparent" post. Included only in feedPost views, for the purposes 75 + * of feed filtering algorithm. 76 + * @type {json | undefined} 77 + */ 78 + grandparentAuthor; 79 + 80 + /** 74 81 * Depth of the post in the getPostThread response it was loaded from, starting from 0. May be negative. 75 82 * @type {number | undefined} 76 83 */
+2 -2
post_component.js
··· 380 380 link.addEventListener('click', (e) => { 381 381 e.preventDefault(); 382 382 loadMore.innerHTML = `<img class="loader" src="icons/sunny.png">`; 383 - loadSubtree(this.post, loadMore.closest('.post')); 383 + loadSubtree(this.post, this.rootElement); 384 384 }); 385 385 386 386 loadMore.appendChild(link); ··· 416 416 417 417 loadHiddenReplies(loadMoreButton) { 418 418 loadMoreButton.innerHTML = `<img class="loader" src="icons/sunny.png">`; 419 - loadHiddenSubtree(this.post, loadMoreButton.closest('.post')); 419 + loadHiddenSubtree(this.post, this.rootElement); 420 420 } 421 421 422 422 /** @param {HTMLLinkElement} authorLink */
+15 -10
skythread.js
··· 7 7 window.biohazardEnabled = JSON.parse(localStorage.getItem('biohazard') ?? 'null'); 8 8 9 9 window.loginDialog = document.querySelector('#login'); 10 + window.accountMenu = document.querySelector('#account_menu'); 10 11 11 12 html.addEventListener('click', (e) => { 12 13 $id('account_menu').style.visibility = 'hidden'; ··· 52 53 window.loadInfohazard = undefined; 53 54 } 54 55 55 - hideDialog(e.target.closest('.dialog')); 56 + let target = /** @type {AnyElement} */ (/** @type {unknown} */ (e.target)); 57 + 58 + hideDialog(target.closest('.dialog')); 56 59 }); 57 60 58 61 document.querySelector('#biohazard_hide').addEventListener('click', (e) => { ··· 66 69 p.style.display = 'none'; 67 70 } 68 71 69 - hideDialog(e.target.closest('.dialog')); 72 + let target = /** @type {AnyElement} */ (/** @type {unknown} */ (e.target)); 73 + 74 + hideDialog(target.closest('.dialog')); 70 75 }); 71 76 72 77 document.querySelector('#account').addEventListener('click', (e) => { ··· 74 79 e.stopPropagation(); 75 80 }); 76 81 77 - document.querySelector('#account_menu').addEventListener('click', (e) => { 82 + accountMenu.addEventListener('click', (e) => { 78 83 e.stopPropagation(); 79 84 }); 80 85 81 - document.querySelector('#account_menu a[data-action=biohazard]').addEventListener('click', (e) => { 86 + accountMenu.querySelector('a[data-action=biohazard]').addEventListener('click', (e) => { 82 87 e.preventDefault(); 83 88 84 89 let hazards = document.querySelectorAll('p.hidden-replies, .content > .post.blocked, .blocked > .load-post'); ··· 96 101 } 97 102 }); 98 103 99 - document.querySelector('#account_menu a[data-action=incognito]').addEventListener('click', (e) => { 104 + accountMenu.querySelector('a[data-action=incognito]').addEventListener('click', (e) => { 100 105 e.preventDefault(); 101 106 102 107 if (isIncognito) { ··· 108 113 location.reload(); 109 114 }); 110 115 111 - document.querySelector('#account_menu a[data-action=login]').addEventListener('click', (e) => { 116 + accountMenu.querySelector('a[data-action=login]').addEventListener('click', (e) => { 112 117 e.preventDefault(); 113 118 toggleDialog(loginDialog); 114 119 $id('account_menu').style.visibility = 'hidden'; 115 120 }); 116 121 117 - document.querySelector('#account_menu a[data-action=logout]').addEventListener('click', (e) => { 122 + accountMenu.querySelector('a[data-action=logout]').addEventListener('click', (e) => { 118 123 e.preventDefault(); 119 124 logOut(); 120 125 }); ··· 248 253 /** @param {string} buttonName */ 249 254 250 255 function showMenuButton(buttonName) { 251 - let button = document.querySelector(`#account_menu a[data-action=${buttonName}]`); 256 + let button = accountMenu.querySelector(`a[data-action=${buttonName}]`); 252 257 button.parentNode.style.display = 'list-item'; 253 258 } 254 259 255 260 /** @param {string} buttonName */ 256 261 257 262 function hideMenuButton(buttonName) { 258 - let button = document.querySelector(`#account_menu a[data-action=${buttonName}]`); 263 + let button = accountMenu.querySelector(`a[data-action=${buttonName}]`); 259 264 button.parentNode.style.display = 'none'; 260 265 } 261 266 262 267 /** @param {string} buttonName, @param {boolean} state */ 263 268 264 269 function toggleMenuButton(buttonName, state) { 265 - let button = document.querySelector(`#account_menu a[data-action=${buttonName}]`); 270 + let button = accountMenu.querySelector(`a[data-action=${buttonName}]`); 266 271 button.querySelector('.check').style.display = (state) ? 'inline' : 'none'; 267 272 } 268 273
+4
types.d.ts
··· 12 12 declare var isIncognito: boolean; 13 13 declare var biohazardEnabled: boolean; 14 14 declare var loginDialog: AnyElement; 15 + declare var accountMenu: AnyElement; 15 16 16 17 type SomeElement = Element | HTMLElement | AnyElement; 17 18 type json = Record<string, any>; ··· 20 21 classList: CSSClassList; 21 22 className: string; 22 23 innerText: string; 24 + innerHTML: string; 23 25 nextElementSibling: AnyElement; 24 26 parentNode: AnyElement; 25 27 src: string; ··· 31 33 32 34 append(...e: Array<string | SomeElement>): void; 33 35 appendChild(e: SomeElement): void; 36 + closest(q: string): AnyElement; 34 37 querySelector(q: string): AnyElement; 38 + querySelectorAll(q: string): AnyElement[]; 35 39 prepend(...e: Array<string | SomeElement>): void; 36 40 remove(): void; 37 41 replaceChildren(e: SomeElement): void;