From 205a8fd151f7a667fc2b35f92632e7c07ef03dde Mon Sep 17 00:00:00 2001 From: Shiba <44804845+DeepDoge@users.noreply.github.com> Date: Sun, 9 Jan 2022 18:42:35 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=99=20Refactor=20removed=20pick=20from?= =?UTF-8?q?=20getExtensionSettings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/settings.ts | 5 +++-- src/scripts/storageSetup.ts | 2 +- src/scripts/tabOnUpdated.ts | 2 +- src/scripts/ytContent.tsx | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/common/settings.ts b/src/common/settings.ts index 2200048..c5908c8 100644 --- a/src/common/settings.ts +++ b/src/common/settings.ts @@ -6,8 +6,9 @@ export interface ExtensionSettings { export const DEFAULT_SETTINGS: ExtensionSettings = { redirect: true, targetPlatform: 'odysee', urlResolver: 'lbryInc' }; -export function getExtensionSettingsAsync>(...keys: K): Promise> { - return new Promise(resolve => chrome.storage.local.get(keys, o => resolve(o as any))); +export function getExtensionSettingsAsync(): Promise +{ + return new Promise(resolve => chrome.storage.local.get(o => resolve(o as any))); } diff --git a/src/scripts/storageSetup.ts b/src/scripts/storageSetup.ts index f574108..7f90e83 100644 --- a/src/scripts/storageSetup.ts +++ b/src/scripts/storageSetup.ts @@ -2,7 +2,7 @@ import { DEFAULT_SETTINGS, ExtensionSettings, getExtensionSettingsAsync } from ' /** Reset settings to default value and update the browser badge text */ async function initSettings() { - const settings = await getExtensionSettingsAsync(...Object.keys(DEFAULT_SETTINGS) as Array); + const settings = await getExtensionSettingsAsync(); // get all the values that aren't set and use them as a change set const invalidEntries = (Object.entries(DEFAULT_SETTINGS) as Array<[keyof ExtensionSettings, ExtensionSettings[keyof ExtensionSettings]]>) diff --git a/src/scripts/tabOnUpdated.ts b/src/scripts/tabOnUpdated.ts index 06e3644..ae767b9 100644 --- a/src/scripts/tabOnUpdated.ts +++ b/src/scripts/tabOnUpdated.ts @@ -33,7 +33,7 @@ async function ctxFromURL(href: string): Promise { const res = await resolveYT(descriptor) if (!res) return // couldn't find it on lbry, so we're done - const { redirect, targetPlatform } = await getExtensionSettingsAsync('redirect', 'targetPlatform') + const { redirect, targetPlatform } = await getExtensionSettingsAsync() return { descriptor, lbryPathname: res, redirect, targetPlatform } })()) await promise diff --git a/src/scripts/ytContent.tsx b/src/scripts/ytContent.tsx index 86e9f99..f1fd9b1 100644 --- a/src/scripts/ytContent.tsx +++ b/src/scripts/ytContent.tsx @@ -168,7 +168,7 @@ async function onPageLoad() history.pushState = function(...params) { onPushState(); return originalPushState(...params) } } - const settings = await getExtensionSettingsAsync('redirect', 'targetPlatform', 'urlResolver') + const settings = await getExtensionSettingsAsync() // Listen Settings Change chrome.storage.onChanged.addListener(async (changes, areaName) => {