File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed
Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 11<script lang =" ts" >
2- import type { SongAPI } from " $lib/api/api" ;
2+ import { SongAPI } from " $lib/api/api" ;
33 import ArtistList from " $lib/comp/ArtistList.svelte" ;
44 import PageContainer from " $lib/comp/PageContainer.svelte" ;
55 import SongList from " $lib/comp/SongList.svelte" ;
66 import LinkButton from " $lib/LinkButton.svelte" ;
7- import type { Stats } from " $lib/stats" ;
7+ import type { Stats , StatsViewConfig } from " $lib/stats" ;
88
9+ export let config: StatsViewConfig ;
910 export let stats: Stats ;
1011 export let api: SongAPI ;
1112
6364
6465 {#snippet pageFavSongsAllTime ()}
6566 <h1 >Your favorite songs of all time</h1 >
66- <SongList songs ={stats .data .songs .slice (0 , 4 )} api ={api } />
67+ <SongList songs ={stats .data .songs .slice (0 , config . songRankCount )} api ={api } />
6768 {/ snippet }
6869
6970 {#snippet pageFavArtistsAllTime ()}
7071 <h1 >Your favorite artists of all time</h1 >
71- <ArtistList artists ={stats .getArtists (true ).slice (0 , 3 )} />
72+ <ArtistList artists ={stats .getArtists (true ).slice (0 , config . artistRankCount )} />
7273 {/ snippet }
7374
7475 {#snippet pageEnd ()}
Original file line number Diff line number Diff line change 11
2+ export type StatsViewConfig = {
3+ songRankCount : number ,
4+ artistRankCount : number
5+ }
6+
27export type StatsData = {
38 formatVersion : number ,
49 songs : SongData [ ]
Original file line number Diff line number Diff line change 11<script lang =" ts" >
2- import type { Stats , StatsData } from " $lib/stats" ;
2+ import type { Stats , StatsData , StatsViewConfig } from " $lib/stats" ;
33
44 import Home from " $lib/layout/Home.svelte" ;
55 import Page from " $lib/comp/Page.svelte" ;
1111 let currentStats: Stats | null = null ;
1212 let statsProcessed = false ;
1313
14+ const config: StatsViewConfig = {
15+ songRankCount: 4 ,
16+ artistRankCount: 3
17+ };
18+
1419 async function setStats(stats : Stats | null ) {
1520 currentStats = stats ;
1621 statsProcessed = false ;
1722
1823 if (stats ) {
1924 // Load API data to cache
2025
21- for (const song of stats .data .songs ) {
26+ for (const song of stats .data .songs . slice ( config . songRankCount ) ) {
2227 const artist = await api .queryArtistByName (song .artist );
2328 await api .querySongByName (song .title , artist ?.id );
2429 }
3338 <StatsView
3439 stats ={currentStats }
3540 api ={api }
41+ config ={config }
3642 onClose ={() => setStats (null )}
3743 />
3844 {:else if currentStats && ! statsProcessed }
You can’t perform that action at this time.
0 commit comments