diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-09-23 23:00:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-23 23:00:12 +0200 |
commit | 0d6b878808a02aa4a544e894f06419c0f612c163 (patch) | |
tree | 119723ea46dd8525c370fee1235c3c9d42e55937 /app/javascript/mastodon/features/status | |
parent | d2f7e30a283a1dca1f7974884ac0c237b93903ad (diff) |
Add user content translations with configurable backends (#19218)
Diffstat (limited to 'app/javascript/mastodon/features/status')
-rw-r--r-- | app/javascript/mastodon/features/status/components/detailed_status.js | 13 | ||||
-rw-r--r-- | app/javascript/mastodon/features/status/index.js | 13 |
2 files changed, 25 insertions, 1 deletions
diff --git a/app/javascript/mastodon/features/status/components/detailed_status.js b/app/javascript/mastodon/features/status/components/detailed_status.js index 5c43c2038..320a847f7 100644 --- a/app/javascript/mastodon/features/status/components/detailed_status.js +++ b/app/javascript/mastodon/features/status/components/detailed_status.js @@ -37,6 +37,7 @@ class DetailedStatus extends ImmutablePureComponent { onOpenMedia: PropTypes.func.isRequired, onOpenVideo: PropTypes.func.isRequired, onToggleHidden: PropTypes.func.isRequired, + onTranslate: PropTypes.func.isRequired, measureHeight: PropTypes.bool, onHeightChange: PropTypes.func, domain: PropTypes.string.isRequired, @@ -103,6 +104,11 @@ class DetailedStatus extends ImmutablePureComponent { window.open(href, 'mastodon-intent', 'width=445,height=600,resizable=no,menubar=no,status=no,scrollbars=yes'); } + handleTranslate = () => { + const { onTranslate, status } = this.props; + onTranslate(status); + } + render () { const status = (this.props.status && this.props.status.get('reblog')) ? this.props.status.get('reblog') : this.props.status; const outerStyle = { boxSizing: 'border-box' }; @@ -260,7 +266,12 @@ class DetailedStatus extends ImmutablePureComponent { <DisplayName account={status.get('account')} localDomain={this.props.domain} /> </a> - <StatusContent status={status} expanded={!status.get('hidden')} onExpandedToggle={this.handleExpandedToggle} /> + <StatusContent + status={status} + expanded={!status.get('hidden')} + onExpandedToggle={this.handleExpandedToggle} + onTranslate={this.handleTranslate} + /> {media} diff --git a/app/javascript/mastodon/features/status/index.js b/app/javascript/mastodon/features/status/index.js index 4d7f24834..5ff7e060e 100644 --- a/app/javascript/mastodon/features/status/index.js +++ b/app/javascript/mastodon/features/status/index.js @@ -32,6 +32,8 @@ import { editStatus, hideStatus, revealStatus, + translateStatus, + undoStatusTranslation, } from '../../actions/statuses'; import { unblockAccount, @@ -339,6 +341,16 @@ class Status extends ImmutablePureComponent { } } + handleTranslate = status => { + const { dispatch } = this.props; + + if (status.get('translation')) { + dispatch(undoStatusTranslation(status.get('id'))); + } else { + dispatch(translateStatus(status.get('id'))); + } + } + handleBlockClick = (status) => { const { dispatch } = this.props; const account = status.get('account'); @@ -558,6 +570,7 @@ class Status extends ImmutablePureComponent { onOpenVideo={this.handleOpenVideo} onOpenMedia={this.handleOpenMedia} onToggleHidden={this.handleToggleHidden} + onTranslate={this.handleTranslate} domain={domain} showMedia={this.state.showMedia} onToggleMediaVisibility={this.handleToggleMediaVisibility} |