🍘 removed memory cache for ctxFromURL

- we already tell browser to cache the request
- and we dont need the response in the same call stack
This commit is contained in:
Shiba 2022-01-07 22:01:30 +00:00
parent 7c50daf7fc
commit c2aacaf307

View file

@ -16,8 +16,6 @@ async function resolveYT(descriptor: YtIdResolverDescriptor) {
return segments.join('/');
}
const lbryPathnameCache: Record<string, string | undefined> = {};
async function ctxFromURL(href: string): Promise<UpdateContext | void> {
if (!href) return;
@ -29,8 +27,7 @@ async function ctxFromURL(href: string): Promise<UpdateContext | void> {
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 };