0
0
Fork 0

Add show more/less toggle for entire threads in web UI (#6733)

Fix #1258
This commit is contained in:
Eugen Rochko 2018-03-11 09:52:59 +01:00 committed by GitHub
parent f5ee2d469b
commit b6003afcdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 120 additions and 25 deletions

View file

@ -37,16 +37,13 @@ export default class Status extends ImmutablePureComponent {
onBlock: PropTypes.func,
onEmbed: PropTypes.func,
onHeightChange: PropTypes.func,
onToggleHidden: PropTypes.func,
muted: PropTypes.bool,
hidden: PropTypes.bool,
onMoveUp: PropTypes.func,
onMoveDown: PropTypes.func,
};
state = {
isExpanded: false,
}
// Avoid checking props that are functions (and whose equality will always
// evaluate to false. See react-immutable-pure-component for usage.
updateOnProps = [
@ -56,8 +53,6 @@ export default class Status extends ImmutablePureComponent {
'hidden',
]
updateOnStates = ['isExpanded']
handleClick = () => {
if (!this.context.router) {
return;
@ -76,7 +71,7 @@ export default class Status extends ImmutablePureComponent {
}
handleExpandedToggle = () => {
this.setState({ isExpanded: !this.state.isExpanded });
this.props.onToggleHidden(this._properStatus());
};
renderLoadingMediaGallery () {
@ -140,7 +135,6 @@ export default class Status extends ImmutablePureComponent {
let statusAvatar, prepend;
const { hidden, featured } = this.props;
const { isExpanded } = this.state;
let { status, account, ...other } = this.props;
@ -248,7 +242,7 @@ export default class Status extends ImmutablePureComponent {
</a>
</div>
<StatusContent status={status} onClick={this.handleClick} expanded={isExpanded} onExpandedToggle={this.handleExpandedToggle} />
<StatusContent status={status} onClick={this.handleClick} expanded={!status.get('hidden')} onExpandedToggle={this.handleExpandedToggle} />
{media}