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