add new sortby button and allow sorting on homepage

This commit is contained in:
2021-06-13 22:29:50 +02:00
parent d94b672a12
commit 8d50ec54e7
4 changed files with 162 additions and 20 deletions

View File

@ -41,18 +41,24 @@ class DynamicContentContainer<T> extends React.Component<Props<T>, state<T>> {
componentDidUpdate(prevProps: Props<T>): void {
// when source props change force update!
if (prevProps.data.length !== this.props.data.length) {
this.clean();
this.loadPreviewBlock(this.InitialLoadNR);
if (
// diff the two arrays
this.props.data
.filter((x) => !prevProps.data.includes(x))
.concat(prevProps.data.filter((x) => !this.props.data.includes(x))).length !== 0
) {
this.clean((): void => {
this.loadPreviewBlock(this.InitialLoadNR);
});
}
}
/**
* clear all elements rendered...
*/
clean(): void {
clean(callback: () => void): void {
this.loadindex = 0;
this.setState({loadeditems: []});
this.setState({loadeditems: []}, callback);
}
render(): JSX.Element {