From 3101fb7406202fc620292cad1db9d30048e5a634 Mon Sep 17 00:00:00 2001 From: Katze719 Date: Thu, 29 Jan 2026 19:47:35 +0100 Subject: [PATCH] Add functionality to delete existing WTB orders Introduces logic to delete existing "Want to Buy" orders if the stock reaches its maximum after a purchase. This enhancement ensures that order management is more efficient and prevents unnecessary order clutter. --- src-tauri/src/live_scraper/modules/item.rs | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/live_scraper/modules/item.rs b/src-tauri/src/live_scraper/modules/item.rs index 938eddf5..df5149e4 100644 --- a/src-tauri/src/live_scraper/modules/item.rs +++ b/src-tauri/src/live_scraper/modules/item.rs @@ -325,6 +325,7 @@ impl ItemModule { .set_enable(true), ); let settings = states::get_settings()?.live_scraper.stock_item; + let wfm_client = states::app_state()?.wfm_client; // Check if item is blacklisted for buying if settings.is_item_blacklisted(&item_info.wfm_id, &TradeMode::Buy) { @@ -352,12 +353,30 @@ impl ItemModule { ), &log_options, ); + // Delete existing WTB order if present (e.g. stock just reached max after a purchase) + let mut order_info = get_order_info(item_info, entry, &wfm_client, OrderType::Buy); + if order_info.has_operation("Update") { + order_info.add_operation("Delete"); + if let Err(e) = progress_order( + &component, + &wfm_client, + &order_info, + OrderType::Buy, + 1, + None, + log_options, + ) + .await + { + return Err(e + .with_location(get_location!()) + .with_context(entry.to_json())); + } + } return Ok(()); } } } - - let wfm_client = states::app_state()?.wfm_client; // Skip if no relevant market activity let (should_skip, _operation) = skip_if_no_market_activity(live_orders); if should_skip {