Add quick filter for followers

pull/4477/head
Chocobozzz 2021-10-19 15:22:15 +02:00
parent 906f46d084
commit 7e76cc3800
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 14 additions and 2 deletions

View File

@ -7,7 +7,7 @@
</h1>
<div class="followers-header">
<my-advanced-input-filter (search)="onSearch($event)"></my-advanced-input-filter>
<my-advanced-input-filter [filters]="inputFilters" (search)="onSearch($event)"></my-advanced-input-filter>
</div>
<div class="no-results" i18n *ngIf="pagination.totalItems === 0">No follower found.</div>

View File

@ -2,6 +2,7 @@ import { Subject } from 'rxjs'
import { Component, OnInit } from '@angular/core'
import { ActivatedRoute } from '@angular/router'
import { AuthService, ComponentPagination, Notifier } from '@app/core'
import { AdvancedInputFilter } from '@app/shared/shared-forms'
import { UserSubscriptionService } from '@app/shared/shared-user-subscription'
import { ActorFollow } from '@shared/models'
@ -21,6 +22,8 @@ export class MyFollowersComponent implements OnInit {
onDataSubject = new Subject<any[]>()
search: string
inputFilters: AdvancedInputFilter[]
constructor (
private route: ActivatedRoute,
private auth: AuthService,
@ -32,6 +35,15 @@ export class MyFollowersComponent implements OnInit {
if (this.route.snapshot.queryParams['search']) {
this.search = this.route.snapshot.queryParams['search']
}
this.auth.userInformationLoaded.subscribe(() => {
this.inputFilters = this.auth.getUser().videoChannels.map(c => {
return {
queryParams: { search: 'channel:' + c.name },
label: $localize`Followers of ${c.name}`
}
})
})
}
onNearOfBottom () {

View File

@ -55,7 +55,7 @@ export class AdvancedInputFilterComponent implements OnInit, AfterViewInit {
}
hasFilters () {
return this.filters.length !== 0
return this.filters && this.filters.length !== 0
}
private scheduleSearchUpdate (value: string) {