mirror of
https://github.com/mastodon/mastodon.git
synced 2026-03-21 18:05:23 -05:00
Refactor: Remove Status unsafe lifecycles (#38294)
This commit is contained in:
parent
cffa8de626
commit
605b5b91c9
|
|
@ -158,24 +158,11 @@ class Status extends ImmutablePureComponent {
|
|||
newRepliesIds: [],
|
||||
};
|
||||
|
||||
UNSAFE_componentWillMount () {
|
||||
componentDidMount() {
|
||||
this.props.dispatch(fetchStatus(this.props.params.statusId, { forceFetch: true }));
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
attachFullscreenListener(this.onFullScreenChange);
|
||||
}
|
||||
|
||||
UNSAFE_componentWillReceiveProps (nextProps) {
|
||||
if (nextProps.params.statusId !== this.props.params.statusId && nextProps.params.statusId) {
|
||||
this.props.dispatch(fetchStatus(nextProps.params.statusId, { forceFetch: true }));
|
||||
}
|
||||
|
||||
if (nextProps.status && nextProps.status.get('id') !== this.state.loadedStatusId) {
|
||||
this.setState({ showMedia: defaultMediaVisibility(nextProps.status), loadedStatusId: nextProps.status.get('id') });
|
||||
}
|
||||
}
|
||||
|
||||
handleToggleMediaVisibility = () => {
|
||||
this.setState({ showMedia: !this.state.showMedia });
|
||||
};
|
||||
|
|
@ -493,8 +480,8 @@ class Status extends ImmutablePureComponent {
|
|||
this.statusNode = c;
|
||||
};
|
||||
|
||||
componentDidUpdate (prevProps) {
|
||||
const { status, descendantsIds } = this.props;
|
||||
componentDidUpdate(prevProps) {
|
||||
const { status, descendantsIds, params } = this.props;
|
||||
|
||||
const isSameStatus = status && (prevProps.status?.get('id') === status.get('id'));
|
||||
|
||||
|
|
@ -506,6 +493,14 @@ class Status extends ImmutablePureComponent {
|
|||
this.setState({newRepliesIds});
|
||||
}
|
||||
}
|
||||
|
||||
if (params.statusId && prevProps.params.statusId !== params.statusId) {
|
||||
this.props.dispatch(fetchStatus(params.statusId, { forceFetch: true }));
|
||||
}
|
||||
|
||||
if (status && status.get('id') !== this.state.loadedStatusId) {
|
||||
this.setState({ showMedia: defaultMediaVisibility(this.props.status), loadedStatusId: status.get('id') });
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user