Skip to content

Commit 9d01213

Browse files
committed
Chore fix: Remove index usage.
1 parent 2793333 commit 9d01213

File tree

6 files changed

+39
-40
lines changed

6 files changed

+39
-40
lines changed

frontend/src/api/interface.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
interface artist {
1+
interface Artist {
22
id: number
33
resource_url: string
44
name: string
@@ -8,7 +8,7 @@ interface artist {
88
tracks: string
99
}
1010

11-
interface label {
11+
interface Label {
1212
id: number
1313
resource_url: string
1414
name: string
@@ -17,32 +17,32 @@ interface label {
1717
entity_type_name: string
1818
}
1919

20-
interface format {
20+
interface Format {
2121
name: string
2222
qty: string
2323
descriptions: string[]
2424
}
2525

26-
interface committer {
26+
interface Committer {
2727
username: string
2828
resource_url: string
2929
}
3030

31-
interface identifiers {
31+
interface Identifiers {
3232
type: string
3333
value: string
3434
description: string
3535
}
3636

37-
interface videos {
37+
interface Videos {
3838
uri: string
3939
title: string
4040
description: string
4141
duration: number
4242
embed: boolean
4343
}
4444

45-
interface track {
45+
interface Track {
4646
title: string
4747
position: string
4848
type_: string
@@ -82,9 +82,9 @@ export interface IReleaseLight {
8282
cover_image: string
8383
title: string
8484
year: number
85-
formats: format[]
86-
artists: artist[]
87-
labels: label[]
85+
formats: Format[]
86+
artists: Artist[]
87+
labels: Label[]
8888
genres: string[]
8989
styles: string[]
9090
}
@@ -101,8 +101,8 @@ export interface IRelease extends IReleaseLight {
101101
count: number
102102
average: number
103103
}
104-
submitter: committer
105-
contributors: committer[]
104+
submitter: Committer
105+
contributors: Committer[]
106106
data_quality: string
107107
status: string
108108
}
@@ -115,10 +115,10 @@ export interface IRelease extends IReleaseLight {
115115
released: string
116116
notes: string
117117
released_formatted: string
118-
identifiers: identifiers[]
119-
videos: videos[]
120-
tracklist: track[]
121-
extraartists: artist[]
118+
identifiers: Identifiers[]
119+
videos: Videos[]
120+
tracklist: Track[]
121+
extraartists: Artist[]
122122
estimated_weight: number
123123
blocked_from_sale: boolean
124124
}

frontend/src/components/AlbumGrid.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import "./AlbumGrid.css"
66

77
interface AlbumProps {
88
album: IReleases
9-
index: number
109
onClickAlbum: (album: IReleases) => void
1110
}
1211

13-
const AlbumGridEntry: React.FC<AlbumProps> = ({ album, index, onClickAlbum }) => (
14-
<IonCol size="6" sizeMd="4" sizeLg="3" key={index}>
12+
const AlbumGridEntry: React.FC<AlbumProps> = ({ album, onClickAlbum }) => (
13+
<IonCol size="6" sizeMd="4" sizeLg="3" key={album.id}>
1514
<div className="album-art-container" onClick={() => onClickAlbum(album)}>
1615
<img
1716
src={album.image_base64 ? album.image_base64 : album.basic_information.thumb}
@@ -35,13 +34,13 @@ interface CollectionProps {
3534

3635
const AlbumGrid: React.FC<CollectionProps> = ({ data, onClickAlbum }) => (
3736
<>
38-
{data.map((options, index) => (
39-
<div key={index} className="album-art-div">
37+
{data.map((options) => (
38+
<div key={options[0]} className="album-art-div">
4039
<h2>{options[0]}</h2>
4140
<IonGrid>
4241
<IonRow>
43-
{options[1].map((album, index) => (
44-
<AlbumGridEntry key={index} album={album} index={index} onClickAlbum={onClickAlbum} />
42+
{options[1].map((album) => (
43+
<AlbumGridEntry key={album.id} album={album} onClickAlbum={onClickAlbum} />
4544
))}
4645
</IonRow>
4746
</IonGrid>

frontend/src/components/AlbumList.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ export const AlbumListGroups: React.FC<{
4040
onClickAlbum: (album: IReleases) => void
4141
}> = ({ data, onClickAlbum }) => (
4242
<>
43-
{data.map((options, index) => (
44-
<IonItemGroup key={index}>
43+
{data.map((options) => (
44+
<IonItemGroup key={options[0]}>
4545
<IonItemDivider>
4646
<IonLabel>{options[0]}</IonLabel>
4747
</IonItemDivider>
48-
{options[1].map((album, index) => (
49-
<AlbumListItem key={index} album={album} onClickAlbum={onClickAlbum} />
48+
{options[1].map((album) => (
49+
<AlbumListItem key={album.id} album={album} onClickAlbum={onClickAlbum} />
5050
))}
5151
</IonItemGroup>
5252
))}
@@ -64,8 +64,8 @@ export const AlbumList: React.FC<{
6464
<IonLabel>{title}</IonLabel>
6565
</IonListHeader>
6666
)}
67-
{data.map((album, index) => (
68-
<AlbumListItem key={index} album={album} onClickAlbum={onClickAlbum} />
67+
{data.map((album) => (
68+
<AlbumListItem key={album.id} album={album} onClickAlbum={onClickAlbum} />
6969
))}
7070
</IonList>
7171
)

frontend/src/components/StatDisplay.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ interface Props {
99
const StatDisplay: React.FC<Props> = ({ items }) => (
1010
<IonGrid>
1111
<IonRow>
12-
{items.map((stat, index) => (
13-
<IonCol key={index} className="statdisp-text">
12+
{items.map((stat) => (
13+
<IonCol key={`${stat.label}${stat.value}`} className="statdisp-text">
1414
<IonIcon icon={stat.icon} style={{ fontSize: "48px", color: "#3880ff" }} />
1515
<IonText style={{ textAlign: "center" }}>
1616
<h2 style={{ margin: 4 }}>{stat.value ?? "N/A"}</h2>

frontend/src/modal/ViewAlbumDetails.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ const ViewAlbumDetails: React.FC<DisplayProps> = ({ album, open, onClose }) => {
191191

192192
{isSuccess && tabState === TabSet.Tracks && (
193193
<IonList inset>
194-
{data.tracklist.map((track, index) => (
195-
<IonItem key={index}>
194+
{data.tracklist.map((track) => (
195+
<IonItem key={track.position}>
196196
<IonNote slot="start">{track.position}</IonNote>
197197
<IonLabel>{track.title}</IonLabel>
198198
<IonNote slot="end">{track.duration}</IonNote>
@@ -202,8 +202,8 @@ const ViewAlbumDetails: React.FC<DisplayProps> = ({ album, open, onClose }) => {
202202
)}
203203
{isSuccess && tabState === TabSet.Credits && (
204204
<IonList inset>
205-
{data.extraartists.map((artist, index) => (
206-
<IonItem key={index}>
205+
{data.extraartists.map((artist) => (
206+
<IonItem key={artist.id}>
207207
<IonLabel>
208208
<h2>{artist.name}</h2>
209209
<p>{artist.role}</p>
@@ -228,8 +228,8 @@ const ViewAlbumDetails: React.FC<DisplayProps> = ({ album, open, onClose }) => {
228228
)}
229229
{isSuccess && tabState === TabSet.IDs && (
230230
<IonList inset>
231-
{data.identifiers.map((id, index) => (
232-
<IonItem key={index}>
231+
{data.identifiers.map((id) => (
232+
<IonItem key={`${id.type}${id.value}`}>
233233
<IonLabel>
234234
<h2>
235235
{id.type} {id.description}

frontend/src/utils/collectionSort.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ export const splitRecordsByLabel = (records: IReleases[]): IReleaseTuple => {
5858

5959
export const masterSort = (sort: "release" | "label" | "artist" | "none", records: IReleases[]): IReleaseTuple => {
6060
switch (sort) {
61-
default:
62-
case "none":
63-
return [["", records]]
6461
case "release":
6562
return splitRecordsByYear(records)
6663
case "label":
6764
return splitRecordsByLabel(records)
6865
case "artist":
6966
return splitRecordsByArtist(records)
67+
case "none":
68+
default:
69+
return [["", records]]
7070
}
7171
}

0 commit comments

Comments
 (0)