diff --git a/src/api/api.js b/src/api/api.js index ed62c42..1e08d20 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -255,7 +255,7 @@ export class BlueskyAPI extends Minisky { return { cursor: response.cursor, posts: postGroups.flat() }; } - /** @param {Post} post, @returns {Promise} */ + /** @param {Post} post, @returns {Promise<(json | null)[]>} */ async loadHiddenReplies(post) { let expectedReplyURIs; diff --git a/src/api/handle_cache.js b/src/api/handle_cache.ts similarity index 58% rename from src/api/handle_cache.js rename to src/api/handle_cache.ts index 80db6a0..8ffca36 100644 --- a/src/api/handle_cache.js +++ b/src/api/handle_cache.ts @@ -2,10 +2,15 @@ * Caches the mapping of handles to DIDs to avoid unnecessary API calls to resolveHandle or getProfile. */ +type HandleMap = Record; + export class HandleCache { - prepareCache() { + cache?: HandleMap + + prepareCache(): asserts this is { cache: HandleMap } { if (!this.cache) { - this.cache = JSON.parse(localStorage.getItem('handleCache') ?? '{}'); + let savedCache = localStorage.getItem('handleCache'); + this.cache = (savedCache ? JSON.parse(savedCache) : {}) as HandleMap; } } @@ -13,24 +18,18 @@ export class HandleCache { localStorage.setItem('handleCache', JSON.stringify(this.cache)); } - /** @param {string} handle, @returns {string | undefined} */ - - getHandleDid(handle) { + getHandleDid(handle: string): string | undefined { this.prepareCache(); return this.cache[handle]; } - /** @param {string} handle, @param {string} did */ - - setHandleDid(handle, did) { + setHandleDid(handle: string, did: string) { this.prepareCache(); this.cache[handle] = did; this.saveCache(); } - /** @param {string} did, @returns {string | undefined} */ - - findHandleByDid(did) { + findHandleByDid(did: string) { this.prepareCache(); let found = Object.entries(this.cache).find((e) => e[1] == did); return found ? found[0] : undefined; diff --git a/src/api/identity.js b/src/api/identity.ts similarity index 85% rename from src/api/identity.js rename to src/api/identity.ts index 1b9b4dd..a545417 100644 --- a/src/api/identity.js +++ b/src/api/identity.ts @@ -8,11 +8,8 @@ export class DIDError extends Error {} export class LoginError extends Error {} - -/** @param {string} did, @returns {Promise} */ - -export async function pdsEndpointForDID(did) { - let documentURL; +export async function pdsEndpointForDID(did: string): Promise { + let documentURL: URL; if (did.startsWith('did:plc:')) { documentURL = new URL(`https://plc.directory/${did}`); @@ -42,9 +39,7 @@ export async function pdsEndpointForDID(did) { } } -/** @param {string} identifier, @returns {Promise} */ - -export async function pdsEndpointForIdentifier(identifier) { +export async function pdsEndpointForIdentifier(identifier: string): Promise { if (identifier.match(/^did:/)) { return await pdsEndpointForDID(identifier); diff --git a/src/components/AccountMenu.svelte b/src/components/AccountMenu.svelte index 52b5ea0..efe6e8e 100644 --- a/src/components/AccountMenu.svelte +++ b/src/components/AccountMenu.svelte @@ -1,4 +1,4 @@ -
  • diff --git a/src/components/BiohazardDialog.svelte b/src/components/BiohazardDialog.svelte index 8d2603b..fbb5946 100644 --- a/src/components/BiohazardDialog.svelte +++ b/src/components/BiohazardDialog.svelte @@ -1,28 +1,26 @@ - diff --git a/src/components/HomeSearch.svelte b/src/components/HomeSearch.svelte index de965f9..ca37366 100644 --- a/src/components/HomeSearch.svelte +++ b/src/components/HomeSearch.svelte @@ -1,14 +1,14 @@ - diff --git a/src/components/LoadableImage.svelte b/src/components/LoadableImage.svelte index 4f6e463..d0aebea 100644 --- a/src/components/LoadableImage.svelte +++ b/src/components/LoadableImage.svelte @@ -1,6 +1,6 @@ - diff --git a/src/components/RichTextFromFacets.svelte b/src/components/RichTextFromFacets.svelte index 653e677..62886fb 100644 --- a/src/components/RichTextFromFacets.svelte +++ b/src/components/RichTextFromFacets.svelte @@ -1,8 +1,8 @@ - {#if embed instanceof RawRecordEmbed || embed instanceof InlineRecordEmbed} diff --git a/src/components/embeds/FeedGeneratorView.svelte b/src/components/embeds/FeedGeneratorView.svelte index 5ef8ffc..df77c0d 100644 --- a/src/components/embeds/FeedGeneratorView.svelte +++ b/src/components/embeds/FeedGeneratorView.svelte @@ -1,9 +1,10 @@ - diff --git a/src/components/posts/EdgeMargin.svelte b/src/components/posts/EdgeMargin.svelte index 84be8ac..630619c 100644 --- a/src/components/posts/EdgeMargin.svelte +++ b/src/components/posts/EdgeMargin.svelte @@ -1,9 +1,8 @@ - diff --git a/src/components/posts/FediSourceLink.svelte b/src/components/posts/FediSourceLink.svelte index c19077a..de6fe95 100644 --- a/src/components/posts/FediSourceLink.svelte +++ b/src/components/posts/FediSourceLink.svelte @@ -1,5 +1,5 @@ - diff --git a/src/components/posts/FeedPostParent.svelte b/src/components/posts/FeedPostParent.svelte index 4f96cec..074d7ea 100644 --- a/src/components/posts/FeedPostParent.svelte +++ b/src/components/posts/FeedPostParent.svelte @@ -1,8 +1,8 @@ - diff --git a/src/components/posts/HiddenRepliesLink.svelte b/src/components/posts/HiddenRepliesLink.svelte index c8221ef..303da4f 100644 --- a/src/components/posts/HiddenRepliesLink.svelte +++ b/src/components/posts/HiddenRepliesLink.svelte @@ -1,15 +1,20 @@ -

    diff --git a/src/components/posts/PostBody.svelte b/src/components/posts/PostBody.svelte index 9a81aa4..873bb8e 100644 --- a/src/components/posts/PostBody.svelte +++ b/src/components/posts/PostBody.svelte @@ -1,19 +1,18 @@ - diff --git a/src/components/posts/PostTagsRow.svelte b/src/components/posts/PostTagsRow.svelte index 00a5f55..f0ee166 100644 --- a/src/components/posts/PostTagsRow.svelte +++ b/src/components/posts/PostTagsRow.svelte @@ -1,8 +1,9 @@ -

    diff --git a/src/components/posts/ReferencedPostAuthorLink.svelte b/src/components/posts/ReferencedPostAuthorLink.svelte index 7f490a1..91840ae 100644 --- a/src/components/posts/ReferencedPostAuthorLink.svelte +++ b/src/components/posts/ReferencedPostAuthorLink.svelte @@ -1,11 +1,12 @@ - diff --git a/src/components/posts/ThreadRootParentRaw.svelte b/src/components/posts/ThreadRootParentRaw.svelte index af4e602..0368897 100644 --- a/src/components/posts/ThreadRootParentRaw.svelte +++ b/src/components/posts/ThreadRootParentRaw.svelte @@ -1,8 +1,8 @@ - diff --git a/src/pages/HashtagPage.svelte b/src/pages/HashtagPage.svelte index d7b6bb6..4d1d89e 100644 --- a/src/pages/HashtagPage.svelte +++ b/src/pages/HashtagPage.svelte @@ -1,19 +1,19 @@ - -{#if firstPageLoaded} +{#if quoteCount !== undefined}

    {#if quoteCount > 1} diff --git a/src/pages/ThreadPage.svelte b/src/pages/ThreadPage.svelte index 98a2948..3f1c0a6 100644 --- a/src/pages/ThreadPage.svelte +++ b/src/pages/ThreadPage.svelte @@ -1,4 +1,4 @@ -