mirror of
https://github.com/LBRYFoundation/Watch-on-LBRY.git
synced 2025-08-23 17:47:26 +00:00
Use a set to deduplicate subscriptions
This commit is contained in:
parent
30c93c2c4f
commit
8341291497
1 changed files with 3 additions and 5 deletions
|
@ -2,7 +2,7 @@ import { Fragment, h, render } from 'preact';
|
||||||
import { useState } from 'preact/hooks';
|
import { useState } from 'preact/hooks';
|
||||||
|
|
||||||
import { getSettingsAsync, redirectDomains } from '../common/settings';
|
import { getSettingsAsync, redirectDomains } from '../common/settings';
|
||||||
import { YTDescriptor, getFileContent, ytService } from '../common/yt';
|
import { getFileContent, ytService } from '../common/yt';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the subscription file and queries the API for lbry channels
|
* Parses the subscription file and queries the API for lbry channels
|
||||||
|
@ -14,10 +14,8 @@ async function lbryChannelsFromFile(file: File) {
|
||||||
const ext = file.name.split('.').pop()?.toLowerCase();
|
const ext = file.name.split('.').pop()?.toLowerCase();
|
||||||
const content = await getFileContent(file);
|
const content = await getFileContent(file);
|
||||||
|
|
||||||
const ids: YTDescriptor[] = (ext === 'xml' || ext == 'opml' ? ytService.readOpml(content) : ytService.readJson(content))
|
const ids = new Set((ext === 'xml' || ext == 'opml' ? ytService.readOpml(content) : ytService.readJson(content)))
|
||||||
.map(id => ({ id, type: 'channel' }));
|
const lbryUrls = await ytService.resolveById(...Array.from(ids).map(id => ({ id, type: 'channel' } as const)));
|
||||||
|
|
||||||
const lbryUrls = await ytService.resolveById(...ids);
|
|
||||||
const { redirect } = await getSettingsAsync('redirect');
|
const { redirect } = await getSettingsAsync('redirect');
|
||||||
const urlPrefix = redirectDomains[redirect].prefix;
|
const urlPrefix = redirectDomains[redirect].prefix;
|
||||||
return lbryUrls.map(channel => urlPrefix + channel);
|
return lbryUrls.map(channel => urlPrefix + channel);
|
||||||
|
|
Loading…
Add table
Reference in a new issue