Refactor: Remove Status unsafe lifecycles (#38294)

This commit is contained in:
Echo 2026-03-19 15:18:47 +01:00 committed by GitHub
parent cffa8de626
commit 605b5b91c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -158,24 +158,11 @@ class Status extends ImmutablePureComponent {
newRepliesIds: [], newRepliesIds: [],
}; };
UNSAFE_componentWillMount () { componentDidMount() {
this.props.dispatch(fetchStatus(this.props.params.statusId, { forceFetch: true })); this.props.dispatch(fetchStatus(this.props.params.statusId, { forceFetch: true }));
}
componentDidMount () {
attachFullscreenListener(this.onFullScreenChange); 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 = () => { handleToggleMediaVisibility = () => {
this.setState({ showMedia: !this.state.showMedia }); this.setState({ showMedia: !this.state.showMedia });
}; };
@ -493,8 +480,8 @@ class Status extends ImmutablePureComponent {
this.statusNode = c; this.statusNode = c;
}; };
componentDidUpdate (prevProps) { componentDidUpdate(prevProps) {
const { status, descendantsIds } = this.props; const { status, descendantsIds, params } = this.props;
const isSameStatus = status && (prevProps.status?.get('id') === status.get('id')); const isSameStatus = status && (prevProps.status?.get('id') === status.get('id'));
@ -506,6 +493,14 @@ class Status extends ImmutablePureComponent {
this.setState({newRepliesIds}); 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 () { componentWillUnmount () {