Skip to content
Commits on Source (2)
......@@ -22,7 +22,7 @@ export class NSFWSelectorComponent {
@Input('service') serviceRef: string = 'consumer';
@Input('consumer') consumer: false;
@Input('expanded') expanded: false;
@Output('selected') onSelected: EventEmitter<any> = new EventEmitter();
@Output('selectedChange') onSelected: EventEmitter<any> = new EventEmitter();
constructor(
public creatorService: NSFWSelectorCreatorService,
......@@ -33,7 +33,9 @@ export class NSFWSelectorComponent {
ngOnInit() {
if (this.service.reasons) {
this.service.reasons.map(r => this.toggle(r.value));
for (const reason of this.service.reasons) {
this.toggle(reason.value, false);
}
}
}
......@@ -64,14 +66,17 @@ export class NSFWSelectorComponent {
}
}
toggle(reason) {
toggle(reason, triggerChange = true) {
if (reason.locked) {
return;
}
this.service.toggle(reason);
const reasons = this.service.reasons.filter(r => r.selected);
this.onSelected.next(reasons);
if (triggerChange) {
const reasons = this.service.reasons.filter(r => r.selected);
this.onSelected.next(reasons);
}
}
hasSelections(): boolean {
......
......@@ -231,7 +231,7 @@
<m-nsfw-selector
service="editing"
[selected]="entity.nsfw"
(selected)="onNSFWSelected($event)"
(selectedChange)="onNSFWSelected($event)"
>
</m-nsfw-selector>
</li>
......
......@@ -134,7 +134,7 @@ import { Session } from '../../../services/session';
<m-nsfw-selector
service="editing"
[selected]="group.nsfw"
(selected)="onNSFWSelected($event)"
(selectedChange)="onNSFWSelected($event)"
>
</m-nsfw-selector>
</li>
......
......@@ -115,7 +115,7 @@ import { BlockListService } from '../../../../common/services/block-list.service
<m-nsfw-selector
service="editing"
[selected]="user.nsfw_lock"
(selected)="setNSFWLock($event)"
(selectedChange)="setNSFWLock($event)"
>
</m-nsfw-selector>
</li>
......
......@@ -171,7 +171,7 @@
service="editing"
[selected]="activity.nsfw"
[locked]="activity.ownerObj.nsfw_lock"
(selected)="onNSWFSelections($event)"
(selectedChange)="onNSWFSelections($event)"
>
</m-nsfw-selector>
</ng-container>
......
......@@ -2,7 +2,7 @@
<ng-container *mIfFeature="'top-feeds'">
<m-nsfw-selector
[consumer]="true"
(selected)="onNSFWSelected($event)"
(selectedChange)="onNSFWSelected($event)"
></m-nsfw-selector>
</ng-container>
<ng-container *ngIf="showBoostOptions">
......
......@@ -60,7 +60,7 @@
</label>
<ng-container *mIfFeature="'top-feeds'; else oldNSFW">
<m-nsfw-selector (selected)="onNSWFSelections($event)">
<m-nsfw-selector (selectedChange)="onNSWFSelections($event)">
</m-nsfw-selector>
</ng-container>
......