PeerTube/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts
Chocobozzz 338633ce72
Remove barrels
They can prevent tree shaking
2024-03-05 10:52:32 +01:00

35 lines
1.1 KiB
TypeScript

import { Component, Input } from '@angular/core'
import { Notifier } from '@app/core'
import { FormsModule } from '@angular/forms'
import { PeertubeCheckboxComponent } from '../../../shared/shared-forms/peertube-checkbox.component'
import { RedundancyService } from '@app/shared/shared-main/video/redundancy.service'
@Component({
selector: 'my-redundancy-checkbox',
templateUrl: './redundancy-checkbox.component.html',
standalone: true,
imports: [ PeertubeCheckboxComponent, FormsModule ]
})
export class RedundancyCheckboxComponent {
@Input() redundancyAllowed: boolean
@Input() host: string
constructor (
private notifier: Notifier,
private redundancyService: RedundancyService
) { }
updateRedundancyState () {
this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed)
.subscribe({
next: () => {
const stateLabel = this.redundancyAllowed ? $localize`enabled` : $localize`disabled`
this.notifier.success($localize`Redundancy for ${this.host} is ${stateLabel}`)
},
error: err => this.notifier.error(err.message)
})
}
}