Skip to content

Commit

Permalink
Use a consumer for identity
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEssem committed Apr 10, 2024
1 parent 9b54b27 commit 1190068
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
21 changes: 13 additions & 8 deletions app/javascript/flavours/glitch/components/status.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Card from '../features/status/components/card';
// to use the progress bar to show download progress
import Bundle from '../features/ui/components/bundle';
import { MediaGallery, Video, Audio } from '../features/ui/util/async-components';
import { IdentityConsumer } from '../features/ui/util/identity_consumer';
import { SensitiveMediaContext } from '../features/ui/util/sensitive_media_context';
import { displayMedia, visibleReactions } from '../initial_state';

Expand Down Expand Up @@ -845,14 +846,18 @@ class Status extends ImmutablePureComponent {
{...statusContentProps}
/>

<StatusReactions
statusId={status.get('id')}
reactions={status.get('reactions')}
numVisible={visibleReactions}
addReaction={this.props.onReactionAdd}
removeReaction={this.props.onReactionRemove}
canReact={this.context.identity.signedIn}
/>
<IdentityConsumer>
{identity => (
<StatusReactions
statusId={status.get('id')}
reactions={status.get('reactions')}
numVisible={visibleReactions}
addReaction={this.props.onReactionAdd}
removeReaction={this.props.onReactionRemove}
canReact={identity.signedIn}
/>
)}
</IdentityConsumer>

{(!isCollapsed || !(muted || !settings.getIn(['collapsed', 'show_action_bar']))) && (
<StatusActionBar
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import PropTypes from 'prop-types';
import { PureComponent } from 'react';

export class IdentityConsumer extends PureComponent {
static contextTypes = {
identity: PropTypes.object
};

static propTypes = {
children: PropTypes.func.isRequired
};

render() {
return this.props.children(this.context.identity);
}
}

0 comments on commit 1190068

Please sign in to comment.