diff --git a/src/lib/components/trade_offer/auto_fill.ts b/src/lib/components/trade_offer/auto_fill.ts index 772ca485..7545cc11 100644 --- a/src/lib/components/trade_offer/auto_fill.ts +++ b/src/lib/components/trade_offer/auto_fill.ts @@ -105,6 +105,41 @@ export class AutoFill extends FloatElement { `; } + renderBulkAutoFillDialog(rawTrades: Trade[]): HTMLTemplateResult { + // Remove items already included and non-pending + const fTrades = rawTrades + .filter( + (trade) => !g_rgCurrentTradeStatus.me.assets.find((a) => a.assetid === trade.contract.item.asset_id) + ) + .filter((trade) => trade.state === TradeState.PENDING); + + // Bulk implies > 1 + if (fTrades.length <= 1) { + return html``; + } + + const totalValue = fTrades.map((e) => e.contract.price).reduce((acc, e) => acc + e, 0); + + return html` +
+
+
+ +
+ Detected ${fTrades.length} Sales +
Total Value: $${(totalValue / 100).toFixed(2)}
+
+ +
+ `; + } + getSaleInfo(item: Item): HTMLTemplateResult { if (item.float_value) { return html` @@ -157,14 +192,22 @@ export class AutoFill extends FloatElement { protected render(): HTMLTemplateResult { if (!this.pendingTradesResponse) return html``; + const tradesToBuyer = this.pendingTradesResponse.trades_to_send.filter( + (e) => e.buyer_id === UserThem?.strSteamId + ); + return html` - ${this.pendingTradesResponse.trades_to_send - .filter((e) => e.buyer_id === UserThem?.strSteamId) - .map((e) => this.renderAutoFillDialog(e))} + ${this.renderBulkAutoFillDialog(tradesToBuyer)} ${tradesToBuyer.map((e) => this.renderAutoFillDialog(e))} ${this.showWarningDialog()} `; } + autoFillAll(trades: Trade[]) { + for (const trade of trades) { + this.autoFill(trade); + } + } + autoFill(trade: Trade) { $J('#inventory_select_your_inventory').click(); const el = UserYou?.findAsset(AppId.CSGO, ContextId.PRIMARY, trade.contract.item.asset_id)?.element;