From d5d6a8ad16b4d66b1a305317d8053330e24247ec Mon Sep 17 00:00:00 2001 From: kibigo! Date: Sat, 15 Jul 2017 15:10:06 -0700 Subject: [PATCH] Ported updates from #64 --- .../glitch/components/status/action_bar.js | 11 ++++---- .../glitch/components/status/content.js | 28 ++++++++++++------- .../glitch/components/status/header.js | 1 + .../glitch/components/status/index.js | 14 ++++++++-- .../glitch/components/status/player.js | 6 +++- .../glitch/reducers/local_settings.js | 20 ++++++------- 6 files changed, 51 insertions(+), 29 deletions(-) diff --git a/app/javascript/glitch/components/status/action_bar.js b/app/javascript/glitch/components/status/action_bar.js index 6aa088c046..df0904a7c8 100644 --- a/app/javascript/glitch/components/status/action_bar.js +++ b/app/javascript/glitch/components/status/action_bar.js @@ -47,7 +47,7 @@ export default class StatusActionBar extends ImmutablePureComponent { onReport: PropTypes.func, onMuteConversation: PropTypes.func, onDeleteNotification: PropTypes.func, - me: PropTypes.number.isRequired, + me: PropTypes.number, withDismiss: PropTypes.bool, intl: PropTypes.object.isRequired, }; @@ -108,6 +108,7 @@ export default class StatusActionBar extends ImmutablePureComponent { const { status, me, intl, withDismiss } = this.props; const reblogDisabled = status.get('visibility') === 'private' || status.get('visibility') === 'direct'; const mutingConversation = status.get('muted'); + const anonymousAccess = !me; let menu = []; let reblogIcon = 'retweet'; @@ -151,12 +152,12 @@ export default class StatusActionBar extends ImmutablePureComponent { return (
- - - + + +
- +
diff --git a/app/javascript/glitch/components/status/content.js b/app/javascript/glitch/components/status/content.js index 76f5b765af..06fe04ce0a 100644 --- a/app/javascript/glitch/components/status/content.js +++ b/app/javascript/glitch/components/status/content.js @@ -4,6 +4,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import escapeTextContentForBrowser from 'escape-html'; import PropTypes from 'prop-types'; import { FormattedMessage } from 'react-intl'; +import classnames from 'classnames'; // Mastodon imports // import emojify from '../../../mastodon/emoji'; @@ -12,10 +13,6 @@ import Permalink from '../../../mastodon/components/permalink'; export default class StatusContent extends React.PureComponent { - static contextTypes = { - router: PropTypes.object, - }; - static propTypes = { status: ImmutablePropTypes.map.isRequired, expanded: PropTypes.oneOf([true, false, null]), @@ -24,6 +21,7 @@ export default class StatusContent extends React.PureComponent { media: PropTypes.element, mediaIcon: PropTypes.string, parseClick: PropTypes.func, + disabled: PropTypes.bool, }; state = { @@ -45,10 +43,11 @@ export default class StatusContent extends React.PureComponent { link.addEventListener('click', this.onHashtagClick.bind(this, link.text), false); } else { link.addEventListener('click', this.onLinkClick.bind(this), false); - link.setAttribute('target', '_blank'); - link.setAttribute('rel', 'noopener'); link.setAttribute('title', link.href); } + + link.setAttribute('target', '_blank'); + link.setAttribute('rel', 'noopener'); } } @@ -118,7 +117,13 @@ export default class StatusContent extends React.PureComponent { } render () { - const { status, media, mediaIcon } = this.props; + const { + status, + media, + mediaIcon, + parseClick, + disabled, + } = this.props; const hidden = ( this.props.setExpansion ? @@ -133,6 +138,9 @@ export default class StatusContent extends React.PureComponent { )), }; const directionStyle = { direction: 'ltr' }; + const classNames = classnames('status__content', { + 'status__content--with-action': parseClick && !disabled, + }); if (isRtl(status.get('search_index'))) { directionStyle.direction = 'rtl'; @@ -180,7 +188,7 @@ export default class StatusContent extends React.PureComponent { } return ( -
+
` if we don't. } diff --git a/app/javascript/glitch/components/status/index.js b/app/javascript/glitch/components/status/index.js index 314e8b51c3..4a91b5aa37 100644 --- a/app/javascript/glitch/components/status/index.js +++ b/app/javascript/glitch/components/status/index.js @@ -507,6 +507,7 @@ applicable. const { router } = this.context; const { status } = this.props; const { isExpanded } = this.state; + if (!router) return; if (destination === undefined) { destination = `/statuses/${ status.getIn(['reblog', 'id'], status.get('id')) @@ -532,7 +533,13 @@ this operation are further explained in the code below. */ render () { - const { parseClick, setExpansion, handleRef } = this; + const { + parseClick, + setExpansion, + saveHeight, + handleRef, + } = this; + const { router } = this.context; const { status, account, @@ -706,9 +713,10 @@ collapsed. media={media} mediaIcon={mediaIcon} expanded={isExpanded} - setExpansion={this.setExpansion} - onHeightUpdate={this.saveHeight} + setExpansion={setExpansion} + onHeightUpdate={saveHeight} parseClick={parseClick} + disabled={!router} /> {isExpanded !== false ? ( ); - let expandButton = ( + let expandButton = !this.context.router ? '' : (
diff --git a/app/javascript/glitch/reducers/local_settings.js b/app/javascript/glitch/reducers/local_settings.js index 79ff963071..776dcead7f 100644 --- a/app/javascript/glitch/reducers/local_settings.js +++ b/app/javascript/glitch/reducers/local_settings.js @@ -28,7 +28,7 @@ Imports */ // Package imports // -import Immutable from 'immutable'; +import { Map as ImmutableMap } from 'immutable'; // Mastodon imports // import { STORE_HYDRATE } from '../../mastodon/actions/store'; @@ -48,27 +48,27 @@ These are only used if no previously-saved values exist. */ -const initialState = Immutable.fromJS({ +const initialState = ImmutableMap({ layout : 'auto', stretch : true, - collapsed : { + collapsed : ImmutableMap({ enabled : true, - auto : { + auto : ImmutableMap({ all : false, notifications : true, lengthy : true, replies : false, media : false, - }, - backgrounds : { + }), + backgrounds : ImmutableMap({ user_backgrounds : false, preview_images : false, - }, - }, - media : { + }), + }), + media : ImmutableMap({ letterbox : true, fullwidth : true, - }, + }), }); /* * * * */