File tree Expand file tree Collapse file tree 1 file changed +15
-13
lines changed
Expand file tree Collapse file tree 1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ function SampleDropdown({
1111} ) : JSX . Element {
1212 const { samples, loadSample } = useAppStore (
1313 ( state ) => ( {
14- samples : state . samples ,
14+ samples : state . samples || [ ] ,
1515 loadSample : state . loadSample as ( key : string ) => Promise < void > ,
1616 } ) ,
1717 shallow
@@ -29,23 +29,25 @@ function SampleDropdown({
2929 ) ;
3030
3131 const handleMenuClick : MenuProps [ "onClick" ] = useCallback (
32- async ( e ) => {
32+ ( e : { key : string } ) => {
3333 if ( ! loadSample ) {
34- message . error ( "Load function is not available" ) ;
34+ void message . error ( "Load function is not available" ) ;
3535 return ;
3636 }
3737
3838 if ( e . key ) {
3939 setLoading ( true ) ;
40- try {
41- await loadSample ( e . key ) ;
42- message . info ( `Loaded ${ e . key } sample` ) ;
43- setSelectedSample ( e . key ) ;
44- } catch ( error ) {
45- message . error ( "Failed to load sample" ) ;
46- } finally {
47- setLoading ( false ) ;
48- }
40+ loadSample ( e . key )
41+ . then ( ( ) => {
42+ void message . info ( `Loaded ${ e . key } sample` ) ;
43+ setSelectedSample ( e . key ) ;
44+ } )
45+ . catch ( ( ) => {
46+ void message . error ( "Failed to load sample" ) ;
47+ } )
48+ . finally ( ( ) => {
49+ setLoading ( false ) ;
50+ } ) ;
4951 }
5052 } ,
5153 [ loadSample , setLoading ]
@@ -64,4 +66,4 @@ function SampleDropdown({
6466 ) ;
6567}
6668
67- export default SampleDropdown ;
69+ export default SampleDropdown ;
You can’t perform that action at this time.
0 commit comments