Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for member meta data fetch issues bug #139

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class MemberAboutComponent implements OnInit {
this.drawerVisible$.next(false);
}

public trackByUid(index: number, item: any): number {
return item.uid;
public trackByUid(index: number, item: any): any {
return item ? item.uid : index;
}
}
4 changes: 2 additions & 2 deletions src/app/pages/member/pages/activity/activity.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class ActivityPage implements OnInit {
return ['/', ROUTER_UTILS.config.space.root, spaceId];
}

public trackByUid(index: number, item: any): number {
return item.uid;
public trackByUid(index: number, item: any): any {
return item ? item.uid : index;
}
}
4 changes: 2 additions & 2 deletions src/app/pages/member/pages/awards/awards.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class AwardsPage {
return this.auth.isLoggedIn$;
}

public trackByUid(index: number, item: any): number {
return item.uid;
public trackByUid(index: number, item: any): any {
return item ? item.uid : index;
}
}
4 changes: 2 additions & 2 deletions src/app/pages/member/pages/badges/badges.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class BadgesPage implements OnInit {
return this.auth.isLoggedIn$;
}

public trackByUid(index: number, item: Transaction) {
return item.uid;
public trackByUid(index: number, item: any): any {
return item ? item.uid : index;
}
}
39 changes: 32 additions & 7 deletions src/app/pages/member/pages/member/member.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { SeoService } from '@core/services/seo';
import { ROUTER_UTILS } from '@core/utils/router.utils';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { FILE_SIZES, Member } from '@build-5/interfaces';
import { BehaviorSubject, Subscription, skip } from 'rxjs';
import { BehaviorSubject, Subscription, filter, map, skip } from 'rxjs';
import { MemberApi } from './../../../../@api/member.api';
import { NavigationService } from './../../../../@core/services/navigation/navigation.service';
import { DataService } from './../../services/data.service';
Expand Down Expand Up @@ -104,6 +104,16 @@ export class MemberPage implements OnInit, OnDestroy {
}

public listenMember(memberId: string): void {
const isValidMemberId = typeof memberId === 'string' && /[a-zA-Z0-9]/.test(memberId);

if (!isValidMemberId) {
this.data.awardsCompleted$.next([]);
this.data.awardsPending$.next([]);
this.data.space$.next([]);
this.data.member$.next(undefined);
return;
}

this.subscriptions$.push(
this.memberApi
.topAwardsCompleted(memberId)
Expand All @@ -118,19 +128,34 @@ export class MemberPage implements OnInit, OnDestroy {
);
// TODO Implement search. This is parked since we will be implementing new search here.
this.subscriptions$.push(
this.memberApi.topSpaces(memberId).pipe(untilDestroyed(this)).subscribe(this.data.space$),
this.memberApi
.topSpaces(memberId)
.pipe(
untilDestroyed(this),
map((spaces) =>
spaces.filter(
(space) => space && typeof space.uid === 'string' && space.uid.trim() !== '',
),
),
)
.subscribe((filteredSpaces) => {
this.data.space$.next(filteredSpaces);
}),
);
this.subscriptions$.push(
this.memberApi
.listen(memberId)
.pipe(untilDestroyed(this))
.subscribe((v) => {
// Only pass next stage.
this.data.member$.next(v);
.pipe(
untilDestroyed(this),
filter((v) => v && typeof v.uid === 'string' && v.uid.trim() !== ''),
)
.subscribe((validMember) => {
// Only pass next stage if valid.
this.data.member$.next(validMember);
}),
);

// Badges.
// Continue with other actions if memberId is valid.
this.data.refreshBadges();
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/member/pages/nfts/nfts.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export class NFTsPage implements OnInit {
return this.auth.member$;
}

public trackByUid(_index: number, item: any): number {
return item.uid;
public trackByUid(index: number, item: any): any {
return item ? item.uid : index;
}

public convertAllToSoonaverseModel(algoliaItems: any[]) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/member/pages/spaces/member-spaces.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class MemberSpacesComponent implements OnInit {
);
}

public trackByUid(index: number, item: any): number {
return item.uid;
public trackByUid(index: number, item: any): any {
return item ? item.uid : index;
}
}
4 changes: 2 additions & 2 deletions src/app/pages/member/pages/tokens/tokens.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ export class TokensPage implements OnInit, OnDestroy {
);
}

public trackByUid(index: number, item: any): number {
return item.uid;
public trackByUid(index: number, item: any): any {
return item ? item.uid : index;
}

public understandNotMintedWarning(): void {
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/member/pages/transactions/transactions.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ export class TransactionsPage implements OnInit, OnDestroy {
});
}

public trackByUid(index: number, item: any): number {
return item.uid;
public trackByUid(index: number, item: any): any {
return item ? item.uid : index;
}

private cancelSubscriptions(): void {
Expand Down
Loading