Skip to content

Commit 9e623e5

Browse files
committed
Fix ts errors
1 parent 7e5b09c commit 9e623e5

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

index.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const main = async () => {
163163
}`);
164164

165165
const doc = parent.document;
166-
const appContainer = doc.getElementById('app-container');
166+
const appContainer = doc.getElementById('app-container')!;
167167

168168
// External links favicons
169169
const setFavicon = (extLinkEl: HTMLAnchorElement) => {
@@ -186,13 +186,17 @@ const main = async () => {
186186
const extLinksObserver = new MutationObserver((mutationsList, observer) => {
187187
for (let i = 0; i < mutationsList.length; i++) {
188188
const addedNode = mutationsList[i].addedNodes[0];
189-
if (addedNode && addedNode.childNodes.length) {
189+
if (
190+
addedNode &&
191+
addedNode.childNodes.length &&
192+
addedNode instanceof Element
193+
) {
190194
const extLinkList =
191195
addedNode.querySelectorAll('.external-link');
192196
if (extLinkList.length) {
193197
extLinksObserver.disconnect();
194198
for (let i = 0; i < extLinkList.length; i++) {
195-
setFavicon(extLinkList[i]);
199+
setFavicon(extLinkList[i] as HTMLAnchorElement);
196200
}
197201

198202
extLinksObserver.observe(
@@ -206,7 +210,7 @@ const main = async () => {
206210

207211
setTimeout(() => {
208212
doc.querySelectorAll('.external-link')?.forEach((extLink) =>
209-
setFavicon(extLink)
213+
setFavicon(extLink as HTMLAnchorElement)
210214
);
211215
extLinksObserver.observe(appContainer, extLinksObserverConfig);
212216
}, 500);
@@ -221,17 +225,16 @@ const main = async () => {
221225
}
222226
);
223227

224-
const blockSet = new Set();
228+
const blockSet = new Set<string>();
225229
logseq.DB.onChanged(async (e) => {
226230
if (e.txMeta?.outlinerOp !== 'insert-blocks') {
227-
blockSet.add(e.blocks[0]?.uuid);
231+
e.blocks[0]?.uuid && blockSet.add(e.blocks[0]?.uuid);
228232
doc.querySelectorAll('.external-link')?.forEach((extLink) =>
229-
setFavicon(extLink)
233+
setFavicon(extLink as HTMLAnchorElement)
230234
);
231235
return;
232236
}
233237

234-
console.log('e', e);
235238
await blockSet.forEach((uuid) => parseBlockForLink(uuid));
236239
blockSet.clear();
237240
});

0 commit comments

Comments
 (0)