Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Added the extra filter option for Watched #583

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"workbench.colorCustomizations": {
"commandCenter.border": "#e7e7e799",
"sash.hoverBorder": "#ab307e",
"statusBar.background": "#832561",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#ab307e",
"statusBarItem.remoteBackground": "#832561",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#832561",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#83256199",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.color": "#832561"
}
25 changes: 18 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@babel/runtime": "7.16.0",
"@sentry/browser": "6.13.3",
"@stremio/stremio-colors": "5.0.1",
"@stremio/stremio-core-web": "0.46.3",
"@stremio/stremio-core-web": "file:../stremio-core-web",
"@stremio/stremio-icons": "5.2.0",
"@stremio/stremio-video": "0.0.33",
"a-color-picker": "1.2.1",
Expand Down
4 changes: 3 additions & 1 deletion src/routes/Library/Library.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Library = ({ model, urlParams, queryParams }) => {
const profile = useProfile();
const notifications = useNotifications();
const library = useLibrary(model, urlParams, queryParams);
const [typeSelect, sortSelect, paginationInput] = useSelectableInputs(library);
const [typeSelect, sortSelect,stateSelect, paginationInput] = useSelectableInputs(library);
const [inputsModalOpen, openInputsModal, closeInputsModal] = useBinaryState(false);
return (
<MainNavBars className={styles['library-container']} route={model}>
Expand All @@ -57,6 +57,7 @@ const Library = ({ model, urlParams, queryParams }) => {
<div className={styles['selectable-inputs-container']}>
<Multiselect {...typeSelect} className={styles['select-input-container']} />
<Multiselect {...sortSelect} className={styles['select-input-container']} />
<Multiselect {...stateSelect} className={styles['select-input-container']} />
<div className={styles['spacing']} />
{
paginationInput !== null ?
Expand Down Expand Up @@ -119,6 +120,7 @@ const Library = ({ model, urlParams, queryParams }) => {
<ModalDialog title={'Library filters'} className={styles['selectable-inputs-modal']} onCloseRequest={closeInputsModal}>
<Multiselect {...typeSelect} className={styles['select-input-container']} />
<Multiselect {...sortSelect} className={styles['select-input-container']} />
<Multiselect {...stateSelect} className={styles['select-input-container']} />
</ModalDialog>
:
null
Expand Down
1 change: 1 addition & 0 deletions src/routes/Library/useLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const useLibrary = (model, urlParams, queryParams) => {
request: {
type: typeof urlParams.type === 'string' ? urlParams.type : null,
sort: queryParams.has('sort') ? queryParams.get('sort') : undefined,
filter: queryParams.has('filter') ? queryParams.get('filter') : undefined,
page: queryParams.has('page') ? parseInt(queryParams.get('page'), 10) : undefined
}
}
Expand Down
17 changes: 16 additions & 1 deletion src/routes/Library/useSelectableInputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ const mapSelectableInputs = (library, t) => {
window.location = event.value;
}
};
const stateSelect = {
title: t.string('SELECT_FILTER'),
options: library.selectable.filters
.map(({ watched, deepLinks }) => ({
value: deepLinks.library,
label: t.stringWithPrefix(watched.toUpperCase(), 'FILTER_')
})),
selected: library.selectable.filters
.filter(({ selected }) => selected)
.map(({ deepLinks }) => deepLinks.library),
onSelect: (event) => {
window.location = event.value;
}
};

const paginationInput = library.selectable.prevPage || library.selectable.nextPage ?
{
label: library.selected.request.page.toString(),
Expand All @@ -46,7 +61,7 @@ const mapSelectableInputs = (library, t) => {
}
:
null;
return [typeSelect, sortSelect, paginationInput];
return [typeSelect, sortSelect,stateSelect, paginationInput];
};

const useSelectableInputs = (library) => {
Expand Down
7 changes: 7 additions & 0 deletions src/types/Selectable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ type SelectableSort<T> = {
deepLinks: T
};

type SelectableFilter<T> = {
filter: string,
selected: boolean,
deepLinks: T
};


type SelectableExtra<T> = {
isRequired: boolean,
name: string,
Expand Down
2 changes: 2 additions & 0 deletions src/types/models/Library.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ type Library = {
nextPage: LibraryPage,
prevPage: LibraryPage,
sorts: SelectableSort<LibraryDeepLinks>[],
filters: SelectableFilter<LibraryDeepLinks>[],
types: SelectableType<LibraryDeepLinks>[],
},
selected: {
request: {
page: number,
sort: string,
filter: string,
type: string | null,
}
} | null,
Expand Down