import Icon from 'mastodon/components/icon';
import PollContainer from 'mastodon/containers/poll_container';
import { displayMedia } from '../initial_state';
-import { is } from 'immutable';
// We use the component (and not the container) since we do not want
// to use the progress bar to show download progress
state = {
showMedia: defaultMediaVisibility(this.props.status),
+ statusId: undefined,
};
// Track height changes we know about to compensate scrolling
}
}
- componentWillReceiveProps (nextProps) {
- if (!is(nextProps.status, this.props.status) && nextProps.status) {
- this.setState({ showMedia: defaultMediaVisibility(nextProps.status) });
+ static getDerivedStateFromProps(nextProps, prevState) {
+ if (nextProps.status && nextProps.status.get('id') !== prevState.statusId) {
+ return {
+ showMedia: defaultMediaVisibility(nextProps.status),
+ statusId: nextProps.status.get('id'),
+ };
+ } else {
+ return null;
}
}
state = {
fullscreen: false,
showMedia: defaultMediaVisibility(this.props.status),
+ loadedStatusId: undefined,
};
componentWillMount () {
this.props.dispatch(fetchStatus(nextProps.params.statusId));
}
- if (!Immutable.is(nextProps.status, this.props.status) && nextProps.status) {
- this.setState({ showMedia: defaultMediaVisibility(nextProps.status) });
+ if (nextProps.status && nextProps.status.get('id') !== this.state.loadedStatusId) {
+ this.setState({ showMedia: defaultMediaVisibility(nextProps.status), loadedStatusId: nextProps.status.get('id') });
}
}