* fix backup reports modal

* chore: fix comments

* chore: fix controls status

* chore: fix stale marketplace data

* slightly better registry switching

---------

Co-authored-by: Matt Hill <mattnine@protonmail.com>
This commit is contained in:
Alex Inkin
2025-06-18 23:40:39 +07:00
committed by GitHub
parent 3ec4db0225
commit 28f31be36f
10 changed files with 56 additions and 48 deletions

View File

@@ -49,38 +49,49 @@ export class MarketplaceService {
toStoreIdentity(start9, registries[start9]),
toStoreIdentity(community, registries[community]),
...Object.entries(registries)
.filter(([url, _]) => ![start9, community].includes(url as any))
.filter(([u, _]) => !sameUrl(start9, u) && !sameUrl(community, u))
.map(([url, name]) => toStoreIdentity(url, name)),
]),
)
readonly newRegistry$ = this.registries$.pipe(
startWith<StoreIdentity[]>([]),
pairwise(),
mergeMap(([p, c]) => c.filter(a => !p.find(b => sameUrl(a.url, b.url)))),
)
readonly currentRegistryUrl$ = new ReplaySubject<string>(1)
readonly requestErrors$ = new BehaviorSubject<string[]>([])
readonly marketplace$: Observable<Marketplace> = this.registries$.pipe(
startWith<StoreIdentity[]>([]),
pairwise(),
mergeMap(([prev, curr]) =>
curr.filter(c => !prev.find(p => sameUrl(c.url, p.url))),
),
mergeMap(({ url, name }) =>
this.fetchRegistry$(url).pipe(
tap(data => {
if (data?.info.name)
this.updateRegistryName(url, name, data.info.name)
readonly marketplace$: Observable<Marketplace> = combineLatest([
this.newRegistry$.pipe(
mergeMap(({ url, name }) =>
this.fetchRegistry$(url).pipe(
tap(data => {
if (data?.info.name)
this.updateRegistryName(url, name, data.info.name)
}),
map(data => [url, data] satisfies [string, StoreDataWithUrl | null]),
startWith<[string, StoreDataWithUrl | null]>([url, null]),
),
),
scan<[string, StoreDataWithUrl | null], Marketplace>(
(requests, [url, store]) => ({
...requests,
[url]: store,
}),
map(data => [url, data] satisfies [string, StoreDataWithUrl | null]),
startWith<[string, StoreDataWithUrl | null]>([url, null]),
{},
),
),
scan<[string, StoreDataWithUrl | null], Marketplace>(
(requests, [url, store]) => {
requests[url] = store
return requests
},
{},
this.registries$,
]).pipe(
map(([marketplace, registries]) =>
Object.fromEntries(
Object.entries(marketplace).filter(([url]) =>
registries.find(store => sameUrl(store.url, url)),
),
),
),
shareReplay(1),
)