Skip to content

Commit efe0a3d

Browse files
markus101mynameisbogdan
authored andcommittedFeb 6, 2024
Typings cleanup and improvements
Appease linter (cherry picked from commit b2c43fb2a67965d68d3d35b72302b0cddb5aca23) (cherry picked from commit 3b5e83670b844cf7c20bf7d744d9fbc96fde6902) Closes #3516 Closes #3510 Closes #2778
1 parent 8e5942d commit efe0a3d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+420
-269
lines changed
 

‎frontend/src/Artist/Index/ArtistIndex.tsx

+19-12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import React, {
77
} from 'react';
88
import { useDispatch, useSelector } from 'react-redux';
99
import { SelectProvider } from 'App/SelectContext';
10+
import ArtistAppState, { ArtistIndexAppState } from 'App/State/ArtistAppState';
11+
import ClientSideCollectionAppState from 'App/State/ClientSideCollectionAppState';
1012
import NoArtist from 'Artist/NoArtist';
1113
import { RSS_SYNC } from 'Commands/commandNames';
1214
import LoadingIndicator from 'Components/Loading/LoadingIndicator';
@@ -89,16 +91,19 @@ const ArtistIndex = withScrollPosition((props: ArtistIndexProps) => {
8991
sortKey,
9092
sortDirection,
9193
view,
92-
} = useSelector(createArtistClientSideCollectionItemsSelector('artistIndex'));
94+
}: ArtistAppState & ArtistIndexAppState & ClientSideCollectionAppState =
95+
useSelector(createArtistClientSideCollectionItemsSelector('artistIndex'));
9396

9497
const isRssSyncExecuting = useSelector(
9598
createCommandExecutingSelector(RSS_SYNC)
9699
);
97100
const { isSmallScreen } = useSelector(createDimensionsSelector());
98101
const dispatch = useDispatch();
99-
const scrollerRef = useRef<HTMLDivElement>();
102+
const scrollerRef = useRef<HTMLDivElement>(null);
100103
const [isOptionsModalOpen, setIsOptionsModalOpen] = useState(false);
101-
const [jumpToCharacter, setJumpToCharacter] = useState<string | null>(null);
104+
const [jumpToCharacter, setJumpToCharacter] = useState<string | undefined>(
105+
undefined
106+
);
102107
const [isSelectMode, setIsSelectMode] = useState(false);
103108

104109
useEffect(() => {
@@ -118,14 +123,14 @@ const ArtistIndex = withScrollPosition((props: ArtistIndexProps) => {
118123
}, [isSelectMode, setIsSelectMode]);
119124

120125
const onTableOptionChange = useCallback(
121-
(payload) => {
126+
(payload: unknown) => {
122127
dispatch(setArtistTableOption(payload));
123128
},
124129
[dispatch]
125130
);
126131

127132
const onViewSelect = useCallback(
128-
(value) => {
133+
(value: string) => {
129134
dispatch(setArtistView({ view: value }));
130135

131136
if (scrollerRef.current) {
@@ -136,14 +141,14 @@ const ArtistIndex = withScrollPosition((props: ArtistIndexProps) => {
136141
);
137142

138143
const onSortSelect = useCallback(
139-
(value) => {
144+
(value: string) => {
140145
dispatch(setArtistSort({ sortKey: value }));
141146
},
142147
[dispatch]
143148
);
144149

145150
const onFilterSelect = useCallback(
146-
(value) => {
151+
(value: string) => {
147152
dispatch(setArtistFilter({ selectedFilterKey: value }));
148153
},
149154
[dispatch]
@@ -158,15 +163,15 @@ const ArtistIndex = withScrollPosition((props: ArtistIndexProps) => {
158163
}, [setIsOptionsModalOpen]);
159164

160165
const onJumpBarItemPress = useCallback(
161-
(character) => {
166+
(character: string) => {
162167
setJumpToCharacter(character);
163168
},
164169
[setJumpToCharacter]
165170
);
166171

167172
const onScroll = useCallback(
168-
({ scrollTop }) => {
169-
setJumpToCharacter(null);
173+
({ scrollTop }: { scrollTop: number }) => {
174+
setJumpToCharacter(undefined);
170175
scrollPositions.artistIndex = scrollTop;
171176
},
172177
[setJumpToCharacter]
@@ -180,10 +185,10 @@ const ArtistIndex = withScrollPosition((props: ArtistIndexProps) => {
180185
};
181186
}
182187

183-
const characters = items.reduce((acc, item) => {
188+
const characters = items.reduce((acc: Record<string, number>, item) => {
184189
let char = item.sortName.charAt(0);
185190

186-
if (!isNaN(char)) {
191+
if (!isNaN(Number(char))) {
187192
char = '#';
188193
}
189194

@@ -300,6 +305,8 @@ const ArtistIndex = withScrollPosition((props: ArtistIndexProps) => {
300305
<PageContentBody
301306
ref={scrollerRef}
302307
className={styles.contentBody}
308+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
309+
// @ts-ignore
303310
innerClassName={styles[`${view}InnerContentBody`]}
304311
initialScrollTop={props.initialScrollTop}
305312
onScroll={onScroll}

‎frontend/src/Artist/Index/ArtistIndexFilterModal.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,29 @@ function createFilterBuilderPropsSelector() {
2323
);
2424
}
2525

26-
export default function ArtistIndexFilterModal(props) {
26+
interface ArtistIndexFilterModalProps {
27+
isOpen: boolean;
28+
}
29+
30+
export default function ArtistIndexFilterModal(
31+
props: ArtistIndexFilterModalProps
32+
) {
2733
const sectionItems = useSelector(createArtistSelector());
2834
const filterBuilderProps = useSelector(createFilterBuilderPropsSelector());
2935
const customFilterType = 'artist';
3036

3137
const dispatch = useDispatch();
3238

3339
const dispatchSetFilter = useCallback(
34-
(payload) => {
40+
(payload: unknown) => {
3541
dispatch(setArtistFilter(payload));
3642
},
3743
[dispatch]
3844
);
3945

4046
return (
4147
<FilterModal
48+
// TODO: Don't spread all the props
4249
{...props}
4350
sectionItems={sectionItems}
4451
filterBuilderProps={filterBuilderProps}

0 commit comments

Comments
 (0)
Please sign in to comment.