From 8a4c236abced330cf1aa3cc6c223c95016f27e1a Mon Sep 17 00:00:00 2001 From: Spencer Murray Date: Fri, 25 Oct 2024 16:53:23 -0400 Subject: [PATCH] Do it better --- src/background/dynamic_content_scripts.ts | 4 ---- src/background/main.ts | 9 --------- src/popup/main.tsx | 13 +++++-------- src/types.ts | 1 - 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/background/dynamic_content_scripts.ts b/src/background/dynamic_content_scripts.ts index 2acfe1a..ae8c58d 100644 --- a/src/background/dynamic_content_scripts.ts +++ b/src/background/dynamic_content_scripts.ts @@ -55,7 +55,3 @@ export async function unregisterContentScriptIfExists( return true; } - -export async function setStorageValues(payload: any): Promise { - await browser.storage.sync.set(payload); -} diff --git a/src/background/main.ts b/src/background/main.ts index 46c8dd9..45b6041 100644 --- a/src/background/main.ts +++ b/src/background/main.ts @@ -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 { browser.runtime.onMessage.addListener(handleMessages); @@ -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); } } diff --git a/src/popup/main.tsx b/src/popup/main.tsx index 25e6d82..8cd3f5a 100644 --- a/src/popup/main.tsx +++ b/src/popup/main.tsx @@ -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(); diff --git a/src/types.ts b/src/types.ts index 801ce51..769435e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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", }