From 8fa6fcf09705cac0a2d2f2b154f8a5417e3bea48 Mon Sep 17 00:00:00 2001 From: Z Date: Mon, 28 Oct 2019 22:17:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=85=E5=9C=A8=E9=BC=A0=E6=A0=87=E7=A7=BB?= =?UTF-8?q?=E8=BF=87/=E6=89=8B=E6=9C=BA=E6=8C=89=E4=B8=8B=E6=97=B6?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E8=AF=84=E8=AE=BA=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/mastodon/components/status.js | 14 +++++++++----- .../mastodon/containers/status_container.js | 11 +++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) 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; };