diff --git a/app/javascript/flavours/glitch/components/status.jsx b/app/javascript/flavours/glitch/components/status.jsx index ea0906963..4321191e9 100644 --- a/app/javascript/flavours/glitch/components/status.jsx +++ b/app/javascript/flavours/glitch/components/status.jsx @@ -61,6 +61,7 @@ class Status extends ImmutablePureComponent { static contextTypes = { router: PropTypes.object, + identity: PropTypes.object, }; static propTypes = { @@ -819,6 +820,7 @@ class Status extends ImmutablePureComponent { numVisible={visibleReactions} addReaction={this.props.onReactionAdd} removeReaction={this.props.onReactionRemove} + canReact={this.context.identity.signedIn} /> {!isCollapsed || !(muted || !settings.getIn(['collapsed', 'show_action_bar'])) ? ( diff --git a/app/javascript/flavours/glitch/components/status_action_bar.jsx b/app/javascript/flavours/glitch/components/status_action_bar.jsx index e6ee2b74c..380dc8416 100644 --- a/app/javascript/flavours/glitch/components/status_action_bar.jsx +++ b/app/javascript/flavours/glitch/components/status_action_bar.jsx @@ -330,7 +330,11 @@ class StatusActionBar extends ImmutablePureComponent { /> - + { + signedIn + ? + : reactButton + } {shareButton} diff --git a/app/javascript/flavours/glitch/components/status_reactions.js b/app/javascript/flavours/glitch/components/status_reactions.js index e263a6480..ff025e8d2 100644 --- a/app/javascript/flavours/glitch/components/status_reactions.js +++ b/app/javascript/flavours/glitch/components/status_reactions.js @@ -17,6 +17,7 @@ export default class StatusReactions extends ImmutablePureComponent { reactions: ImmutablePropTypes.list.isRequired, numVisible: PropTypes.number, addReaction: PropTypes.func.isRequired, + canReact: PropTypes.bool.isRequired, removeReaction: PropTypes.func.isRequired, }; @@ -56,6 +57,7 @@ export default class StatusReactions extends ImmutablePureComponent { style={{ transform: `scale(${style.scale})`, position: style.scale < 0.5 ? 'absolute' : 'static' }} addReaction={this.props.addReaction} removeReaction={this.props.removeReaction} + canReact={this.props.canReact} /> ))} @@ -73,6 +75,7 @@ class Reaction extends ImmutablePureComponent { reaction: ImmutablePropTypes.map.isRequired, addReaction: PropTypes.func.isRequired, removeReaction: PropTypes.func.isRequired, + canReact: PropTypes.bool.isRequired, style: PropTypes.object, }; @@ -83,12 +86,10 @@ class Reaction extends ImmutablePureComponent { handleClick = () => { const { reaction, statusId, addReaction, removeReaction } = this.props; - if (!reaction.get('extern')) { - if (reaction.get('me')) { - removeReaction(statusId, reaction.get('name')); - } else { - addReaction(statusId, reaction.get('name')); - } + if (reaction.get('me')) { + removeReaction(statusId, reaction.get('name')); + } else { + addReaction(statusId, reaction.get('name')); } } @@ -105,6 +106,7 @@ class Reaction extends ImmutablePureComponent { onClick={this.handleClick} onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave} + disabled={!this.props.canReact} style={this.props.style} > diff --git a/app/javascript/flavours/glitch/containers/status_container.js b/app/javascript/flavours/glitch/containers/status_container.js index 3574c7671..7faed925c 100644 --- a/app/javascript/flavours/glitch/containers/status_container.js +++ b/app/javascript/flavours/glitch/containers/status_container.js @@ -168,11 +168,7 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({ }, onReactionAdd (statusId, name, url) { - const { signedIn } = this.context.identity; - - if (signedIn) { - dispatch(addReaction(statusId, name, url)); - } + dispatch(addReaction(statusId, name, url)); }, onReactionRemove (statusId, name) { diff --git a/app/javascript/flavours/glitch/features/status/components/action_bar.jsx b/app/javascript/flavours/glitch/features/status/components/action_bar.jsx index 776b909f9..30c198d6d 100644 --- a/app/javascript/flavours/glitch/features/status/components/action_bar.jsx +++ b/app/javascript/flavours/glitch/features/status/components/action_bar.jsx @@ -236,7 +236,13 @@ class ActionBar extends React.PureComponent {
-
+
+ { + signedIn + ? + : reactButton + } +
{shareButton}
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 8ff7c52db..e32cf23ff 100644 --- a/app/javascript/flavours/glitch/features/status/components/detailed_status.jsx +++ b/app/javascript/flavours/glitch/features/status/components/detailed_status.jsx @@ -26,6 +26,7 @@ class DetailedStatus extends ImmutablePureComponent { static contextTypes = { router: PropTypes.object, + identity: PropTypes.object, }; static propTypes = { @@ -332,6 +333,7 @@ class DetailedStatus extends ImmutablePureComponent { reactions={status.get('reactions')} addReaction={this.props.onReactionAdd} removeReaction={this.props.onReactionRemove} + canReact={this.context.identity.signedIn} />
diff --git a/app/javascript/flavours/glitch/features/status/index.jsx b/app/javascript/flavours/glitch/features/status/index.jsx index 77d3f642c..993b06f6a 100644 --- a/app/javascript/flavours/glitch/features/status/index.jsx +++ b/app/javascript/flavours/glitch/features/status/index.jsx @@ -306,12 +306,6 @@ class Status extends ImmutablePureComponent { if (signedIn) { dispatch(addReaction(statusId, name, url)); - } else { - dispatch(openModal('INTERACTION', { - type: 'reaction_add', - accountId: status.getIn(['account', 'id']), - url: status.get('url'), - })); } } diff --git a/app/javascript/mastodon/components/status.jsx b/app/javascript/mastodon/components/status.jsx index 3e9b6572e..4b1d0becb 100644 --- a/app/javascript/mastodon/components/status.jsx +++ b/app/javascript/mastodon/components/status.jsx @@ -64,6 +64,7 @@ class Status extends ImmutablePureComponent { static contextTypes = { router: PropTypes.object, + identity: PropTypes.object, }; static propTypes = { @@ -557,7 +558,7 @@ class Status extends ImmutablePureComponent { numVisible={visibleReactions} addReaction={this.props.onReactionAdd} removeReaction={this.props.onReactionRemove} - emojiMap={this.props.emojiMap} + canReact={this.context.identity.signedIn} /> diff --git a/app/javascript/mastodon/components/status_action_bar.jsx b/app/javascript/mastodon/components/status_action_bar.jsx index e6d2cd70a..bce30fbf4 100644 --- a/app/javascript/mastodon/components/status_action_bar.jsx +++ b/app/javascript/mastodon/components/status_action_bar.jsx @@ -130,13 +130,7 @@ class StatusActionBar extends ImmutablePureComponent { }; handleEmojiPick = data => { - const { signedIn } = this.context.identity; - - if (signedIn) { - this.props.onReactionAdd(this.props.status.get('id'), data.native.replace(/:/g, '')); - } else { - this.props.onInteractionModal('favourite', this.props.status); - } + this.props.onReactionAdd(this.props.status.get('id'), data.native.replace(/:/g, ''), data.imageUrl); } handleReblogClick = e => { diff --git a/app/javascript/mastodon/components/status_reactions.js b/app/javascript/mastodon/components/status_reactions.js index c16b7e826..ff025e8d2 100644 --- a/app/javascript/mastodon/components/status_reactions.js +++ b/app/javascript/mastodon/components/status_reactions.js @@ -17,8 +17,8 @@ export default class StatusReactions extends ImmutablePureComponent { reactions: ImmutablePropTypes.list.isRequired, numVisible: PropTypes.number, addReaction: PropTypes.func.isRequired, + canReact: PropTypes.bool.isRequired, removeReaction: PropTypes.func.isRequired, - emojiMap: ImmutablePropTypes.map.isRequired, }; willEnter() { @@ -57,7 +57,7 @@ export default class StatusReactions extends ImmutablePureComponent { style={{ transform: `scale(${style.scale})`, position: style.scale < 0.5 ? 'absolute' : 'static' }} addReaction={this.props.addReaction} removeReaction={this.props.removeReaction} - emojiMap={this.props.emojiMap} + canReact={this.props.canReact} /> ))}
@@ -75,7 +75,7 @@ class Reaction extends ImmutablePureComponent { reaction: ImmutablePropTypes.map.isRequired, addReaction: PropTypes.func.isRequired, removeReaction: PropTypes.func.isRequired, - emojiMap: ImmutablePropTypes.map.isRequired, + canReact: PropTypes.bool.isRequired, style: PropTypes.object, }; @@ -85,14 +85,11 @@ class Reaction extends ImmutablePureComponent { handleClick = () => { const { reaction, statusId, addReaction, removeReaction } = this.props; - const { signedIn } = this.context.identity; - if (signedIn) { - if (reaction.get('me')) { - removeReaction(statusId, reaction.get('name')); - } else { - addReaction(statusId, reaction.get('name')); - } + if (reaction.get('me')) { + removeReaction(statusId, reaction.get('name')); + } else { + addReaction(statusId, reaction.get('name')); } } @@ -109,10 +106,16 @@ class Reaction extends ImmutablePureComponent { onClick={this.handleClick} onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave} + disabled={!this.props.canReact} style={this.props.style} > - + @@ -127,12 +130,13 @@ class Emoji extends React.PureComponent { static propTypes = { emoji: PropTypes.string.isRequired, - emojiMap: ImmutablePropTypes.map.isRequired, hovered: PropTypes.bool.isRequired, + url: PropTypes.string, + staticUrl: PropTypes.string, }; render() { - const { emoji, emojiMap, hovered } = this.props; + const { emoji, hovered, url, staticUrl } = this.props; if (unicodeMapping[emoji]) { const { filename, shortCode } = unicodeMapping[this.props.emoji]; @@ -147,10 +151,8 @@ class Emoji extends React.PureComponent { src={`${assetHost}/emoji/${filename}.svg`} /> ); - } else if (emojiMap.get(emoji)) { - const filename = (autoPlayGif || hovered) - ? emojiMap.getIn([emoji, 'url']) - : emojiMap.getIn([emoji, 'static_url']); + } else { + const filename = (autoPlayGif || hovered) ? url : staticUrl; const shortCode = `:${emoji}:`; return ( @@ -162,8 +164,6 @@ class Emoji extends React.PureComponent { src={filename} /> ); - } else { - return null; } } diff --git a/app/javascript/mastodon/features/status/components/action_bar.jsx b/app/javascript/mastodon/features/status/components/action_bar.jsx index a517f16d2..0b0663904 100644 --- a/app/javascript/mastodon/features/status/components/action_bar.jsx +++ b/app/javascript/mastodon/features/status/components/action_bar.jsx @@ -308,7 +308,13 @@ class ActionBar extends React.PureComponent {
-
+
+ { + canReact + ? + : reactButton + } +
{shareButton} diff --git a/app/javascript/mastodon/features/status/components/detailed_status.jsx b/app/javascript/mastodon/features/status/components/detailed_status.jsx index b5216b222..64af812dd 100644 --- a/app/javascript/mastodon/features/status/components/detailed_status.jsx +++ b/app/javascript/mastodon/features/status/components/detailed_status.jsx @@ -30,6 +30,7 @@ class DetailedStatus extends ImmutablePureComponent { static contextTypes = { router: PropTypes.object, + identity: PropTypes.object, }; static propTypes = { @@ -50,7 +51,6 @@ class DetailedStatus extends ImmutablePureComponent { onToggleMediaVisibility: PropTypes.func, onReactionAdd: PropTypes.func.isRequired, onReactionRemove: PropTypes.func.isRequired, - emojiMap: ImmutablePropTypes.map.isRequired, }; state = { @@ -292,7 +292,7 @@ class DetailedStatus extends ImmutablePureComponent { reactions={status.get('reactions')} addReaction={this.props.onReactionAdd} removeReaction={this.props.onReactionRemove} - emojiMap={this.props.emojiMap} + canReact={this.context.identity.signedIn} />
diff --git a/app/javascript/mastodon/features/status/index.jsx b/app/javascript/mastodon/features/status/index.jsx index 952104034..77d6e470e 100644 --- a/app/javascript/mastodon/features/status/index.jsx +++ b/app/javascript/mastodon/features/status/index.jsx @@ -261,12 +261,6 @@ class Status extends ImmutablePureComponent { if (signedIn) { dispatch(addReaction(statusId, name, url)); - } else { - dispatch(openModal('INTERACTION', { - type: 'reaction_add', - accountId: status.getIn(['account', 'id']), - url: status.get('url'), - })); } }