diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index d1bff4524..4ae1bbdd6 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -107,15 +107,12 @@ class Status extends ImmutablePureComponent { state = { showMedia: defaultMediaVisibility(this.props.status), statusId: undefined, + noPreviewData: true, }; // Track height changes we know about to compensate scrolling componentDidMount () { this.didShowCard = !this.props.muted && !this.props.hidden && this.props.status && this.props.status.get('card'); - if(this.props.com_prev) { - const { status } = this.props; - this.props.onPreview(status.get('id')); - } } getSnapshotBeforeUpdate () { @@ -181,6 +178,13 @@ class Status extends ImmutablePureComponent { this.context.router.history.push(`/statuses/${status.getIn(['reblog', 'id'], status.get('id'))}`); } + handleMouseEnter = () => { + if(this.props.com_prev && this.state.noPreviewData) { + const { status } = this.props + this.props.onPreview(status.getIn(['reblog', 'id'], status.get('id'))); + this.setState({noPreviewData: false}); + } + } handleExpandClick = (e) => { if (this.props.onClick) { this.props.onClick(); @@ -477,7 +481,7 @@ class Status extends ImmutablePureComponent {
{prepend} -
+
diff --git a/app/javascript/mastodon/containers/status_container.js b/app/javascript/mastodon/containers/status_container.js index 889227002..5241d5fbe 100644 --- a/app/javascript/mastodon/containers/status_container.js +++ b/app/javascript/mastodon/containers/status_container.js @@ -42,10 +42,13 @@ const messages = defineMessages({ const makeMapStateToProps = () => { const getStatus = makeGetStatus(); - const mapStateToProps = (state, props) => ({ - status: getStatus(state, props), - sonsIds: 'com_prev' in props ? state.getIn(['contexts', 'replies', props.id]) : null, - }); + const mapStateToProps = (state, props) => { + const status = getStatus(state, props); + return ({ + status: getStatus(state, props), + sonsIds: 'com_prev' in props ? state.getIn(['contexts', 'replies', status.getIn(['reblog', 'id'], props.id)]) : null, + }) + } return mapStateToProps; };