import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ListingMode, ListingModes, ListingService } from '@iqser/common-ui';
import { File } from '@red/domain';
import { ConfigService } from '../../config.service';

@Component({
    selector: 'redaction-view-mode-selection',
    templateUrl: './view-mode-selection.component.html',
    styleUrls: ['./view-mode-selection.component.scss'],
    changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ViewModeSelectionComponent {
    readonly listingModes = ListingModes;

    constructor(readonly configService: ConfigService, private readonly _listingService: ListingService<File>) {}

    setListingMode(listingMode: ListingMode): void {
        if (listingMode === this.configService.listingMode) {
            return;
        }

        this.configService.listingMode = listingMode;
        this._listingService.setSelected([]);
    }
}
