[Glitch] Change buttons on timeline preview to open the interaction dialog

Port 71e28ba399 to glitch-soc
main
Thibaut Girka 6 years ago
parent 9a47f2cbdf
commit 91c9cb6022

@ -83,7 +83,11 @@ export default class StatusActionBar extends ImmutablePureComponent {
] ]
handleReplyClick = () => { handleReplyClick = () => {
this.props.onReply(this.props.status, this.context.router.history); if (me) {
this.props.onReply(this.props.status, this.context.router.history);
} else {
this._openInteractionDialog('reply');
}
} }
handleShareClick = () => { handleShareClick = () => {
@ -94,17 +98,29 @@ export default class StatusActionBar extends ImmutablePureComponent {
} }
handleFavouriteClick = (e) => { handleFavouriteClick = (e) => {
this.props.onFavourite(this.props.status, e); if (me) {
this.props.onFavourite(this.props.status, e);
} else {
this._openInteractionDialog('favourite');
}
} }
handleBookmarkClick = (e) => { handleBookmarkClick = (e) => {
this.props.onBookmark(this.props.status, e); this.props.onBookmark(this.props.status, e);
} }
handleReblogClick = (e) => { handleReblogClick = e => {
this.props.onReblog(this.props.status, e); if (me) {
this.props.onReblog(this.props.status, e);
} else {
this._openInteractionDialog('reblog');
}
} }
_openInteractionDialog = type => {
window.open(`/interact/${this.props.status.get('id')}?type=${type}`, 'mastodon-intent', 'width=445,height=600,resizable=no,menubar=no,status=no,scrollbars=yes');
}
handleDeleteClick = () => { handleDeleteClick = () => {
this.props.onDelete(this.props.status, this.context.router.history); this.props.onDelete(this.props.status, this.context.router.history);
} }
@ -174,7 +190,7 @@ export default class StatusActionBar extends ImmutablePureComponent {
const mutingConversation = status.get('muted'); const mutingConversation = status.get('muted');
const anonymousAccess = !me; const anonymousAccess = !me;
const publicStatus = ['public', 'unlisted'].includes(status.get('visibility')); const publicStatus = ['public', 'unlisted'].includes(status.get('visibility'));
const reblogDisabled = anonymousAccess || (status.get('visibility') === 'direct' || (status.get('visibility') === 'private' && me !== status.getIn(['account', 'id']))); const reblogDisabled = status.get('visibility') === 'direct' || (status.get('visibility') === 'private' && me !== status.getIn(['account', 'id']));
const reblogMessage = status.get('visibility') === 'private' ? messages.reblog_private : messages.reblog; const reblogMessage = status.get('visibility') === 'private' ? messages.reblog_private : messages.reblog;
let menu = []; let menu = [];
@ -243,7 +259,6 @@ export default class StatusActionBar extends ImmutablePureComponent {
let replyButton = ( let replyButton = (
<IconButton <IconButton
className='status__action-bar-button' className='status__action-bar-button'
disabled={anonymousAccess}
title={replyTitle} title={replyTitle}
icon={replyIcon} icon={replyIcon}
onClick={this.handleReplyClick} onClick={this.handleReplyClick}
@ -262,7 +277,7 @@ export default class StatusActionBar extends ImmutablePureComponent {
<div className='status__action-bar'> <div className='status__action-bar'>
{replyButton} {replyButton}
<IconButton className='status__action-bar-button' disabled={reblogDisabled} active={status.get('reblogged')} pressed={status.get('reblogged')} title={reblogDisabled ? intl.formatMessage(messages.cannot_reblog) : intl.formatMessage(reblogMessage)} icon={reblogIcon} onClick={this.handleReblogClick} /> <IconButton className='status__action-bar-button' disabled={reblogDisabled} active={status.get('reblogged')} pressed={status.get('reblogged')} title={reblogDisabled ? intl.formatMessage(messages.cannot_reblog) : intl.formatMessage(reblogMessage)} icon={reblogIcon} onClick={this.handleReblogClick} />
<IconButton className='status__action-bar-button star-icon' disabled={anonymousAccess} animate active={status.get('favourited')} pressed={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' onClick={this.handleFavouriteClick} /> <IconButton className='status__action-bar-button star-icon' animate active={status.get('favourited')} pressed={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' onClick={this.handleFavouriteClick} />
{shareButton} {shareButton}
<IconButton className='status__action-bar-button bookmark-icon' disabled={anonymousAccess} active={status.get('bookmarked')} pressed={status.get('bookmarked')} title={intl.formatMessage(messages.bookmark)} icon='bookmark' onClick={this.handleBookmarkClick} /> <IconButton className='status__action-bar-button bookmark-icon' disabled={anonymousAccess} active={status.get('bookmarked')} pressed={status.get('bookmarked')} title={intl.formatMessage(messages.bookmark)} icon='bookmark' onClick={this.handleBookmarkClick} />

Loading…
Cancel
Save