Skip to content

Commit

Permalink
Fix seo for lists page
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Dec 26, 2023
1 parent aaac553 commit 875ca5a
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { SeoService } from '../../common-components/seo.service';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { ActivatedRoute, Router } from '@angular/router';
import { ListContents, ListsService } from '../../common-components/services/lists.service';
import { filter, map, switchMap } from 'rxjs';
import { filter, from, map, switchMap } from 'rxjs';
import { Format } from '../../format';
import { AuthService } from '../../common-components/auth/auth.service';
import { PlatformService } from '../../common-components/platform.service';

@UntilDestroy()
@Component({
Expand All @@ -24,18 +25,24 @@ export class UserListsPageComponent {
theLists = this.publicLists;

constructor(private globalSettings: GlobalSettingsService, private seo: SeoService, private auth: AuthService,
public lists: ListsService, private router: Router, private route: ActivatedRoute) {
public lists: ListsService, private router: Router, private route: ActivatedRoute, private platform: PlatformService) {
this.globalSettings.ready.subscribe(() => {
this.init = true;
});
this.route.params.pipe(
untilDestroyed(this),
map((params) => params['user-id']),
filter((userId) => !!userId),
switchMap((userId) => this.auth.getUser().pipe(
map((user) => user?.profile?.id || ''),
map((loggedInUserId) => ({ userId, loggedInUserId }))
)),
switchMap((userId: string) => {
if (this.platform.browser()) {
return this.auth.getUser().pipe(
map((user) => user?.profile?.id || ''),
map((loggedInUserId: string) => ({ userId, loggedInUserId }))
);
} else {
return from([{ userId, loggedInUserId: '' }]);
}
}),
map(({userId, loggedInUserId}) => {
if (userId === loggedInUserId) {
return this.lists.curatedLists;
Expand Down

0 comments on commit 875ca5a

Please sign in to comment.