From b3c826a16e32316a1cdb12c4b8e81013538b6184 Mon Sep 17 00:00:00 2001 From: nklhrstv Date: Fri, 27 Mar 2020 23:28:18 +0200 Subject: [PATCH] continue_watching flag removed in library --- src/routes/Library/useLibrary.js | 42 +++++------------------ src/routes/Library/useSelectableInputs.js | 17 ++------- 2 files changed, 11 insertions(+), 48 deletions(-) diff --git a/src/routes/Library/useLibrary.js b/src/routes/Library/useLibrary.js index a533914db..cad2bea95 100644 --- a/src/routes/Library/useLibrary.js +++ b/src/routes/Library/useLibrary.js @@ -1,8 +1,6 @@ const React = require('react'); const { useModelState } = require('stremio/common'); -const DEFAULT_SORT = 'lastwatched'; - const initLibraryState = () => ({ selected: null, type_names: [], @@ -28,44 +26,22 @@ const mapLibraryState = (library) => { return { selected, type_names, lib_items }; }; -const onNewLibraryState = (library) => { - if (library.selected === null) { - return { - action: 'Load', - args: { - model: 'LibraryWithFilters', - args: { - type_name: null, - sort: DEFAULT_SORT, - continue_watching: false - } - } - }; - } else { - return null; - } -}; - const useLibrary = (urlParams, queryParams) => { - const loadLibraryAction = React.useMemo(() => { - return { - action: 'Load', + const loadLibraryAction = React.useMemo(() => ({ + action: 'Load', + args: { + model: 'LibraryWithFilters', args: { - model: 'LibraryWithFilters', - args: { - type_name: typeof urlParams.type === 'string' ? urlParams.type : null, - sort: queryParams.has('sort') ? queryParams.get('sort') : DEFAULT_SORT, - continue_watching: queryParams.get('cw') === '1' - } + type_name: typeof urlParams.type === 'string' ? urlParams.type : null, + sort: queryParams.has('sort') ? queryParams.get('sort') : 'lastwatched' } - }; - }, [urlParams, queryParams]); + } + }), [urlParams, queryParams]); return useModelState({ model: 'library', action: loadLibraryAction, map: mapLibraryState, - init: initLibraryState, - onNewState: onNewLibraryState + init: initLibraryState }); }; diff --git a/src/routes/Library/useSelectableInputs.js b/src/routes/Library/useSelectableInputs.js index a328ed1ff..6bea29673 100644 --- a/src/routes/Library/useSelectableInputs.js +++ b/src/routes/Library/useSelectableInputs.js @@ -17,15 +17,7 @@ const mapSelectableInputs = (library) => { .concat(library.type_names.map((type) => ({ label: type, value: JSON.stringify(type) }))), onSelect: (event) => { const type = JSON.parse(event.value); - const queryParams = new URLSearchParams( - library.selected !== null ? - [ - ['sort', library.selected.sort], - ['cw', library.selected.continue_watching ? '1' : '0'] - ] - : - [] - ); + const queryParams = new URLSearchParams(library.selected !== null ? [['sort', library.selected.sort]] : []); window.location.replace(`#/library${type !== null ? `/${encodeURIComponent(type)}` : ''}?${queryParams.toString()}`); } }; @@ -38,12 +30,7 @@ const mapSelectableInputs = (library) => { options: SORT_OPTIONS, onSelect: (event) => { const type = library.selected !== null ? library.selected.type_name : null; - const queryParams = new URLSearchParams( - [ - ['sort', event.value], - ['cw', library.selected !== null && library.selected.continue_watching ? '1' : '0'] - ] - ); + const queryParams = new URLSearchParams([['sort', event.value]]); window.location.replace(`#/library${type !== null ? `/${encodeURIComponent(type)}` : ''}?${queryParams.toString()}`); } };