mirror of https://github.com/stashapp/stash.git
Lint + prettier
This commit is contained in:
parent
960d5c7000
commit
857b2cc78d
|
@ -3,7 +3,7 @@ import { FormattedMessage } from "react-intl";
|
|||
import { Nav, Navbar, Button } from "react-bootstrap";
|
||||
import { IconName } from "@fortawesome/fontawesome-svg-core";
|
||||
import { LinkContainer } from "react-router-bootstrap";
|
||||
import { NavLink, Link, useLocation } from "react-router-dom";
|
||||
import { Link, useLocation } from "react-router-dom";
|
||||
|
||||
import { Icon } from "src/components/Shared";
|
||||
|
||||
|
@ -67,7 +67,14 @@ export const MainNavbar: React.FC = () => {
|
|||
);
|
||||
|
||||
return (
|
||||
<Navbar collapseOnSelect fixed="top" variant="dark" bg="dark" className="top-nav" expand="sm">
|
||||
<Navbar
|
||||
collapseOnSelect
|
||||
fixed="top"
|
||||
variant="dark"
|
||||
bg="dark"
|
||||
className="top-nav"
|
||||
expand="sm"
|
||||
>
|
||||
<Navbar.Brand as="div" className="order-1 order-sm-0">
|
||||
<Link to="/">
|
||||
<Button className="minimal brand-link d-none d-sm-inline-block">
|
||||
|
|
|
@ -96,25 +96,26 @@ const useList = <QueryResult extends IQueryResult, QueryData extends IDataItem>(
|
|||
const totalCount = options.getCount(result);
|
||||
const items = options.getData(result);
|
||||
|
||||
const updateInterfaceConfig = useCallback((updatedFilter: ListFilterModel) => {
|
||||
setInterfaceState(config => {
|
||||
const data = { ...config } as IInterfaceConfig;
|
||||
data.queries = {
|
||||
[options.filterMode]: {
|
||||
filter: updatedFilter.makeQueryParameters(),
|
||||
itemsPerPage: updatedFilter.itemsPerPage,
|
||||
currentPage: updatedFilter.currentPage
|
||||
}
|
||||
};
|
||||
return data;
|
||||
});
|
||||
}, [options.filterMode, setInterfaceState]);
|
||||
const updateInterfaceConfig = useCallback(
|
||||
(updatedFilter: ListFilterModel) => {
|
||||
setInterfaceState(config => {
|
||||
const data = { ...config } as IInterfaceConfig;
|
||||
data.queries = {
|
||||
[options.filterMode]: {
|
||||
filter: updatedFilter.makeQueryParameters(),
|
||||
itemsPerPage: updatedFilter.itemsPerPage,
|
||||
currentPage: updatedFilter.currentPage
|
||||
}
|
||||
};
|
||||
return data;
|
||||
});
|
||||
},
|
||||
[options.filterMode, setInterfaceState]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if(interfaceState.loading)
|
||||
return;
|
||||
if(!forageInitialised)
|
||||
setForageInitialised(true);
|
||||
if (interfaceState.loading) return;
|
||||
if (!forageInitialised) setForageInitialised(true);
|
||||
|
||||
// Don't use query parameters for sub-components
|
||||
if (options.subComponent) return;
|
||||
|
@ -124,29 +125,28 @@ const useList = <QueryResult extends IQueryResult, QueryData extends IDataItem>(
|
|||
|
||||
const queryFilter = queryString.parse(history.location.search);
|
||||
const storedFilter = queryString.parse(storedQuery.filter);
|
||||
const query = history.location.search ? {
|
||||
sortby: storedFilter.sortby,
|
||||
sortdir: storedFilter.sortdir,
|
||||
disp: storedFilter.disp,
|
||||
perPage: storedFilter.perPage,
|
||||
...queryFilter
|
||||
} : storedFilter;
|
||||
const query = history.location.search
|
||||
? {
|
||||
sortby: storedFilter.sortby,
|
||||
sortdir: storedFilter.sortdir,
|
||||
disp: storedFilter.disp,
|
||||
perPage: storedFilter.perPage,
|
||||
...queryFilter
|
||||
}
|
||||
: storedFilter;
|
||||
|
||||
const newFilter = new ListFilterModel(
|
||||
options.filterMode,
|
||||
query
|
||||
);
|
||||
const newFilter = new ListFilterModel(options.filterMode, query);
|
||||
|
||||
// Compare constructed filter with current filter.
|
||||
// If different it's the result of navigation, and we update the filter.
|
||||
const newLocation = { ...history.location };
|
||||
newLocation.search = newFilter.makeQueryParameters();
|
||||
if(newLocation.search !== filter.makeQueryParameters()) {
|
||||
if (newLocation.search !== filter.makeQueryParameters()) {
|
||||
setFilter(newFilter);
|
||||
updateInterfaceConfig(newFilter);
|
||||
}
|
||||
// If constructed search is different from current, update it as well
|
||||
if(newLocation.search !== location.search) {
|
||||
if (newLocation.search !== location.search) {
|
||||
newLocation.search = newFilter.makeQueryParameters();
|
||||
history.replace(newLocation);
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ const useList = <QueryResult extends IQueryResult, QueryData extends IDataItem>(
|
|||
|
||||
function updateQueryParams(listFilter: ListFilterModel) {
|
||||
setFilter(listFilter);
|
||||
if(!options.subComponent) {
|
||||
if (!options.subComponent) {
|
||||
const newLocation = { ...location };
|
||||
newLocation.search = listFilter.makeQueryParameters();
|
||||
history.replace(newLocation);
|
||||
|
|
Loading…
Reference in New Issue