From 6ad76069096005d7b55d9c63a567f843997a8068 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Mon, 1 Oct 2018 14:15:47 +0200 Subject: [Glitch] Add support for new display_media setting Port f7a6f9489da9b2a1820366654df47b8a52f5c5bc to glitch-soc [API] [vanilla required] [glitch-soc optional] initial_state show_sensitive_media boolean changed to show_media string with options "default", "hide_all", "show_all" --- app/javascript/flavours/glitch/components/media_gallery.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/javascript/flavours/glitch/components') diff --git a/app/javascript/flavours/glitch/components/media_gallery.js b/app/javascript/flavours/glitch/components/media_gallery.js index 605a2862b..613318102 100644 --- a/app/javascript/flavours/glitch/components/media_gallery.js +++ b/app/javascript/flavours/glitch/components/media_gallery.js @@ -6,7 +6,7 @@ import IconButton from './icon_button'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { isIOS } from 'flavours/glitch/util/is_mobile'; import classNames from 'classnames'; -import { autoPlayGif, displaySensitiveMedia } from 'flavours/glitch/util/initial_state'; +import { autoPlayGif, displayMedia } from 'flavours/glitch/util/initial_state'; const messages = defineMessages({ hidden: { @@ -226,7 +226,7 @@ export default class MediaGallery extends React.PureComponent { }; state = { - visible: this.props.revealed === undefined ? (!this.props.sensitive || displaySensitiveMedia) : this.props.revealed, + visible: this.props.revealed === undefined ? (displayMedia !== 'hide_all' && !this.props.sensitive || displayMedia === 'show_all') : this.props.revealed, }; componentWillReceiveProps (nextProps) { -- cgit From a9e8f98a9d32c57956d41009bd09a1f33310676e Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Tue, 2 Oct 2018 16:01:28 +0200 Subject: Make hidden media clickable in account media gallery --- app/javascript/flavours/glitch/components/permalink.js | 15 ++++++++++++--- .../features/account_gallery/components/media_item.js | 10 ++++++++++ .../flavours/glitch/styles/components/accounts.scss | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) (limited to 'app/javascript/flavours/glitch/components') diff --git a/app/javascript/flavours/glitch/components/permalink.js b/app/javascript/flavours/glitch/components/permalink.js index d6556b584..1ea6a2915 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 3740b614f..89778e123 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 ea748b72b..d87cd9c43 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: ""; -- cgit From 7cc78431092edb0996372bc93bbc398a34af2395 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Sat, 6 Oct 2018 18:53:49 +0200 Subject: Do not scroll timelines when *closing* media modals Media modals push an history state so that pressing back on mobile closes them. We made sure to not scroll when opening them, but not when *closing* them, which caused some issues in rare cases. --- app/javascript/flavours/glitch/components/scrollable_list.js | 1 + app/javascript/flavours/glitch/features/account_gallery/index.js | 3 ++- app/javascript/flavours/glitch/features/blocks/index.js | 3 ++- app/javascript/flavours/glitch/features/favourites/index.js | 1 + app/javascript/flavours/glitch/features/follow_requests/index.js | 1 + app/javascript/flavours/glitch/features/followers/index.js | 1 + app/javascript/flavours/glitch/features/following/index.js | 3 ++- app/javascript/flavours/glitch/features/mutes/index.js | 1 + app/javascript/flavours/glitch/features/reblogs/index.js | 1 + app/javascript/flavours/glitch/features/status/index.js | 3 ++- 10 files changed, 14 insertions(+), 4 deletions(-) (limited to 'app/javascript/flavours/glitch/components') diff --git a/app/javascript/flavours/glitch/components/scrollable_list.js b/app/javascript/flavours/glitch/components/scrollable_list.js index a677cbf5b..3ee710dc9 100644 --- a/app/javascript/flavours/glitch/components/scrollable_list.js +++ b/app/javascript/flavours/glitch/components/scrollable_list.js @@ -150,6 +150,7 @@ export default class ScrollableList extends PureComponent { } defaultShouldUpdateScroll = (prevRouterProps, { location }) => { + if ((((prevRouterProps || {}).location || {}).state || {}).mastodonModalOpen) return false; return !(location.state && location.state.mastodonModalOpen); } diff --git a/app/javascript/flavours/glitch/features/account_gallery/index.js b/app/javascript/flavours/glitch/features/account_gallery/index.js index de8318964..53b906d16 100644 --- a/app/javascript/flavours/glitch/features/account_gallery/index.js +++ b/app/javascript/flavours/glitch/features/account_gallery/index.js @@ -90,7 +90,8 @@ export default class AccountGallery extends ImmutablePureComponent { } shouldUpdateScroll = (prevRouterProps, { location }) => { - return !(location.state && location.state.mastodonModalOpen) + if ((((prevRouterProps || {}).location || {}).state || {}).mastodonModalOpen) return false; + return !(location.state && location.state.mastodonModalOpen); } render () { diff --git a/app/javascript/flavours/glitch/features/blocks/index.js b/app/javascript/flavours/glitch/features/blocks/index.js index 4c8b16504..386a0ce63 100644 --- a/app/javascript/flavours/glitch/features/blocks/index.js +++ b/app/javascript/flavours/glitch/features/blocks/index.js @@ -43,7 +43,8 @@ export default class Blocks extends ImmutablePureComponent { } shouldUpdateScroll = (prevRouterProps, { location }) => { - return !(location.state && location.state.mastodonModalOpen) + if ((((prevRouterProps || {}).location || {}).state || {}).mastodonModalOpen) return false; + return !(location.state && location.state.mastodonModalOpen); } render () { diff --git a/app/javascript/flavours/glitch/features/favourites/index.js b/app/javascript/flavours/glitch/features/favourites/index.js index cf8b31eb3..65cd4a19b 100644 --- a/app/javascript/flavours/glitch/features/favourites/index.js +++ b/app/javascript/flavours/glitch/features/favourites/index.js @@ -34,6 +34,7 @@ export default class Favourites extends ImmutablePureComponent { } shouldUpdateScroll = (prevRouterProps, { location }) => { + if ((((prevRouterProps || {}).location || {}).state || {}).mastodonModalOpen) return false; return !(location.state && location.state.mastodonModalOpen); } diff --git a/app/javascript/flavours/glitch/features/follow_requests/index.js b/app/javascript/flavours/glitch/features/follow_requests/index.js index 1e4633984..bce6338ea 100644 --- a/app/javascript/flavours/glitch/features/follow_requests/index.js +++ b/app/javascript/flavours/glitch/features/follow_requests/index.js @@ -43,6 +43,7 @@ export default class FollowRequests extends ImmutablePureComponent { } shouldUpdateScroll = (prevRouterProps, { location }) => { + if ((((prevRouterProps || {}).location || {}).state || {}).mastodonModalOpen) return false; return !(location.state && location.state.mastodonModalOpen); } diff --git a/app/javascript/flavours/glitch/features/followers/index.js b/app/javascript/flavours/glitch/features/followers/index.js index cdde1775c..a977142ed 100644 --- a/app/javascript/flavours/glitch/features/followers/index.js +++ b/app/javascript/flavours/glitch/features/followers/index.js @@ -57,6 +57,7 @@ export default class Followers extends ImmutablePureComponent { } shouldUpdateScroll = (prevRouterProps, { location }) => { + if ((((prevRouterProps || {}).location || {}).state || {}).mastodonModalOpen) return false; return !(location.state && location.state.mastodonModalOpen); } diff --git a/app/javascript/flavours/glitch/features/following/index.js b/app/javascript/flavours/glitch/features/following/index.js index e7a72d036..70aeefaad 100644 --- a/app/javascript/flavours/glitch/features/following/index.js +++ b/app/javascript/flavours/glitch/features/following/index.js @@ -57,7 +57,8 @@ export default class Following extends ImmutablePureComponent { } shouldUpdateScroll = (prevRouterProps, { location }) => { - return !(location.state && location.state.mastodonModalOpen) + if ((((prevRouterProps || {}).location || {}).state || {}).mastodonModalOpen) return false; + return !(location.state && location.state.mastodonModalOpen); } render () { diff --git a/app/javascript/flavours/glitch/features/mutes/index.js b/app/javascript/flavours/glitch/features/mutes/index.js index d94c1d8ad..bbcbea701 100644 --- a/app/javascript/flavours/glitch/features/mutes/index.js +++ b/app/javascript/flavours/glitch/features/mutes/index.js @@ -43,6 +43,7 @@ export default class Mutes extends ImmutablePureComponent { } shouldUpdateScroll = (prevRouterProps, { location }) => { + if ((((prevRouterProps || {}).location || {}).state || {}).mastodonModalOpen) return false; return !(location.state && location.state.mastodonModalOpen); } diff --git a/app/javascript/flavours/glitch/features/reblogs/index.js b/app/javascript/flavours/glitch/features/reblogs/index.js index c0a65d1de..75f8390a1 100644 --- a/app/javascript/flavours/glitch/features/reblogs/index.js +++ b/app/javascript/flavours/glitch/features/reblogs/index.js @@ -34,6 +34,7 @@ export default class Reblogs extends ImmutablePureComponent { } shouldUpdateScroll = (prevRouterProps, { location }) => { + if ((((prevRouterProps || {}).location || {}).state || {}).mastodonModalOpen) return false; return !(location.state && location.state.mastodonModalOpen); } diff --git a/app/javascript/flavours/glitch/features/status/index.js b/app/javascript/flavours/glitch/features/status/index.js index b3147a2fa..4382748d5 100644 --- a/app/javascript/flavours/glitch/features/status/index.js +++ b/app/javascript/flavours/glitch/features/status/index.js @@ -364,7 +364,8 @@ export default class Status extends ImmutablePureComponent { } shouldUpdateScroll = (prevRouterProps, { location }) => { - return !(location.state && location.state.mastodonModalOpen) + if ((((prevRouterProps || {}).location || {}).state || {}).mastodonModalOpen) return false; + return !(location.state && location.state.mastodonModalOpen); } render () { -- cgit