@@ -5,6 +5,7 @@ import { route } from 'preact-router';
55import { useContext , useEffect , useState } from 'preact/hooks' ;
66import AppContext from '../../contexts/appContext' ;
77import { useNavKeys } from '../../hooks/useNavKeys' ;
8+ import { useShortcutKeys } from '../../hooks/useShortcutKeys' ;
89import * as style from './style.css' ;
910
1011const episodeService = new EpisodeService ( ) ;
@@ -15,6 +16,7 @@ interface FilterProps {
1516
1617function Filter ( { filterId } : FilterProps ) {
1718 const [ episodes , setEpisodes ] = useState < EpisodeExtended [ ] > ( [ ] ) ;
19+ const [ loading , setLoading ] = useState < boolean > ( true ) ;
1820 const { openNav } = useContext ( AppContext ) ;
1921
2022 const filterName : any = {
@@ -26,8 +28,13 @@ function Filter({ filterId }: FilterProps) {
2628 SoftLeft : ( ) => openNav ( )
2729 } ) ;
2830
31+ useShortcutKeys ( episodes || [ ] , { } , episode => {
32+ handleEpisodeClick ( episode ) ;
33+ } ) ;
34+
2935 useEffect ( ( ) => {
3036 episodeService . getByFilter ( filterId ) . then ( result => {
37+ setLoading ( false ) ;
3138 setEpisodes ( result ) ;
3239 } ) ;
3340 } , [ filterId ] ) ;
@@ -42,7 +49,8 @@ function Filter({ filterId }: FilterProps) {
4249 < h1 className = "kui-h1" > { filterName [ filterId ] } </ h1 >
4350 </ div >
4451 < div className = "view-content" >
45- { episodes . length === 0 && (
52+ { loading && < div className = { `kui-sec ${ style . message } ` } > Loading...</ div > }
53+ { ! loading && episodes . length === 0 && (
4654 < div className = { `kui-sec ${ style . message } ` } > No episodes.</ div >
4755 ) }
4856 < ul className = "kui-list" >
0 commit comments