feat: auto-save listing to archive after successful eBay post

This commit is contained in:
Peter Foster
2026-04-15 09:53:01 +01:00
parent 8564c3d51c
commit 40c62dbf34
2 changed files with 7 additions and 2 deletions

View File

@@ -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

View File

@@ -17,6 +17,7 @@ public partial class SingleItemView : UserControl
private AiAssistantService? _aiService;
private EbayAuthService? _auth;
private EbayAspectsService? _aspectsService;
private SavedListingsService? _savedService;
private List<CategoryAspect> _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)