John Bednarczyk 1 month ago committed by GitHub
commit 98463826b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -53,7 +53,8 @@ class CollectionOverviews extends Component {
columnCount: 1, columnCount: 1,
posterWidth: 162, posterWidth: 162,
posterHeight: 238, posterHeight: 238,
rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {}) rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {}),
navigateToId: props.location.state?.navigateToId ?? 0
}; };
this._grid = null; this._grid = null;
@ -72,7 +73,8 @@ class CollectionOverviews extends Component {
const { const {
width, width,
rowHeight, rowHeight,
scrollRestored scrollRestored,
navigateToId
} = this.state; } = this.state;
if (prevProps.sortKey !== sortKey || if (prevProps.sortKey !== sortKey ||
@ -106,6 +108,10 @@ class CollectionOverviews extends Component {
}); });
} }
} }
if (navigateToId) {
this.scrollToItem(navigateToId);
}
} }
// //
@ -186,6 +192,25 @@ class CollectionOverviews extends Component {
); );
}; };
scrollToItem = (itemId) => {
const index = this.props.items.findIndex((item) => item.tmdbId === itemId);
if (index !== -1 && this._grid) {
this._grid.scrollToCell({
columnIndex: 0,
rowIndex: index,
align: 'start'
});
}
// Replacing the history to prevent navigating back to this item on re-renders
window.history.replaceState({}, '');
this.setState({
navigateToId: 0
});
};
// //
// Listeners // Listeners
@ -265,7 +290,8 @@ CollectionOverviews.propTypes = {
isSmallScreen: PropTypes.bool.isRequired, isSmallScreen: PropTypes.bool.isRequired,
timeFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired,
selectedState: PropTypes.object.isRequired, selectedState: PropTypes.object.isRequired,
onSelectedChange: PropTypes.func.isRequired onSelectedChange: PropTypes.func.isRequired,
location: PropTypes.object.isRequired
}; };
export default CollectionOverviews; export default CollectionOverviews;

@ -8,17 +8,13 @@ import React, {
import { Link as RouterLink } from 'react-router-dom'; import { Link as RouterLink } from 'react-router-dom';
import styles from './Link.css'; import styles from './Link.css';
interface ReactRouterLinkProps {
to?: string;
}
export interface LinkProps extends React.HTMLProps<HTMLAnchorElement> { export interface LinkProps extends React.HTMLProps<HTMLAnchorElement> {
className?: string; className?: string;
component?: component?:
| string | string
| FunctionComponent<LinkProps> | FunctionComponent<LinkProps>
| ComponentClass<LinkProps, unknown>; | ComponentClass<LinkProps, unknown>;
to?: string; to?: string | { pathname: string; state?: object };
target?: string; target?: string;
isDisabled?: boolean; isDisabled?: boolean;
noRouter?: boolean; noRouter?: boolean;
@ -46,26 +42,38 @@ function Link(props: LinkProps) {
[isDisabled, onPress] [isDisabled, onPress]
); );
const linkProps: React.HTMLProps<HTMLAnchorElement> & ReactRouterLinkProps = { const linkProps: React.HTMLProps<HTMLAnchorElement> & LinkProps = {
target, target,
}; };
let el = component; let el = component;
if (to) { if (to) {
if (/\w+?:\/\//.test(to)) { if (typeof to === 'string') {
el = 'a'; if (/\w+?:\/\//.test(to)) {
linkProps.href = to; el = 'a';
linkProps.target = target || '_blank'; linkProps.href = to;
linkProps.rel = 'noreferrer'; linkProps.target = target || '_blank';
} else if (noRouter) { linkProps.rel = 'noreferrer';
el = 'a'; } else if (noRouter) {
linkProps.href = to; el = 'a';
linkProps.target = target || '_self'; linkProps.href = to;
linkProps.target = target || '_self';
} else {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
el = RouterLink;
linkProps.to = `${window.Radarr.urlBase}/${to.replace(/^\//, '')}`;
linkProps.target = target;
}
} else { } else {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore // @ts-ignore
el = RouterLink; el = RouterLink;
linkProps.to = `${window.Radarr.urlBase}/${to.replace(/^\//, '')}`; const url = `${window.Radarr.urlBase}/${to.pathname.replace(/^\//, '')}`;
linkProps.to = {
pathname: url,
...(to.state && { state: to.state }),
};
linkProps.target = target; linkProps.target = target;
} }
} }

@ -7,3 +7,7 @@
color: var(--iconButtonHoverLightColor); color: var(--iconButtonHoverLightColor);
} }
} }
.titleLink {
color: inherit;
}

@ -2,6 +2,7 @@
// Please do not change this file! // Please do not change this file!
interface CssExports { interface CssExports {
'monitorToggleButton': string; 'monitorToggleButton': string;
'titleLink': string;
} }
export const cssExports: CssExports; export const cssExports: CssExports;
export default cssExports; export default cssExports;

@ -1,5 +1,6 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import Link from 'Components/Link/Link';
import MonitorToggleButton from 'Components/MonitorToggleButton'; import MonitorToggleButton from 'Components/MonitorToggleButton';
import styles from './MovieCollectionLabel.css'; import styles from './MovieCollectionLabel.css';
@ -18,6 +19,7 @@ class MovieCollectionLabel extends Component {
render() { render() {
const { const {
tmdbId,
title, title,
monitored, monitored,
onMonitorTogglePress onMonitorTogglePress
@ -31,7 +33,15 @@ class MovieCollectionLabel extends Component {
size={15} size={15}
onPress={onMonitorTogglePress} onPress={onMonitorTogglePress}
/> />
{title} <Link
to={{
pathname: '/collections',
state: { navigateToId: tmdbId }
}}
className={styles.titleLink}
>
{title}
</Link>
</div> </div>
); );
} }
@ -40,7 +50,8 @@ class MovieCollectionLabel extends Component {
MovieCollectionLabel.propTypes = { MovieCollectionLabel.propTypes = {
title: PropTypes.string.isRequired, title: PropTypes.string.isRequired,
monitored: PropTypes.bool.isRequired, monitored: PropTypes.bool.isRequired,
onMonitorTogglePress: PropTypes.func.isRequired onMonitorTogglePress: PropTypes.func.isRequired,
tmdbId: PropTypes.number.isRequired
}; };
export default MovieCollectionLabel; export default MovieCollectionLabel;

@ -9,11 +9,13 @@ function createUnoptimizedSelector(uiSection) {
const items = movies.items.map((s) => { const items = movies.items.map((s) => {
const { const {
id, id,
tmdbId,
sortTitle sortTitle
} = s; } = s;
return { return {
id, id,
tmdbId,
sortTitle sortTitle
}; };
}); });

Loading…
Cancel
Save