mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-05 20:42:19 -07:00
Appease linter (cherry picked from commit b2c43fb2a67965d68d3d35b72302b0cddb5aca23) (cherry picked from commit 3b5e83670b844cf7c20bf7d744d9fbc96fde6902) Closes #3516 Closes #3510 Closes #2778
31 lines
817 B
TypeScript
31 lines
817 B
TypeScript
import React from 'react';
|
|
import { RouteComponentProps } from 'react-router-dom';
|
|
import scrollPositions from 'Store/scrollPositions';
|
|
|
|
interface WrappedComponentProps {
|
|
initialScrollTop: number;
|
|
}
|
|
|
|
interface ScrollPositionProps {
|
|
history: RouteComponentProps['history'];
|
|
location: RouteComponentProps['location'];
|
|
match: RouteComponentProps['match'];
|
|
}
|
|
|
|
function withScrollPosition(
|
|
WrappedComponent: React.FC<WrappedComponentProps>,
|
|
scrollPositionKey: string
|
|
) {
|
|
function ScrollPosition(props: ScrollPositionProps) {
|
|
const { history } = props;
|
|
|
|
const initialScrollTop =
|
|
history.action === 'POP' ? scrollPositions[scrollPositionKey] : 0;
|
|
|
|
return <WrappedComponent {...props} initialScrollTop={initialScrollTop} />;
|
|
}
|
|
|
|
return ScrollPosition;
|
|
}
|
|
|
|
export default withScrollPosition;
|