library adapted to new stremio-core changes

This commit is contained in:
svetlagasheva 2019-11-25 12:04:20 +02:00
parent 535c0eef8a
commit 2e8909935e
2 changed files with 4 additions and 4 deletions

View file

@ -8,7 +8,7 @@ const useLibrary = (urlParams) => {
React.useEffect(() => {
const onNewState = () => {
const state = core.getState();
if (state.library.selected === null && state.library.type_names.length > 0) {
if (state.library.selected.type_name === null && state.library.type_names.length > 0) {
core.dispatch({
action: 'Load',
args: {
@ -21,7 +21,7 @@ const useLibrary = (urlParams) => {
return;
}
const selectInput = {
selected: [state.library.selected],
selected: [state.library.selected.type_name],
options: state.library.type_names
.map((type) => ({
label: type === '' ? '"Empty"' : type,
@ -33,7 +33,7 @@ const useLibrary = (urlParams) => {
}
};
const error = state.library.library_state.type !== 'Ready' ? state.library.library_state.type : null;
setLibrary([state.library.items, selectInput, error]);
setLibrary([state.library.lib_items, selectInput, error]);
};
core.on('NewModel', onNewState);
const state = core.getState();

View file

@ -26,7 +26,7 @@ const useSort = (urlParams, queryParams) => {
onSelect: (event) => {
const nextQuery = new URLSearchParams({ sort: event.value });
const state = core.getState();
window.location.replace(`#/library/${state.library.selected !== null ? state.library.selected : ''}?${nextQuery}`);
window.location.replace(`#/library/${state.library.selected.type_name !== null ? state.library.selected.type_name : ''}?${nextQuery}`);
}
};
setSort([selectInput, sortItems]);