diff --git a/src/app/features/trade/components/assets-selector/services/tokens-list-service/tokens-list-builder.ts b/src/app/features/trade/components/assets-selector/services/tokens-list-service/tokens-list-builder.ts index 70b3503f44..e7e69e75a3 100644 --- a/src/app/features/trade/components/assets-selector/services/tokens-list-service/tokens-list-builder.ts +++ b/src/app/features/trade/components/assets-selector/services/tokens-list-service/tokens-list-builder.ts @@ -19,21 +19,15 @@ export class TokensListBuilder { constructor( private readonly tokensStoreService: TokensStoreService, private readonly assetsSelectorService: AssetsSelectorService, - private readonly swapFormService: SwapsFormService, - listType: TokensListType - ) { - this.initList(listType); - } + private readonly swapFormService: SwapsFormService + ) {} - /** - * Use at the beggining of builder, if you work directly with tokenList - */ - public useCustomList(tokensList: List): TokensListBuilder { - this.tempTokensList = this.addAvailableFavoriteFields(tokensList); - return this; - } + public initList(listType: TokensListType, tokensList?: List): TokensListBuilder { + if (tokensList) { + this.tempTokensList = this.addAvailableFavoriteFields(tokensList); + return this; + } - private initList(listType: TokensListType): TokensListBuilder { if (listType === 'favorite') { this.tempTokensList = this.addAvailableFavoriteFields(this.tokensStoreService.favoriteTokens); } else if (this.assetsSelectorService.assetType === 'allChains') { diff --git a/src/app/features/trade/components/assets-selector/services/tokens-list-service/tokens-list-store.service.ts b/src/app/features/trade/components/assets-selector/services/tokens-list-service/tokens-list-store.service.ts index 42359fe204..99c07131ce 100644 --- a/src/app/features/trade/components/assets-selector/services/tokens-list-service/tokens-list-store.service.ts +++ b/src/app/features/trade/components/assets-selector/services/tokens-list-service/tokens-list-store.service.ts @@ -207,11 +207,10 @@ export class TokensListStoreService { const tlb = new TokensListBuilder( this.tokensStoreService, this.assetsSelectorService, - this.swapFormService, - this.listType + this.swapFormService ); - return tlb.useCustomList(backendTokens).applySortByComparator().toArray(); + return tlb.initList(this.listType, backendTokens).applySortByComparator().toArray(); } return []; }) @@ -282,12 +281,15 @@ export class TokensListStoreService { const tlb = new TokensListBuilder( this.tokensStoreService, this.assetsSelectorService, - this.swapFormService, - this.listType + this.swapFormService ); if (this.assetsSelectorService.assetType === 'allChains') { - return tlb.applyFilterBySearchQueryOnClient(query).applySortByComparator().toArray(); + return tlb + .initList(this.listType) + .applyFilterBySearchQueryOnClient(query) + .applySortByComparator() + .toArray(); } return tlb @@ -304,15 +306,18 @@ export class TokensListStoreService { const tlb = new TokensListBuilder( this.tokensStoreService, this.assetsSelectorService, - this.swapFormService, - this.listType + this.swapFormService ); if (this.assetsSelectorService.assetType === 'allChains') { - return tlb.applySortByComparator().toArray(); + return tlb.initList(this.listType).applySortByComparator().toArray(); } - return tlb.applyFilterByChain(this.blockchain).applySortByComparator().toArray(); + return tlb + .initList(this.listType) + .applyFilterByChain(this.blockchain) + .applySortByComparator() + .toArray(); } private isTokenFavorite(token: BlockchainToken): boolean {