From ace921461c9532fe26c0fe533ec59ebb0163cd58 Mon Sep 17 00:00:00 2001 From: Jeremy Kescher Date: Tue, 21 May 2024 00:46:17 +0200 Subject: [PATCH] [Glitch+Emoji reactions] Use modern React context for for identity for emoji reaction code --- app/javascript/flavours/glitch/components/status.jsx | 7 +++++-- .../features/status/components/detailed_status.jsx | 11 ++++------- .../flavours/glitch/features/status/index.jsx | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/javascript/flavours/glitch/components/status.jsx b/app/javascript/flavours/glitch/components/status.jsx index a6167699ea..aa5db535c1 100644 --- a/app/javascript/flavours/glitch/components/status.jsx +++ b/app/javascript/flavours/glitch/components/status.jsx @@ -12,6 +12,7 @@ import { HotKeys } from 'react-hotkeys'; import PictureInPicturePlaceholder from 'flavours/glitch/components/picture_in_picture_placeholder'; import PollContainer from 'flavours/glitch/containers/poll_container'; import NotificationOverlayContainer from 'flavours/glitch/features/notifications/containers/overlay_container'; +import { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context'; import { autoUnfoldCW } from 'flavours/glitch/utils/content_warning'; import { withOptionalRouter, WithOptionalRouterPropTypes } from 'flavours/glitch/utils/react_router'; @@ -77,6 +78,7 @@ class Status extends ImmutablePureComponent { static contextType = SensitiveMediaContext; static propTypes = { + identity: identityContextPropShape, containerId: PropTypes.string, id: PropTypes.string, status: ImmutablePropTypes.map, @@ -541,6 +543,7 @@ class Status extends ImmutablePureComponent { onOpenMedia, notification, history, + identity, ...other } = this.props; const { isCollapsed } = this.state; @@ -849,7 +852,7 @@ class Status extends ImmutablePureComponent { numVisible={visibleReactions} addReaction={this.props.onReactionAdd} removeReaction={this.props.onReactionRemove} - canReact={this.context.identity.signedIn} + canReact={this.props.identity.signedIn} /> {(!isCollapsed || !(muted || !settings.getIn(['collapsed', 'show_action_bar']))) && ( @@ -874,4 +877,4 @@ class Status extends ImmutablePureComponent { } -export default withOptionalRouter(injectIntl(Status)); +export default withOptionalRouter(injectIntl((withIdentity(Status)))); diff --git a/app/javascript/flavours/glitch/features/status/components/detailed_status.jsx b/app/javascript/flavours/glitch/features/status/components/detailed_status.jsx index 50268c8b99..d8c62aa16a 100644 --- a/app/javascript/flavours/glitch/features/status/components/detailed_status.jsx +++ b/app/javascript/flavours/glitch/features/status/components/detailed_status.jsx @@ -15,6 +15,7 @@ import { getHashtagBarForStatus } from 'flavours/glitch/components/hashtag_bar'; import PictureInPicturePlaceholder from 'flavours/glitch/components/picture_in_picture_placeholder'; import { VisibilityIcon } from 'flavours/glitch/components/visibility_icon'; import PollContainer from 'flavours/glitch/containers/poll_container'; +import { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context'; import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router'; import { Avatar } from '../../../components/avatar'; @@ -29,12 +30,8 @@ import Video from '../../video'; import Card from './card'; class DetailedStatus extends ImmutablePureComponent { - - static contextTypes = { - identity: PropTypes.object, - }; - static propTypes = { + identity: identityContextPropShape, status: ImmutablePropTypes.map, settings: ImmutablePropTypes.map.isRequired, onOpenMedia: PropTypes.func.isRequired, @@ -319,7 +316,7 @@ class DetailedStatus extends ImmutablePureComponent { reactions={status.get('reactions')} addReaction={this.props.onReactionAdd} removeReaction={this.props.onReactionRemove} - canReact={this.context.identity.signedIn} + canReact={this.props.identity.signedIn} />
@@ -348,4 +345,4 @@ class DetailedStatus extends ImmutablePureComponent { } -export default withRouter(DetailedStatus); +export default withRouter(withIdentity(DetailedStatus)); diff --git a/app/javascript/flavours/glitch/features/status/index.jsx b/app/javascript/flavours/glitch/features/status/index.jsx index 6973d8a037..218f953617 100644 --- a/app/javascript/flavours/glitch/features/status/index.jsx +++ b/app/javascript/flavours/glitch/features/status/index.jsx @@ -288,8 +288,8 @@ class Status extends ImmutablePureComponent { }; handleReactionAdd = (statusId, name, url) => { - const { dispatch } = this.props; - const { signedIn } = this.context.identity; + const { dispatch, identity } = this.props; + const { signedIn } = identity; if (signedIn) { dispatch(addReaction(statusId, name, url));