@@ -305,31 +305,37 @@ private async Task LoadStashTabsAsync()
305305 StashTabComboBox . IsEnabled = false ;
306306
307307 SelectedStashTab = null ;
308- if ( await ApiAdapter . GenerateUri ( ) )
308+ var stashTabs = await ApiAdapter . FetchStashTabs ( ) ;
309+ if ( stashTabs is not null )
309310 {
310- foreach ( var stashTab in ApiAdapter . StashTabList )
311+ StashTabList . Clear ( ) ;
312+ foreach ( var tab in stashTabs )
311313 {
312- StashTabList . Add ( stashTab ) ;
314+ StashTabList . Add ( tab ) ;
313315 }
314- }
315316
316- if ( StashTabList . Count > 0 )
317- {
318- var selectedStashTabName = Properties . Settings . Default . SelectedStashTabName ;
319- if ( ! string . IsNullOrEmpty ( selectedStashTabName ) )
317+ if ( stashTabs . Count > 0 )
320318 {
321- var previouslySelectedStashTab = StashTabList . FirstOrDefault ( x => x . TabName == selectedStashTabName ) ;
322- if ( previouslySelectedStashTab is not null )
319+ var selectedStashTabName = Properties . Settings . Default . SelectedStashTabName ;
320+ if ( ! string . IsNullOrEmpty ( selectedStashTabName ) )
323321 {
324- SelectedStashTab = previouslySelectedStashTab ;
322+ var previouslySelectedStashTab = StashTabList . FirstOrDefault ( x => x . TabName == selectedStashTabName ) ;
323+ if ( previouslySelectedStashTab is not null )
324+ {
325+ SelectedStashTab = previouslySelectedStashTab ;
326+ }
325327 }
326- }
327328
328- if ( SelectedStashTab is null )
329- {
330- SelectedStashTab = StashTabList [ 0 ] ;
329+ if ( SelectedStashTab is null )
330+ {
331+ SelectedStashTab = StashTabList [ 0 ] ;
332+ }
331333 }
332334 }
335+ else
336+ {
337+ _ = MessageBox . Show ( "Failed to fetch stash tabs" , "Request Failed" , MessageBoxButton . OK , MessageBoxImage . Error ) ;
338+ }
333339
334340 FetchStashTabsButton . IsEnabled = true ;
335341 StashTabComboBox . IsEnabled = true ;
0 commit comments