File tree Expand file tree Collapse file tree 2 files changed +20
-19
lines changed
lib/shared/components/now-playing Expand file tree Collapse file tree 2 files changed +20
-19
lines changed Original file line number Diff line number Diff line change 5353 </style >
5454
5555<script lang =" ts" >
56- import { onDestroy , onMount } from ' svelte' ;
5756 import { nowPlayingSong } from ' $stores' ;
58- import ExternalLink from ' $lib/shared/ui/components/external-link/ExternalLink.svelte' ;
59-
60- let clearSetTimeout: NodeJS .Timeout ;
61- const getCurrentlyPlayingSong = (): void => {
62- fetch (` /api/now-playing.json ` )
63- .then ((res ) => res .json ())
64- .then ((response ) => nowPlayingSong .set (response ));
65-
66- clearSetTimeout = setTimeout (getCurrentlyPlayingSong , 120000 );
67- };
68- onMount (async () => {
69- getCurrentlyPlayingSong ();
70- });
71-
72- onDestroy (() => {
73- clearTimeout (clearSetTimeout );
74- });
57+ import ExternalLink from ' $ui/components/external-link/ExternalLink.svelte' ;
7558 </script >
7659
7760<div class =" flex flex-row-reverse sm:flex-row mb-8 space-x-0 sm:space-x-2 w-full" >
Original file line number Diff line number Diff line change 11<script lang =" ts" >
22 // Start: Local Imports
33
4+ import { onDestroy , onMount } from ' svelte' ;
5+ import { nowPlayingSong } from ' $stores' ;
46 // Start: External Imports
5-
7+ import ' ../styles/tailwind.postcss ' ;
68
79 // End: External Imports
810
5860 htmlTag .className = event .detail .dark ? ' dark' : ' light' ;
5961 };
6062
63+ let clearSetTimeout: NodeJS .Timeout ;
64+ const getCurrentlyPlayingSong = (): void => {
65+ fetch (` /api/now-playing.json ` )
66+ .then ((res ) => res .json ())
67+ .then ((response ) => nowPlayingSong .set (response ));
68+
69+ clearSetTimeout = setTimeout (getCurrentlyPlayingSong , 120000 );
70+ };
71+ onMount (async () => {
72+ getCurrentlyPlayingSong ();
73+ });
74+
75+ onDestroy (() => {
76+ clearTimeout (clearSetTimeout );
77+ });
78+
6179 // End: Local component methods
6280 </script >
6381
You can’t perform that action at this time.
0 commit comments