From c2aacaf307be1dd5852ce2052c350aab2ba27cc2 Mon Sep 17 00:00:00 2001 From: Shiba <44804845+DeepDoge@users.noreply.github.com> Date: Fri, 7 Jan 2022 22:01:30 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=98=20removed=20memory=20cache=20for?= =?UTF-8?q?=20ctxFromURL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - we already tell browser to cache the request - and we dont need the response in the same call stack --- src/scripts/tabOnUpdated.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/scripts/tabOnUpdated.ts b/src/scripts/tabOnUpdated.ts index a8afc22..c3b7fde 100644 --- a/src/scripts/tabOnUpdated.ts +++ b/src/scripts/tabOnUpdated.ts @@ -16,8 +16,6 @@ async function resolveYT(descriptor: YtIdResolverDescriptor) { return segments.join('/'); } -const lbryPathnameCache: Record = {}; - async function ctxFromURL(href: string): Promise { if (!href) return; @@ -29,8 +27,7 @@ async function ctxFromURL(href: string): Promise { const descriptor = ytService.getId(href); if (!descriptor) return; // couldn't get the ID, so we're done - const res = href in lbryPathnameCache ? lbryPathnameCache[href] : await resolveYT(descriptor); - lbryPathnameCache[href] = res; + const res = await resolveYT(descriptor); // NOTE: API call cached by the browser if (!res) return; // couldn't find it on lbry, so we're done return { descriptor, lbryPathname: res, redirect, targetPlatform };