mirror of
https://github.com/LBRYFoundation/Watch-on-LBRY.git
synced 2025-08-23 17:47:26 +00:00
commit
8c26ae0872
5 changed files with 9 additions and 23 deletions
|
@ -70,22 +70,18 @@ export function resetProfileSettings() {
|
||||||
|
|
||||||
async function apiRequest<T extends object>(method: 'GET' | 'POST', pathname: string, data: T) {
|
async function apiRequest<T extends object>(method: 'GET' | 'POST', pathname: string, data: T) {
|
||||||
const settings = await getExtensionSettingsAsync()
|
const settings = await getExtensionSettingsAsync()
|
||||||
/* const urlResolverSettings = ytUrlResolversSettings[settings.urlResolver]
|
|
||||||
if (!urlResolverSettings.signRequest) throw new Error() */
|
|
||||||
|
|
||||||
const url = new URL(ytUrlResolversSettings.madiatorFinder.href/* urlResolverSettings.href */)
|
const url = new URL(ytUrlResolversSettings.madiatorFinder.href)
|
||||||
url.pathname = path.join(url.pathname, pathname)
|
url.pathname = path.join(url.pathname, pathname)
|
||||||
url.searchParams.set('data', JSON.stringify(data))
|
url.searchParams.set('data', JSON.stringify(data))
|
||||||
|
|
||||||
if (true/* requiresSignature */) {
|
if (!settings.privateKey || !settings.publicKey)
|
||||||
if (!settings.privateKey || !settings.publicKey)
|
throw new Error('There is no profile.')
|
||||||
throw new Error('There is no profile.')
|
|
||||||
|
|
||||||
url.searchParams.set('keys', JSON.stringify({
|
url.searchParams.set('keys', JSON.stringify({
|
||||||
signature: await sign(url.searchParams.toString(), settings.privateKey!),
|
signature: await sign(url.searchParams.toString(), settings.privateKey!),
|
||||||
publicKey: settings.publicKey
|
publicKey: settings.publicKey
|
||||||
}))
|
}))
|
||||||
}
|
|
||||||
|
|
||||||
const respond = await fetch(url.href, { method })
|
const respond = await fetch(url.href, { method })
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,6 @@ async function get(id: string): Promise<string | null | undefined> {
|
||||||
await clearExpired()
|
await clearExpired()
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
console.log('cache found', id, response.value)
|
|
||||||
return response.value
|
return response.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#popup {
|
#popup {
|
||||||
width: 40em;
|
width: 40em;
|
||||||
max-width: 100%;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
@ -28,18 +27,12 @@ section {
|
||||||
gap: .75em;
|
gap: .75em;
|
||||||
}
|
}
|
||||||
|
|
||||||
section>label {
|
label {
|
||||||
font-size: 1.75em;
|
font-size: 1.75em;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
section>b {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
section>* {
|
section>* {
|
||||||
padding: 0 1rem;
|
padding: 0 1rem;
|
||||||
}
|
}
|
||||||
|
@ -59,4 +52,4 @@ section>* {
|
||||||
.toggle-option {
|
.toggle-option {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: .5em;
|
gap: .5em;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ chrome.runtime.onMessage.addListener(({ method, data }, sender, sendResponse) =>
|
||||||
const params: Parameters<typeof resolveById> = JSON.parse(data)
|
const params: Parameters<typeof resolveById> = JSON.parse(data)
|
||||||
// Don't create a new Promise for same ID until on going one is over.
|
// Don't create a new Promise for same ID until on going one is over.
|
||||||
const promise = onGoingLbryPathnameRequest[data] ?? (onGoingLbryPathnameRequest[data] = resolveById(...params))
|
const promise = onGoingLbryPathnameRequest[data] ?? (onGoingLbryPathnameRequest[data] = resolveById(...params))
|
||||||
console.log('lbrypathname request', params, await promise)
|
|
||||||
resolve(await promise)
|
resolve(await promise)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
sendResponse(`error: ${(error as any).toString()}`)
|
sendResponse(`error: ${(error as any).toString()}`)
|
||||||
|
|
|
@ -231,7 +231,6 @@ import { getExtensionSettingsAsync, getSourcePlatfromSettingsFromHostname, getTa
|
||||||
console.error("Background error on:", params)
|
console.error("Background error on:", params)
|
||||||
throw new Error(`Background error. ${response ?? ''}`)
|
throw new Error(`Background error. ${response ?? ''}`)
|
||||||
}
|
}
|
||||||
console.log(response)
|
|
||||||
return response ? JSON.parse(response) : null
|
return response ? JSON.parse(response) : null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue