From 40c62dbf34d08bee756b5cf0005ffbc14c84abf8 Mon Sep 17 00:00:00 2001 From: Peter Foster Date: Wed, 15 Apr 2026 09:53:01 +0100 Subject: [PATCH] feat: auto-save listing to archive after successful eBay post --- EbayListingTool/Views/MainWindow.xaml.cs | 2 +- EbayListingTool/Views/SingleItemView.xaml.cs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/EbayListingTool/Views/MainWindow.xaml.cs b/EbayListingTool/Views/MainWindow.xaml.cs index 40aa1b6..1b817b5 100644 --- a/EbayListingTool/Views/MainWindow.xaml.cs +++ b/EbayListingTool/Views/MainWindow.xaml.cs @@ -41,7 +41,7 @@ public partial class MainWindow : MetroWindow SavedView.Initialise(_savedService, _priceLookupService); // New Listing + Bulk tabs - SingleView.Initialise(_listingService, _categoryService, _aiService, _auth, _aspectsService); + SingleView.Initialise(_listingService, _categoryService, _aiService, _auth, _aspectsService, _savedService); BulkView.Initialise(_listingService, _categoryService, _aiService, _bulkService, _auth); // Try to restore saved eBay session diff --git a/EbayListingTool/Views/SingleItemView.xaml.cs b/EbayListingTool/Views/SingleItemView.xaml.cs index e7911e2..4aa71bb 100644 --- a/EbayListingTool/Views/SingleItemView.xaml.cs +++ b/EbayListingTool/Views/SingleItemView.xaml.cs @@ -17,6 +17,7 @@ public partial class SingleItemView : UserControl private AiAssistantService? _aiService; private EbayAuthService? _auth; private EbayAspectsService? _aspectsService; + private SavedListingsService? _savedService; private List _currentAspects = new(); private string _lastAspectsCategoryId = ""; @@ -46,13 +47,15 @@ public partial class SingleItemView : UserControl } public void Initialise(EbayListingService listingService, EbayCategoryService categoryService, - AiAssistantService aiService, EbayAuthService auth, EbayAspectsService aspectsService) + AiAssistantService aiService, EbayAuthService auth, EbayAspectsService aspectsService, + SavedListingsService savedService) { _listingService = listingService; _categoryService = categoryService; _aiService = aiService; _auth = auth; _aspectsService = aspectsService; + _savedService = savedService; PostcodeBox.Text = App.Configuration["Ebay:DefaultPostcode"] ?? ""; } @@ -587,6 +590,8 @@ public partial class SingleItemView : UserControl var url = await _listingService!.PostListingAsync(_draft); ListingUrlText.Text = url; SuccessPanel.Visibility = Visibility.Visible; + try { _savedService?.Save(_draft); } + catch { /* non-critical — listing is already posted */ } GetWindow()?.SetStatus($"Listed: {_draft.Title}"); } catch (Exception ex)