Skip to content

Commit

Permalink
Do it better
Browse files Browse the repository at this point in the history
  • Loading branch information
spalmurray-codecov committed Oct 25, 2024
1 parent d5c1fb3 commit 8a4c236
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 22 deletions.
4 changes: 0 additions & 4 deletions src/background/dynamic_content_scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,3 @@ export async function unregisterContentScriptIfExists(

return true;
}

export async function setStorageValues(payload: any): Promise<void> {
await browser.storage.sync.set(payload);
}
9 changes: 0 additions & 9 deletions src/background/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,8 @@ import { MessageType } from "src/types";
import { Codecov } from "src/service";
import {
registerContentScript,
setStorageValues,
unregisterContentScriptIfExists,
} from "./dynamic_content_scripts";
import {
selfHostedCodecovApiToken,
selfHostedCodecovURLStorageKey,
selfHostedGitHubURLStorageKey,
useSelfHostedStorageKey,
} from "src/constants";

async function main(): Promise<void> {
browser.runtime.onMessage.addListener(handleMessages);
Expand All @@ -38,8 +31,6 @@ async function handleMessages(message: {
return registerContentScript(message.payload);
case MessageType.UNREGISTER_CONTENT_SCRIPTS:
return unregisterContentScriptIfExists(message.payload);
case MessageType.SET_STORAGE_VALUES:
return setStorageValues(message.payload);
}
}

Expand Down
13 changes: 5 additions & 8 deletions src/popup/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,11 @@ const Popup = () => {
}
}

await browser.runtime.sendMessage({
type: MessageType.SET_STORAGE_VALUES,
payload: {
[useSelfHostedStorageKey]: useSelfHosted,
[selfHostedCodecovURLStorageKey]: codecovUrl,
[selfHostedGitHubURLStorageKey]: githubUrl,
[selfHostedCodecovApiToken]: codecovApiToken,
},
await browser.storage.sync.set({
[useSelfHostedStorageKey]: useSelfHosted,
[selfHostedCodecovURLStorageKey]: codecovUrl,
[selfHostedGitHubURLStorageKey]: githubUrl,
[selfHostedCodecovApiToken]: codecovApiToken,
});

resetEphemeralState();
Expand Down
1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ export enum MessageType {
FETCH_COMPONENTS_LIST = "fetch_components_list",
REGISTER_CONTENT_SCRIPTS = "register_content_scripts",
UNREGISTER_CONTENT_SCRIPTS = "unregister_content_scripts",
SET_STORAGE_VALUES = "set_storage_values",
}

0 comments on commit 8a4c236

Please sign in to comment.