Skip to content

Commit

Permalink
More DataService member$ and space$ fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
amenconi committed Mar 10, 2024
1 parent 45bb01f commit 7f5e19d
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ <h4 class="flex items-center justify-between">
>
<span i18n>No Contribution Yet.</span>
</article>

<article class="testArticle">
MemberId: {{ (data.member$ | async)?.uid }}<br />
Spaces: {{ (data.space$ | async) }}
<div *ngFor="let s of data.space$ | async">
Space Item: {{ s.uid }}<br />
</div>
</article>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export class MemberAboutComponent implements OnInit {
public previewImageService: PreviewImageService,
public auth: AuthService,
public cd: ChangeDetectorRef,
) {}
) {
}

public ngOnInit(): void {
this.data.triggerAction$.pipe(skip(1), untilDestroyed(this)).subscribe((s) => {
Expand Down Expand Up @@ -63,14 +64,8 @@ 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 {
console.log('member-about trackByUid fired, (index, item): ', index, item);
return item ? item.uid : undefined;
return item ? item.uid : index;
}

}
5 changes: 3 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,8 @@ 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;
}

}
5 changes: 3 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,8 @@ 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;
}

}
23 changes: 17 additions & 6 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 @@ -116,17 +116,28 @@ export class MemberPage implements OnInit, OnDestroy {
.pipe(untilDestroyed(this))
.subscribe(this.data.awardsPending$),
);

// 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);
}),
);

Expand Down
3 changes: 2 additions & 1 deletion src/app/pages/member/pages/nfts/nfts.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export class NFTsPage implements OnInit {
private route: ActivatedRoute,
private router: Router,
private nftSelectionService: NftSelectionService,
) {}
) {
}

public ngOnInit(): void {
this.route.params.subscribe((params) => {
Expand Down
5 changes: 3 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,8 @@ 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;
}

}
3 changes: 2 additions & 1 deletion src/app/pages/member/pages/transactions/transactions.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export class TransactionsPage implements OnInit, OnDestroy {
private memberApi: MemberApi,
private cd: ChangeDetectorRef,
private route: ActivatedRoute,
) {}
) {
}

public ngOnInit(): void {
this.route.params.subscribe((params) => {
Expand Down
1 change: 1 addition & 0 deletions src/app/pages/member/services/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class DataService {
public member$: BehaviorSubject<Member | undefined> = new BehaviorSubject<Member | undefined>(
undefined,
);

public awardsCompleted$: BehaviorSubject<Award[] | undefined> = new BehaviorSubject<
Award[] | undefined
>(undefined);
Expand Down

0 comments on commit 7f5e19d

Please sign in to comment.