import { Injectable } from '@angular/core' ; import { Language , TradeSearchHttpQuery } from '@data/poe/schema' ; import { Item , ItemSocketsService } from '../../../item' ; import { TradeSearchFilterService } from './trade-search-filter.service' ; @ Injectable ( { providedIn : 'root' } ) export class TradeSearchFilterSocketsService implements TradeSearchFilterService { constructor ( private readonly sockets ) { } public add ( item , _ , query ) { const validSockets = ( item . sockets || [ ] ) . filter ( x => ! ! x ) ; if ( validSockets . length <= 0 ) { return ; } query . filters . socket_filters = { filters : { } } ; const { length } = validSockets . filter ( x => ! ! x . color ) ; if ( length > 0 ) { query . filters . socket_filters . filters . sockets = { min : length } ; } const links = this . sockets . getLinkCount ( validSockets ) ; if ( links > 0 ) { query . filters . socket_filters . filters . links = { min : links } ; } } }