diff --git a/src/app/@api/token.api.ts b/src/app/@api/token.api.ts index 3dd5b05..3bac963 100644 --- a/src/app/@api/token.api.ts +++ b/src/app/@api/token.api.ts @@ -10,7 +10,7 @@ import { WenRequest, } from '@build-5/interfaces'; import { TokenDistributionRepository, TokenRepository, TokenStatsRepository } from '@build-5/lib'; -import { Observable, of } from 'rxjs'; +import { Observable, firstValueFrom, lastValueFrom, of } from 'rxjs'; import { BaseApi, SOON_ENV } from './base.api'; @Injectable({ @@ -91,6 +91,17 @@ export class TokenApi extends BaseApi { return distributions; }; + public getAllTokens = async () => { + const tokens: Token[] = []; + let actTokens: Token[] = []; + do { + const last = tokens[tokens.length - 1]?.uid; + actTokens = await this.tokenRepo.getByField('approved', true, last); + tokens.push(...actTokens); + } while (actTokens.length === QUERY_MAX_LENGTH); + return tokens; + }; + public stats(tokenId: string) { if (!tokenId) { return of(undefined); diff --git a/src/app/pages/award/pages/new/new.page.ts b/src/app/pages/award/pages/new/new.page.ts index 17b075b..76c1e6e 100644 --- a/src/app/pages/award/pages/new/new.page.ts +++ b/src/app/pages/award/pages/new/new.page.ts @@ -142,21 +142,18 @@ export class NewPage implements OnInit, OnDestroy { } }); - this.subscriptions$.push( - this.tokenApi - .top(undefined, 1) - .pipe( - map((tokens) => { - return tokens?.filter((t) => { + this.tokenApi + .getAllTokens() + .then( + (tokens) => { + this.tokens$.next(tokens?.filter((t) => { return ( TEST_AVAILABLE_MINTABLE_NETWORKS.indexOf(t.mintingData?.network) > -1 || t.status === TokenStatus.BASE - ); - }); - }), - ) - .subscribe(this.tokens$), - ); + ) && t.approved; + })) + } + ); } public trackByUid(index: number, item: any): number {