@@ -105,6 +105,41 @@ export class AutoFill extends FloatElement {
105105 ` ;
106106 }
107107
108+ renderBulkAutoFillDialog ( rawTrades : Trade [ ] ) : HTMLTemplateResult {
109+ // Remove items already included and non-pending
110+ const fTrades = rawTrades
111+ . filter (
112+ ( trade ) => ! g_rgCurrentTradeStatus . me . assets . find ( ( a ) => a . assetid === trade . contract . item . asset_id )
113+ )
114+ . filter ( ( trade ) => trade . state === TradeState . PENDING ) ;
115+
116+ // Bulk implies > 1
117+ if ( fTrades . length <= 1 ) {
118+ return html `` ;
119+ }
120+
121+ const totalValue = fTrades . map ( ( e ) => e . contract . price ) . reduce ( ( acc , e ) => acc + e , 0 ) ;
122+
123+ return html `
124+ < div class ="container " style ="margin: 20px 0 20px 0; ">
125+ < div >
126+ < div class ="float-icon ">
127+ < img
128+ src ="https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/79/798a12316637ad8fbb91ddb7dc63f770b680bd19_full.jpg "
129+ style ="height: 32px; "
130+ />
131+ </ div >
132+ < span class ="item-name "> Detected ${ fTrades . length } Sales </ span >
133+ < div class ="sale-info "> Total Value: $${ ( totalValue / 100 ) . toFixed ( 2 ) } </ div >
134+ </ div >
135+ < csfloat-steam-button
136+ .text ="${ 'Auto-Fill All Items' } "
137+ @click ="${ ( ) => this . autoFillAll ( fTrades ) } "
138+ > </ csfloat-steam-button >
139+ </ div >
140+ ` ;
141+ }
142+
108143 getSaleInfo ( item : Item ) : HTMLTemplateResult {
109144 if ( item . float_value ) {
110145 return html `
@@ -157,14 +192,22 @@ export class AutoFill extends FloatElement {
157192 protected render ( ) : HTMLTemplateResult {
158193 if ( ! this . pendingTradesResponse ) return html `` ;
159194
195+ const tradesToBuyer = this . pendingTradesResponse . trades_to_send . filter (
196+ ( e ) => e . buyer_id === UserThem ?. strSteamId
197+ ) ;
198+
160199 return html `
161- ${ this . pendingTradesResponse . trades_to_send
162- . filter ( ( e ) => e . buyer_id === UserThem ?. strSteamId )
163- . map ( ( e ) => this . renderAutoFillDialog ( e ) ) }
200+ ${ this . renderBulkAutoFillDialog ( tradesToBuyer ) } ${ tradesToBuyer . map ( ( e ) => this . renderAutoFillDialog ( e ) ) }
164201 ${ this . showWarningDialog ( ) }
165202 ` ;
166203 }
167204
205+ autoFillAll ( trades : Trade [ ] ) {
206+ for ( const trade of trades ) {
207+ this . autoFill ( trade ) ;
208+ }
209+ }
210+
168211 autoFill ( trade : Trade ) {
169212 $J ( '#inventory_select_your_inventory' ) . click ( ) ;
170213 const el = UserYou ?. findAsset ( AppId . CSGO , ContextId . PRIMARY , trade . contract . item . asset_id ) ?. element ;
0 commit comments