@@ -20,11 +20,13 @@ import { WorkerState } from '@/lib/workerState'
2020import { Loader2 } from 'lucide-react'
2121import { useEffect , useState } from 'react'
2222import { z } from 'zod'
23+ import { useToast } from './ui/use-toast'
2324
2425type Props = {
2526 open : boolean
2627 onOpenChange : ( open : boolean ) => void
2728 workerState : z . infer < typeof WorkerState >
29+ setWorkerState : ( workerState : z . infer < typeof WorkerState > ) => void
2830}
2931
3032type SpecDir = {
@@ -37,11 +39,12 @@ type SeriesDir = {
3739 children : SpecDir [ ]
3840}
3941
40- export function LoadResourceDialog ( { open, onOpenChange, workerState } : Props ) {
42+ export function LoadResourceDialog ( { open, onOpenChange, workerState, setWorkerState } : Props ) {
4143 const [ dirStruct , setDirStruct ] = useState < SeriesDir [ ] > ( [ ] )
4244 const [ selectedSeries , selectSeries ] = useState < string | undefined > ( )
4345 const [ selectedSpec , selectSpec ] = useState < string | undefined > ( )
4446 const [ selectedVersion , selectVersion ] = useState < string | undefined > ( )
47+ const { toast } = useToast ( )
4548
4649 useEffect ( ( ) => {
4750 fetch ( 'https://cdn.jsdelivr.net/gh/proj3rd/3gpp-specs-in-json/.dir-list.json' )
@@ -54,6 +57,12 @@ export function LoadResourceDialog({ open, onOpenChange, workerState }: Props) {
5457 } )
5558 } , [ ] )
5659
60+ useEffect ( ( ) => {
61+ if ( open === true && workerState === 'idle' ) {
62+ toast ( { title : 'Done' } )
63+ }
64+ } , [ workerState ] )
65+
5766 function handleOpenChange ( open : boolean ) {
5867 if ( workerState === 'busy' ) {
5968 return
@@ -65,6 +74,7 @@ export function LoadResourceDialog({ open, onOpenChange, workerState }: Props) {
6574 if ( ! selectedSeries || ! selectedSpec || ! selectedVersion ) {
6675 return
6776 }
77+ setWorkerState ( 'busy' )
6878 fetch (
6979 `https://cdn.jsdelivr.net/gh/proj3rd/3gpp-specs-in-json/${ selectedSeries } /${ selectedSpec } /${ selectedVersion } `
7080 )
0 commit comments