import { NoteViewController } from '@standardnotes/snjs' import { PureComponent } from '@/Components/Abstract/PureComponent' import { WebApplication } from '@/Application/Application' import MultipleSelectedNotes from '@/Components/MultipleSelectedNotes/MultipleSelectedNotes' import NoteView from '@/Components/NoteView/NoteView' import MultipleSelectedFiles from '../MultipleSelectedFiles/MultipleSelectedFiles' import { ElementIds } from '@/Constants/ElementIDs' type State = { showMultipleSelectedNotes: boolean showMultipleSelectedFiles: boolean controllers: NoteViewController[] } type Props = { application: WebApplication } class NoteGroupView extends PureComponent { private removeChangeObserver!: () => void constructor(props: Props) { super(props, props.application) this.state = { showMultipleSelectedNotes: false, showMultipleSelectedFiles: false, controllers: [], } } override componentDidMount(): void { super.componentDidMount() const controllerGroup = this.application.noteControllerGroup this.removeChangeObserver = this.application.noteControllerGroup.addActiveControllerChangeObserver(() => { const controllers = controllerGroup.noteControllers this.setState({ controllers: controllers, }) }) this.autorun(() => { if (!this.viewControllerManager) { return } if (this.viewControllerManager && this.viewControllerManager.notesController) { this.setState({ showMultipleSelectedNotes: this.viewControllerManager.notesController.selectedNotesCount > 1, }) } if (this.viewControllerManager.selectionController) { this.setState({ showMultipleSelectedFiles: this.viewControllerManager.selectionController.selectedFilesCount > 1, }) } }) } override deinit() { this.removeChangeObserver?.() ;(this.removeChangeObserver as unknown) = undefined super.deinit() } override render() { return (
{this.state.showMultipleSelectedNotes && ( )} {this.state.showMultipleSelectedFiles && ( )} {!this.state.showMultipleSelectedNotes && ( <> {this.state.controllers.map((controller) => { return })} )}
) } } export default NoteGroupView