From 1e77ebde618c94fe3e580d685469c92550870b3d Mon Sep 17 00:00:00 2001 From: Echo Date: Thu, 19 Mar 2026 15:18:47 +0100 Subject: [PATCH] [Glitch] Refactor: Remove Status unsafe lifecycles Port 605b5b91c9cb69153ba41f88e4e331503d16e0c2 to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/features/status/index.jsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/javascript/flavours/glitch/features/status/index.jsx b/app/javascript/flavours/glitch/features/status/index.jsx index aece950c6e..f60279a9b8 100644 --- a/app/javascript/flavours/glitch/features/status/index.jsx +++ b/app/javascript/flavours/glitch/features/status/index.jsx @@ -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 () {