From a9e8f98a9d32c57956d41009bd09a1f33310676e Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Tue, 2 Oct 2018 16:01:28 +0200 Subject: [PATCH] Make hidden media clickable in account media gallery --- .../flavours/glitch/components/permalink.js | 15 ++++++++++++--- .../account_gallery/components/media_item.js | 10 ++++++++++ .../glitch/styles/components/accounts.scss | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/javascript/flavours/glitch/components/permalink.js b/app/javascript/flavours/glitch/components/permalink.js index d6556b584d9..1ea6a291505 100644 --- a/app/javascript/flavours/glitch/components/permalink.js +++ b/app/javascript/flavours/glitch/components/permalink.js @@ -12,12 +12,20 @@ export default class Permalink extends React.PureComponent { href: PropTypes.string.isRequired, to: PropTypes.string.isRequired, children: PropTypes.node, + onInterceptClick: PropTypes.func, }; handleClick = (e) => { - if (this.context.router && e.button === 0 && !(e.ctrlKey || e.metaKey)) { - e.preventDefault(); - this.context.router.history.push(this.props.to); + if (e.button === 0 && !(e.ctrlKey || e.metaKey)) { + if (this.props.onInterceptClick && this.props.onInterceptClick()) { + e.preventDefault(); + return; + } + + if (this.context.router) { + e.preventDefault(); + this.context.router.history.push(this.props.to); + } } } @@ -27,6 +35,7 @@ export default class Permalink extends React.PureComponent { className, href, to, + onInterceptClick, ...other } = this.props; diff --git a/app/javascript/flavours/glitch/features/account_gallery/components/media_item.js b/app/javascript/flavours/glitch/features/account_gallery/components/media_item.js index 3740b614f47..89778e1232f 100644 --- a/app/javascript/flavours/glitch/features/account_gallery/components/media_item.js +++ b/app/javascript/flavours/glitch/features/account_gallery/components/media_item.js @@ -14,6 +14,15 @@ export default class MediaItem extends ImmutablePureComponent { visible: displayMedia !== 'hide_all' && !this.props.media.getIn(['status', 'sensitive']) || displayMedia === 'show_all', }; + handleClick = () => { + if (!this.state.visible) { + this.setState({ visible: true }); + return true; + } + + return false; + } + render () { const { media } = this.props; const { visible } = this.state; @@ -50,6 +59,7 @@ export default class MediaItem extends ImmutablePureComponent { href={status.get('url')} style={style} title={title} + onInterceptClick={this.handleClick} > {icon} {label} diff --git a/app/javascript/flavours/glitch/styles/components/accounts.scss b/app/javascript/flavours/glitch/styles/components/accounts.scss index ea748b72bd3..d87cd9c439b 100644 --- a/app/javascript/flavours/glitch/styles/components/accounts.scss +++ b/app/javascript/flavours/glitch/styles/components/accounts.scss @@ -423,6 +423,7 @@ &:active, &:focus { outline: 0; + color: $ui-secondary-color; &::before { content: "";