Restore previous content type when clearing search (#742)
After clearing the current search the initial content type was always restored instead of the previous selected content type
This commit is contained in:
@@ -246,14 +246,19 @@ export function SourceMangas() {
|
|||||||
);
|
);
|
||||||
const [dialogFiltersToApply, setDialogFiltersToApply] = useState<IPos[]>(filtersToApply);
|
const [dialogFiltersToApply, setDialogFiltersToApply] = useState<IPos[]>(filtersToApply);
|
||||||
const [resetScrollPosition, setResetScrollPosition] = useState(false);
|
const [resetScrollPosition, setResetScrollPosition] = useState(false);
|
||||||
const [contentType, setContentType] = useSessionStorage(
|
const [currentContentType, setCurrentContentType] = useSessionStorage<SourceContentType | undefined>(
|
||||||
|
`source-mangas-${sourceId}-content-type`,
|
||||||
|
initialContentType,
|
||||||
|
);
|
||||||
|
const [contentType, setLocationContentType] = useSessionStorage(
|
||||||
`source-mangas-location-${locationKey}-${sourceId}-content-type`,
|
`source-mangas-location-${locationKey}-${sourceId}-content-type`,
|
||||||
query ? SourceContentType.SEARCH : initialContentType,
|
query ? SourceContentType.SEARCH : currentContentType!,
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => () => {
|
() => () => {
|
||||||
setCurrentFiltersToApply(undefined);
|
setCurrentFiltersToApply(undefined);
|
||||||
|
setCurrentContentType(undefined);
|
||||||
},
|
},
|
||||||
[sourceId],
|
[sourceId],
|
||||||
);
|
);
|
||||||
@@ -263,6 +268,11 @@ export function SourceMangas() {
|
|||||||
setLocationFiltersToApply(filters);
|
setLocationFiltersToApply(filters);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const setContentType = (newContentType: SourceContentType) => {
|
||||||
|
setCurrentContentType(newContentType);
|
||||||
|
setLocationContentType(newContentType);
|
||||||
|
};
|
||||||
|
|
||||||
const [loadPage, { data, isLoading: loading, size: lastPageNum, abortRequest, filteredOutAllItemsOfFetchedPage }] =
|
const [loadPage, { data, isLoading: loading, size: lastPageNum, abortRequest, filteredOutAllItemsOfFetchedPage }] =
|
||||||
useSourceManga(sourceId, contentType, query, filtersToApply, 1, hideLibraryEntries);
|
useSourceManga(sourceId, contentType, query, filtersToApply, 1, hideLibraryEntries);
|
||||||
const isLoading = loading || filteredOutAllItemsOfFetchedPage;
|
const isLoading = loading || filteredOutAllItemsOfFetchedPage;
|
||||||
|
|||||||
Reference in New Issue
Block a user