fix: correct conditionNotes, persist post history, remove redundant Dispatcher.Invoke
This commit is contained in:
@@ -338,12 +338,9 @@ public partial class NewListingView : UserControl
|
||||
if (cts.IsCancellationRequested) return;
|
||||
var suggestions = await _categoryService!.GetCategorySuggestionsAsync(text);
|
||||
if (cts.IsCancellationRequested) return;
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
BCategoryList.ItemsSource = suggestions.Select(s => s.CategoryName).ToList();
|
||||
BCategoryList.Tag = suggestions;
|
||||
BCategoryList.Visibility = suggestions.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
|
||||
});
|
||||
}
|
||||
catch (OperationCanceledException) { }
|
||||
catch { }
|
||||
@@ -623,7 +620,7 @@ public partial class NewListingView : UserControl
|
||||
SetState(ListingState.DropZone);
|
||||
}
|
||||
|
||||
private async void SaveDraft_Click(object sender, RoutedEventArgs e)
|
||||
private void SaveDraft_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_savedService == null) return;
|
||||
if (!ValidateDraft()) return;
|
||||
@@ -632,15 +629,12 @@ public partial class NewListingView : UserControl
|
||||
{
|
||||
_savedService.Save(
|
||||
_draft.Title, _draft.Description, _draft.Price,
|
||||
_draft.CategoryName, GetSelectedCondition().ToString(),
|
||||
_draft.CategoryName, "",
|
||||
_draft.PhotoPaths,
|
||||
_draft.CategoryId, _draft.Condition, _draft.Format,
|
||||
BPostcodeBox.Text);
|
||||
GetWindow()?.RefreshSavedListings();
|
||||
GetWindow()?.SetStatus($"Draft saved: {_draft.Title}");
|
||||
SaveDraftBtn.IsEnabled = false;
|
||||
await Task.Delay(600);
|
||||
SaveDraftBtn.IsEnabled = true;
|
||||
ResetToStateA();
|
||||
}
|
||||
catch (Exception ex) { ShowError("Save Failed", ex.Message); }
|
||||
@@ -656,6 +650,23 @@ public partial class NewListingView : UserControl
|
||||
{
|
||||
var url = await _listingService.PostListingAsync(_draft);
|
||||
_draft.EbayListingUrl = url;
|
||||
|
||||
// Persist a record of the posting
|
||||
if (_savedService != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_savedService.Save(
|
||||
_draft.Title, _draft.Description, _draft.Price,
|
||||
_draft.CategoryName, $"Posted: {url}",
|
||||
_draft.PhotoPaths,
|
||||
_draft.CategoryId, _draft.Condition, _draft.Format,
|
||||
_draft.Postcode);
|
||||
GetWindow()?.RefreshSavedListings();
|
||||
}
|
||||
catch { /* non-critical — posting succeeded, history save is best-effort */ }
|
||||
}
|
||||
|
||||
BSuccessUrl.Text = url;
|
||||
SetState(ListingState.Success);
|
||||
GetWindow()?.SetStatus($"Listed: {_draft.Title}");
|
||||
|
||||
Reference in New Issue
Block a user