mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
addons hooks adapted to changes in core
This commit is contained in:
parent
c82a4563df
commit
5ee47cf7d2
2 changed files with 41 additions and 35 deletions
|
|
@ -21,16 +21,16 @@ const mapAddonsStateWithCtx = (addons, ctx) => {
|
|||
...addons.catalog_resource,
|
||||
content: {
|
||||
...addons.catalog_resource.content,
|
||||
content: addons.catalog_resource.content.content.map((descriptor) => ({
|
||||
transportUrl: descriptor.transportUrl,
|
||||
installed: ctx.content.addons.some((addon) => addon.transportUrl === descriptor.transportUrl),
|
||||
content: addons.catalog_resource.content.content.map((addon) => ({
|
||||
transportUrl: addon.transportUrl,
|
||||
installed: ctx.profile.addons.some(({ transportUrl }) => transportUrl === addon.transportUrl),
|
||||
manifest: {
|
||||
id: descriptor.manifest.id,
|
||||
name: descriptor.manifest.name,
|
||||
version: descriptor.manifest.version,
|
||||
logo: descriptor.manifest.logo,
|
||||
description: descriptor.manifest.description,
|
||||
types: descriptor.manifest.types
|
||||
id: addon.manifest.id,
|
||||
name: addon.manifest.name,
|
||||
version: addon.manifest.version,
|
||||
logo: addon.manifest.logo,
|
||||
description: addon.manifest.description,
|
||||
types: addon.manifest.types
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
|
@ -45,8 +45,10 @@ const onNewAddonsState = (addons) => {
|
|||
return {
|
||||
action: 'Load',
|
||||
args: {
|
||||
load: 'CatalogFiltered',
|
||||
args: addons.selectable.catalogs[0].load_request
|
||||
model: 'CatalogFiltered',
|
||||
args: {
|
||||
request: addons.selectable.catalogs[0].request
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -59,14 +61,16 @@ const useAddons = (urlParams) => {
|
|||
return {
|
||||
action: 'Load',
|
||||
args: {
|
||||
load: 'CatalogFiltered',
|
||||
model: 'CatalogFiltered',
|
||||
args: {
|
||||
base: urlParams.transportUrl,
|
||||
path: {
|
||||
resource: 'addon_catalog',
|
||||
type_name: urlParams.type,
|
||||
id: urlParams.catalogId,
|
||||
extra: []
|
||||
request: {
|
||||
base: urlParams.transportUrl,
|
||||
path: {
|
||||
resource: 'addon_catalog',
|
||||
type_name: urlParams.type,
|
||||
id: urlParams.catalogId,
|
||||
extra: []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -77,8 +81,10 @@ const useAddons = (urlParams) => {
|
|||
return {
|
||||
action: 'Load',
|
||||
args: {
|
||||
load: 'CatalogFiltered',
|
||||
args: addons.selectable.catalogs[0].load_request
|
||||
model: 'CatalogFiltered',
|
||||
args: {
|
||||
request: addons.selectable.catalogs[0].request
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
const React = require('react');
|
||||
|
||||
const navigateWithLoadRequest = (load_request) => {
|
||||
const transportUrl = encodeURIComponent(load_request.base);
|
||||
const catalogId = encodeURIComponent(load_request.path.id);
|
||||
const type = encodeURIComponent(load_request.path.type_name);
|
||||
const navigateWithRequest = (request) => {
|
||||
const transportUrl = encodeURIComponent(request.base);
|
||||
const catalogId = encodeURIComponent(request.path.id);
|
||||
const type = encodeURIComponent(request.path.type_name);
|
||||
window.location.replace(`#/addons/${transportUrl}/${catalogId}/${type}`);
|
||||
};
|
||||
|
||||
|
|
@ -18,35 +18,35 @@ const mapSelectableInputs = (addons) => {
|
|||
const catalogSelect = {
|
||||
title: 'Select catalog',
|
||||
options: addons.selectable.catalogs
|
||||
.map(({ name, load_request }) => ({
|
||||
value: JSON.stringify(load_request),
|
||||
.map(({ name, request }) => ({
|
||||
value: JSON.stringify(request),
|
||||
label: name
|
||||
})),
|
||||
selected: addons.selectable.catalogs
|
||||
.filter(({ load_request: { path: { id } } }) => {
|
||||
.filter(({ request: { path: { id } } }) => {
|
||||
return addons.catalog_resource !== null &&
|
||||
addons.catalog_resource.request.path.id === id;
|
||||
})
|
||||
.map(({ load_request }) => JSON.stringify(load_request)),
|
||||
.map(({ request }) => JSON.stringify(request)),
|
||||
onSelect: (event) => {
|
||||
navigateWithLoadRequest(JSON.parse(event.value));
|
||||
navigateWithRequest(JSON.parse(event.value));
|
||||
}
|
||||
};
|
||||
const typeSelect = {
|
||||
title: 'Select type',
|
||||
options: addons.selectable.types
|
||||
.map(({ name, load_request }) => ({
|
||||
value: JSON.stringify(load_request),
|
||||
.map(({ name, request }) => ({
|
||||
value: JSON.stringify(request),
|
||||
label: name
|
||||
})),
|
||||
selected: addons.selectable.types
|
||||
.filter(({ load_request }) => {
|
||||
.filter(({ request }) => {
|
||||
return addons.catalog_resource !== null &&
|
||||
equalWithouExtra(addons.catalog_resource.request, load_request);
|
||||
equalWithouExtra(addons.catalog_resource.request, request);
|
||||
})
|
||||
.map(({ load_request }) => JSON.stringify(load_request)),
|
||||
.map(({ request }) => JSON.stringify(request)),
|
||||
onSelect: (event) => {
|
||||
navigateWithLoadRequest(JSON.parse(event.value));
|
||||
navigateWithRequest(JSON.parse(event.value));
|
||||
}
|
||||
};
|
||||
return [catalogSelect, typeSelect];
|
||||
|
|
|
|||
Loading…
Reference in a new issue