diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/background.ts | 13 | ||||
-rw-r--r-- | source/feature-manager.tsx | 2 | ||||
-rw-r--r-- | source/features/tags-on-commits-list.tsx | 10 | ||||
-rw-r--r-- | source/github-helpers/github-url.ts | 2 | ||||
-rw-r--r-- | source/github-helpers/search-query.ts | 2 |
5 files changed, 14 insertions, 15 deletions
diff --git a/source/background.ts b/source/background.ts index 209f722e..d2d1ef29 100644 --- a/source/background.ts +++ b/source/background.ts @@ -15,7 +15,7 @@ import {doesBrowserActionOpenOptions} from './helpers/feature-utils.js'; addDomainPermissionToggle(); const messageHandlers = { - openUrls(urls: string[], {tab}: Runtime.MessageSender) { + async openUrls(urls: string[], {tab}: Runtime.MessageSender) { for (const [i, url] of urls.entries()) { void browser.tabs.create({ url, @@ -24,7 +24,7 @@ const messageHandlers = { }); } }, - closeTab(_: any, {tab}: Runtime.MessageSender) { + async closeTab(_: any, {tab}: Runtime.MessageSender) { void browser.tabs.remove(tab!.id!); }, async fetch(url: string) { @@ -35,12 +35,13 @@ const messageHandlers = { const response = await fetch(url); return response.json(); }, - openOptionsPage() { - void browser.runtime.openOptionsPage(); + async openOptionsPage() { + return browser.runtime.openOptionsPage(); }, -}; + // They must return a promise to mark the message as handled +} satisfies Record<string, (...arguments_: any[]) => Promise<any>>; -browser.runtime.onMessage.addListener((message: typeof messageHandlers, sender) => { +browser.runtime.onMessage.addListener((message: typeof messageHandlers, sender): Promise<unknown> | void => { for (const id of objectKeys(message)) { if (id in messageHandlers) { return messageHandlers[id](message[id], sender); diff --git a/source/feature-manager.tsx b/source/feature-manager.tsx index 0855be0e..65f52bee 100644 --- a/source/feature-manager.tsx +++ b/source/feature-manager.tsx @@ -171,7 +171,7 @@ async function setupPageLoad(id: FeatureID, config: InternalRunConfig): Promise< currentFeatureControllers.append(id, featureController); const runFeature = async (): Promise<void> => { - let result: FeatureInitResult; + let result: FeatureInitResult | undefined; try { result = await init(featureController.signal); diff --git a/source/features/tags-on-commits-list.tsx b/source/features/tags-on-commits-list.tsx index 199979f7..6dbae581 100644 --- a/source/features/tags-on-commits-list.tsx +++ b/source/features/tags-on-commits-list.tsx @@ -35,12 +35,10 @@ type TagNode = { function mergeTags(oldTags: CommitTags, newTags: CommitTags): CommitTags { const result: CommitTags = {...oldTags}; - for (const commit in newTags) { - if (result[commit]) { - result[commit] = arrayUnion(result[commit], newTags[commit]); - } else { - result[commit] = newTags[commit]; - } + for (const commit of Object.keys(newTags)) { + result[commit] = result[commit] + ? arrayUnion(result[commit], newTags[commit]) + : newTags[commit]; } return result; diff --git a/source/github-helpers/github-url.ts b/source/github-helpers/github-url.ts index 8f767e84..67f33e10 100644 --- a/source/github-helpers/github-url.ts +++ b/source/github-helpers/github-url.ts @@ -9,7 +9,7 @@ export default class GitHubURL { branch = ''; filePath = ''; - private internalUrl: URL; + private readonly internalUrl: URL; constructor(url: string) { // Use Facade pattern instead of inheritance #3193 diff --git a/source/github-helpers/search-query.ts b/source/github-helpers/search-query.ts index f7a20711..6b8d2f7d 100644 --- a/source/github-helpers/search-query.ts +++ b/source/github-helpers/search-query.ts @@ -48,7 +48,7 @@ export default class SearchQuery { return new SearchQuery(url); } - private url: URL; + private readonly url: URL; private queryParts: string[]; constructor(url: string | URL, base?: string) { |