mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
catalogs hook provides raw data from the stte container
This commit is contained in:
parent
8fa98feab4
commit
4a261cd82b
2 changed files with 23 additions and 25 deletions
|
|
@ -21,14 +21,28 @@ const Board = () => {
|
|||
<div className={styles['board-container']}>
|
||||
<MainNavBar className={styles['nav-bar']} />
|
||||
<div className={styles['board-content']} tabIndex={-1}>
|
||||
{catalogs.map((catalog) => (
|
||||
<BoardRow
|
||||
key={catalog.id}
|
||||
className={styles['addon-catalog-row']}
|
||||
title={catalog.title}
|
||||
items={catalog.items}
|
||||
/>
|
||||
))}
|
||||
{
|
||||
catalogs
|
||||
.filter(([_, response]) => response.type === 'Ready')
|
||||
.map(([request, response]) => [
|
||||
request,
|
||||
{
|
||||
...response,
|
||||
content: response.content.map((item) => ({
|
||||
...item,
|
||||
posterShape: item.posterShape || 'poster'
|
||||
}))
|
||||
}
|
||||
])
|
||||
.map(([request, response], index) => (
|
||||
<BoardRow
|
||||
key={`${index}${request.transport_url}`}
|
||||
className={styles['addon-catalog-row']}
|
||||
title={`${request.resource_ref.id} - ${request.resource_ref.type_name}`}
|
||||
items={response.content}
|
||||
/>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -5,23 +5,7 @@ const useCatalogs = () => {
|
|||
React.useEffect(() => {
|
||||
const onNewState = () => {
|
||||
const state = window.stateContainer.getState();
|
||||
const catalogs = state.groups.reduce((catalogs, [request, response], index) => {
|
||||
if (response.type === 'Ready') {
|
||||
catalogs.push({
|
||||
id: `${index}${request.transport_url}`,
|
||||
title: `${request.resource_ref.id} - ${request.resource_ref.type_name}`,
|
||||
items: response.content.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
posterShape: item.posterShape || 'poster'
|
||||
};
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
return catalogs;
|
||||
}, []);
|
||||
setCatalogs(catalogs);
|
||||
setCatalogs(state.groups);
|
||||
};
|
||||
window.stateContainer.on('NewState', onNewState);
|
||||
window.stateContainer.dispatch({
|
||||
|
|
|
|||
Loading…
Reference in a new issue