Merge pull request #1372 from Bilb/state-refresh-group-media

do not refresh group panel media if length of media did not change
pull/1376/head
Audric Ackermann 5 years ago committed by GitHub
commit 1b3140d126
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -38,7 +38,13 @@ interface Props {
onSetDisappearingMessages: (seconds: number) => void;
}
class SessionGroupSettings extends React.Component<Props, any> {
interface State {
documents: Array<any>;
media: Array<any>;
onItemClick: any;
}
class SessionGroupSettings extends React.Component<Props, State> {
public constructor(props: Props) {
super(props);
@ -67,17 +73,27 @@ class SessionGroupSettings extends React.Component<Props, any> {
setTimeout(() => {
this.getMediaGalleryProps()
.then(({ documents, media, onItemClick }) => {
this.setState({
documents,
media,
onItemClick,
});
const { documents: oldDocs, media: oldMedias } = this.state;
if (
oldDocs.length !== documents.length ||
oldMedias.length !== media.length
) {
this.setState({
documents,
media,
onItemClick,
});
}
})
.ignore();
}, mediaScanInterval);
}
public async getMediaGalleryProps() {
public async getMediaGalleryProps(): Promise<{
documents: Array<any>;
media: Array<any>;
onItemClick: any;
}> {
// We fetch more documents than media as they dont require to be loaded
// into memory right away. Revisit this once we have infinite scrolling:
const DEFAULT_MEDIA_FETCH_COUNT = 50;

Loading…
Cancel
Save