Skip to content

Commit

Permalink
Fixes for the artist page and spotify metadata downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
nukeop committed Sep 11, 2024
1 parent 3b152f6 commit bae0c93
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 22 deletions.
10 changes: 6 additions & 4 deletions packages/app/app/components/ArtistView/PopularTracks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type AddAllButtonProps = {
t: TFunction;
}

const MAX_POPULAR_TRACKS_DISPLAYED = 15;

export const AddAllButton: React.FC<AddAllButtonProps> = ({
handleAddAll,
t
Expand Down Expand Up @@ -57,7 +59,7 @@ const PopularTracks: React.FC<PopularTracksProps> = ({
const toggleExpand = () => setExpanded(!expanded);
const handleAddAll = () => {
tracks
.slice(0, tracks.length > 15 ? 15 : tracks.length)
.slice(0, Math.min(tracks.length, MAX_POPULAR_TRACKS_DISPLAYED))
.forEach(track => {
addToQueue({
artist: artist.name,
Expand Down Expand Up @@ -85,15 +87,15 @@ const PopularTracks: React.FC<PopularTracksProps> = ({
handleAddAll={handleAddAll}
t={t}
/>
<div
<div
className={styles.popular_tracks_table_container}
style={{ height: expanded ? `calc(48px + (${tracks.length}*42px))` : undefined }}
style={{ height: expanded ? `calc(48px + (${Math.min(tracks.length, MAX_POPULAR_TRACKS_DISPLAYED)}*42px))` : undefined }}
>
<TrackTableContainer
tracks={
_(tracks)
.sortBy('playcount')
.takeRight(expanded ? 15 : 5)
.takeRight(expanded ? MAX_POPULAR_TRACKS_DISPLAYED : 5)
.value()
}
displayDeleteButton={false}
Expand Down
32 changes: 18 additions & 14 deletions packages/app/app/components/ArtistView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const ArtistView: React.FC<ArtistViewProps> = ({
const { t } = useTranslation('artist');
const isLoading = () => artist.loading || false;
const isOnTour = () => artist.onTour || false;
const areReleasesLoading = () => artist.releasesLoading || isLoading();
const onAlbumClick = (album) => {
albumInfoSearch(album.id, album.type, album);
history.push('/album/' + album.id);
Expand Down Expand Up @@ -109,20 +110,23 @@ const ArtistView: React.FC<ArtistViewProps> = ({
<hr />
</>
}
<ArtistAlbums
albums={artist?.releases ?? []}
onAlbumClick={onAlbumClick}
isLoading={isLoading()}
strings={{
header: t('artist-albums.header'),
sortByReleaseDate: t('artist-albums.sort-by-release-date'),
sortByAZ: t('artist-albums.sort-by-az'),
sortByMostPlayed: t('artist-albums.sort-by-most-played'),
filterPlaceholder: t('artist-albums.filter-placeholder')
}}
withSortByAZ
withSortByReleaseDate
/>
{
(areReleasesLoading() || artist.releases?.length > 0) &&
<ArtistAlbums
albums={artist?.releases ?? []}
onAlbumClick={onAlbumClick}
isLoading={areReleasesLoading()}
strings={{
header: t('artist-albums.header'),
sortByReleaseDate: t('artist-albums.sort-by-release-date'),
sortByAZ: t('artist-albums.sort-by-az'),
sortByMostPlayed: t('artist-albums.sort-by-most-played'),
filterPlaceholder: t('artist-albums.filter-placeholder')
}}
withSortByAZ
withSortByReleaseDate
/>
}
</Dimmer.Dimmable>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions packages/app/app/components/FavoriteTracksView/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
.header_container {
display: flex;
justify-content: space-between;
align-items: center;
}

.tracks_container {
Expand Down
9 changes: 7 additions & 2 deletions packages/app/app/reducers/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ import { YoutubeResult } from '@nuclear/core/src/rest/Youtube';
import { ActionType, getType } from 'typesafe-actions';
import { SearchActions } from '../actions/search';

export type ArtistDetailsState = Partial<ArtistDetails> & {loading?: boolean, error?: boolean, releases?: SearchResultsAlbum[],
releasesLoading?: boolean, releasesError?: boolean}
export type ArtistDetailsState = Partial<ArtistDetails> & {
loading?: boolean,
error?: boolean,
releases?: SearchResultsAlbum[],
releasesLoading?: boolean,
releasesError?: boolean
}

export type AlbumDetailsState = Partial<AlbumDetails> & {loading?: boolean, error?: boolean}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/rest/Spotify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class SpotifyClient {
let data: SpotifyPaginatedResponse<SpotifySimplifiedAlbum> = await this.get(`${SPOTIFY_API_URL}/artists/${id}/albums?include_groups=album`);
albums = data.items;

while (data.next) {
while (data.next && data.items?.length >= data.limit) {
const nextData: SpotifyPaginatedResponse<SpotifySimplifiedAlbum> = await this.get(data.next);
albums = [...albums, ...nextData.items];
data = nextData;
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/lib/components/AlbumGrid/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@
overflow-y: auto;
overflow-x: hidden;
}

.visible.dimmer {
padding: 8em 0;
}
}
1 change: 0 additions & 1 deletion packages/ui/lib/components/GridTrackTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ export const GridTrackTable = <T extends Track>({
{column.render('Header', extraProps)}
</div>))
}
<div data-testid='track-table-header-spacer' className={styles.track_table_header_spacer} />
</div>
))}
</div>
Expand Down

0 comments on commit bae0c93

Please sign in to comment.