ActivityPub-federated video streaming platform using P2P directly in your web browser
Use a resolver to fetch auto tag policies
Chocobozzzf7b90e0d2933
diff --git a/client/src/app/+my-library/my-auto-tag-policies/my-auto-tag-policies.component.ts b/client/src/app/+my-library/my-auto-tag-policies/my-auto-tag-policies.component.tsindex 21490269b0..e6f3795a70 100644--- a/client/src/app/+my-library/my-auto-tag-policies/my-auto-tag-policies.component.ts+++ b/client/src/app/+my-library/my-auto-tag-policies/my-auto-tag-policies.component.ts@@ -1,11 +1,12 @@import { Component, OnInit, inject } from '@angular/core'import { FormsModule } from '@angular/forms'+import { ActivatedRoute } from '@angular/router'import { AuthService, HtmlRendererService, Notifier } from '@app/core'import { PeertubeCheckboxComponent } from '@app/shared/shared-forms/peertube-checkbox.component'import { AutomaticTagAvailableType } from '@peertube/peertube-models'-import { forkJoin } from 'rxjs'import { AutomaticTagService } from './automatic-tag.service'+import { AutoTagPoliciesTag } from './my-auto-tag-policies.resolver'@Component({templateUrl: './my-auto-tag-policies.component.html',@@ -19,11 +20,12 @@ export class MyAutoTagPoliciesComponent implements OnInit {private autoTagsService = inject(AutomaticTagService)private notifier = inject(Notifier)private html = inject(HtmlRendererService)+ private route = inject(ActivatedRoute)- tags: { name: string, review: boolean, type: AutomaticTagAvailableType }[] = []+ tags: AutoTagPoliciesTag[] = []ngOnInit () {- this.loadAvailableTags()+ this.tags = this.route.snapshot.data['tags']}getLabelText (tag: { name: string, type: AutomaticTagAvailableType }) {@@ -48,16 +50,4 @@ export class MyAutoTagPoliciesComponent implements OnInit {error: err => this.notifier.handleError(err)})}-- private loadAvailableTags () {- const accountName = this.authService.getUser().account.name-- forkJoin([- this.autoTagsService.listAvailable({ accountName }),- this.autoTagsService.getCommentPolicies({ accountName })- ]).subscribe(([ resAvailable, policies ]) => {- this.tags = resAvailable.available- .map(a => ({ name: a.name, type: a.type, review: policies.review.includes(a.name) }))- })- }}diff --git a/client/src/app/+my-library/my-auto-tag-policies/my-auto-tag-policies.resolver.ts b/client/src/app/+my-library/my-auto-tag-policies/my-auto-tag-policies.resolver.tsnew file mode 100644index 0000000000..105005e6ab--- /dev/null+++ b/client/src/app/+my-library/my-auto-tag-policies/my-auto-tag-policies.resolver.ts@@ -0,0 +1,29 @@+import { inject } from '@angular/core'+import { ResolveFn } from '@angular/router'+import { AuthService } from '@app/core'+import { AutomaticTagAvailableType } from '@peertube/peertube-models'+import { forkJoin, map } from 'rxjs'+import { AutomaticTagService } from './automatic-tag.service'++export type AutoTagPoliciesTag = {+ name: string+ review: boolean+ type: AutomaticTagAvailableType+}++export const autoTagPoliciesResolver: ResolveFn<AutoTagPoliciesTag[]> = () => {+ const authService = inject(AuthService)+ const autoTagService = inject(AutomaticTagService)++ const accountName = authService.getUser().account.name++ return forkJoin([+ autoTagService.listAvailable({ accountName }),+ autoTagService.getCommentPolicies({ accountName })+ ]).pipe(+ map(([ resAvailable, policies ]) => {+ return resAvailable.available+ .map(a => ({ name: a.name, type: a.type, review: policies.review.includes(a.name) }))+ })+ )+}diff --git a/client/src/app/+my-library/routes.ts b/client/src/app/+my-library/routes.tsindex e4fcb20ff1..bc6e8fb4ca 100644--- a/client/src/app/+my-library/routes.ts+++ b/client/src/app/+my-library/routes.ts@@ -12,6 +12,7 @@ import { LoginGuard } from '../core'import { CommentsOnMyVideosComponent } from './comments-on-my-videos/comments-on-my-videos.component'import { AutomaticTagService } from './my-auto-tag-policies/automatic-tag.service'import { MyAutoTagPoliciesComponent } from './my-auto-tag-policies/my-auto-tag-policies.component'+import { autoTagPoliciesResolver } from './my-auto-tag-policies/my-auto-tag-policies.resolver'import { MyChannelSpaceComponent } from './my-channel-space.component'import { MyFollowersComponent } from './my-follows/my-followers.component'import { MySubscriptionsComponent } from './my-follows/my-subscriptions.component'@@ -89,6 +90,9 @@ const videoSpaceRoutes = [{path: 'auto-tag-policies',component: MyAutoTagPoliciesComponent,+ resolve: {+ tags: autoTagPoliciesResolver+ },data: {meta: {title: $localize`Your automatic tag policies`