[Glitch] Refactor: Remove Status unsafe lifecycles

Port 605b5b91c9 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Echo
2026-03-19 15:18:47 +01:00
committed by Claire
parent efac62c156
commit 1e77ebde61

View File

@@ -160,8 +160,8 @@ class Status extends ImmutablePureComponent {
};
componentDidMount () {
attachFullscreenListener(this.onFullScreenChange);
this.props.dispatch(fetchStatus(this.props.params.statusId, { forceFetch: true }));
attachFullscreenListener(this.onFullScreenChange);
}
static getDerivedStateFromProps(props, state) {
@@ -169,7 +169,6 @@ class Status extends ImmutablePureComponent {
let updated = false;
if (props.params.statusId && state.statusId !== props.params.statusId) {
props.dispatch(fetchStatus(props.params.statusId, { forceFetch: true }));
update.threadExpanded = undefined;
update.statusId = props.params.statusId;
updated = true;
@@ -519,8 +518,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'));
@@ -532,6 +531,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 () {