Web: Files: Added resize listener.

This commit is contained in:
Tatiana Lopaeva 2021-06-16 15:35:05 +03:00
parent c257b501fe
commit 056d34a66d

View File

@ -16,17 +16,26 @@ class SelectFileDialogBody extends React.Component {
super(props); super(props);
this.state = { this.state = {
isLoadingData: false, isLoadingData: false,
isAvailableFolders: true,
certainFolders: true,
isVisible: false, isVisible: false,
selectedFolder: "", selectedFolder: "",
filesList: [], filesList: [],
width: window.innerWidth,
}; };
this.backupList; this.timeoutId = null;
this.convertedData = [];
} }
componentDidMount() {} componentDidMount() {
window.addEventListener("resize", this.updateWidth);
}
updateWidth = () => {
clearTimeout(this.timeoutId);
this.timeoutId = setTimeout(
() => this.setState({ width: window.innerWidth }),
150
);
};
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
const { selectedFolder } = this.state; const { selectedFolder } = this.state;
@ -43,6 +52,10 @@ class SelectFileDialogBody extends React.Component {
} }
} }
componentWillUnmount() {
window.removeEventListener("resize", this.updateWidth);
}
onClickInput = () => { onClickInput = () => {
this.setState({ this.setState({
isVisible: true, isVisible: true,
@ -88,10 +101,9 @@ class SelectFileDialogBody extends React.Component {
foldersType, foldersType,
isCommonWithoutProvider, isCommonWithoutProvider,
} = this.props; } = this.props;
const { isVisible, filesList, isLoadingData } = this.state; const { isVisible, filesList, isLoadingData, width } = this.state;
console.log("filesList", filesList);
let type = "aside"; return width < 1024 ? (
return type === "aside" ? (
<SelectFileDialogAsideView <SelectFileDialogAsideView
t={t} t={t}
isPanelVisible={isPanelVisible} isPanelVisible={isPanelVisible}