Merge pull request #447 from ThibG/glitch-soc/features/unfold-thread

Fix enabling/disabling collapsed toots, as well as the unfold thread feature
This commit is contained in:
beatrix 2018-04-27 10:30:26 -04:00 committed by GitHub
commit 8de8a621f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 19 deletions

View file

@ -51,7 +51,6 @@ export default class Status extends ImmutablePureComponent {
}; };
state = { state = {
isExpanded: this.props.expanded,
isCollapsed: false, isCollapsed: false,
autoCollapsed: false, autoCollapsed: false,
} }
@ -69,6 +68,7 @@ export default class Status extends ImmutablePureComponent {
'collapse', 'collapse',
'notification', 'notification',
'hidden', 'hidden',
'expanded',
] ]
updateOnStates = [ updateOnStates = [
@ -79,23 +79,48 @@ export default class Status extends ImmutablePureComponent {
// If our settings have changed to disable collapsed statuses, then we // If our settings have changed to disable collapsed statuses, then we
// need to make sure that we uncollapse every one. We do that by watching // need to make sure that we uncollapse every one. We do that by watching
// for changes to `settings.collapsed.enabled` in // for changes to `settings.collapsed.enabled` in
// `componentWillReceiveProps()`. // `getderivedStateFromProps()`.
// We also need to watch for changes on the `collapse` prop---if this // We also need to watch for changes on the `collapse` prop---if this
// changes to anything other than `undefined`, then we need to collapse or // changes to anything other than `undefined`, then we need to collapse or
// uncollapse our status accordingly. // uncollapse our status accordingly.
componentWillReceiveProps (nextProps) { static getDerivedStateFromProps(nextProps, prevState) {
let update = {};
let updated = false;
// Make sure the state mirrors props we track…
if (nextProps.collapse !== prevState.collapseProp) {
update.collapseProp = nextProps.collapse;
updated = true;
}
if (nextProps.expanded !== prevState.expandedProp) {
update.expandedProp = nextProps.expanded;
updated = true;
}
// Update state based on new props
if (!nextProps.settings.getIn(['collapsed', 'enabled'])) { if (!nextProps.settings.getIn(['collapsed', 'enabled'])) {
if (this.state.isCollapsed) { if (prevState.isCollapsed) {
this.setCollapsed(false); update.isCollapsed = false;
updated = true;
} }
} else if ( } else if (
nextProps.collapse !== this.props.collapse && nextProps.collapse !== prevState.collapseProp &&
nextProps.collapse !== undefined nextProps.collapse !== undefined
) this.setCollapsed(nextProps.collapse); ) {
if (nextProps.expanded !== this.props.expanded && update.isCollapsed = nextProps.collapse;
if (nextProps.collapse) update.isExpanded = false;
updated = true;
}
if (nextProps.expanded !== prevState.expandedProp &&
nextProps.expanded !== undefined nextProps.expanded !== undefined
) this.setExpansion(nextProps.expanded); ) {
update.isExpanded = nextProps.expanded;
if (nextProps.expanded) update.isCollapsed = false;
updated = true;
}
return updated ? update : null;
} }
// When mounting, we just check to see if our status should be collapsed, // When mounting, we just check to see if our status should be collapsed,

View file

@ -3233,10 +3233,14 @@ hoek@4.x.x:
version "4.2.0" version "4.2.0"
resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.0.tgz#72d9d0754f7fe25ca2d01ad8f8f9a9449a89526d" resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.0.tgz#72d9d0754f7fe25ca2d01ad8f8f9a9449a89526d"
hoist-non-react-statics@^2.2.1, hoist-non-react-statics@^2.3.0: hoist-non-react-statics@^2.3.0:
version "2.3.1" version "2.3.1"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.3.1.tgz#343db84c6018c650778898240135a1420ee22ce0" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.3.1.tgz#343db84c6018c650778898240135a1420ee22ce0"
hoist-non-react-statics@^2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.5.0.tgz#d2ca2dfc19c5a91c5a6615ce8e564ef0347e2a40"
home-or-tmp@^2.0.0: home-or-tmp@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8"
@ -3477,7 +3481,13 @@ intl@^1.2.5:
version "1.2.5" version "1.2.5"
resolved "https://registry.yarnpkg.com/intl/-/intl-1.2.5.tgz#82244a2190c4e419f8371f5aa34daa3420e2abde" resolved "https://registry.yarnpkg.com/intl/-/intl-1.2.5.tgz#82244a2190c4e419f8371f5aa34daa3420e2abde"
invariant@^2.0.0, invariant@^2.1.1, invariant@^2.2.0, invariant@^2.2.1, invariant@^2.2.2: invariant@^2.0.0:
version "2.2.4"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
dependencies:
loose-envify "^1.0.0"
invariant@^2.1.1, invariant@^2.2.0, invariant@^2.2.1, invariant@^2.2.2:
version "2.2.2" version "2.2.2"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360"
dependencies: dependencies:
@ -4271,7 +4281,11 @@ locate-path@^2.0.0:
p-locate "^2.0.0" p-locate "^2.0.0"
path-exists "^3.0.0" path-exists "^3.0.0"
lodash-es@^4.2.0, lodash-es@^4.2.1: lodash-es@^4.17.5:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.10.tgz#62cd7104cdf5dd87f235a837f0ede0e8e5117e05"
lodash-es@^4.2.1:
version "4.17.4" version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.4.tgz#dcc1d7552e150a0640073ba9cb31d70f032950e7" resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.4.tgz#dcc1d7552e150a0640073ba9cb31d70f032950e7"
@ -4381,10 +4395,14 @@ lodash.uniq@^4.5.0:
version "4.5.0" version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
"lodash@>=3.5 <5", lodash@^4.0.0, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@~4.17.4: "lodash@>=3.5 <5", lodash@^4.0.0, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.2.1, lodash@^4.3.0, lodash@~4.17.4:
version "4.17.4" version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
lodash@^4.17.5, lodash@^4.2.0:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
loglevel@^1.4.1: loglevel@^1.4.1:
version "1.6.0" version "1.6.0"
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.0.tgz#ae0caa561111498c5ba13723d6fb631d24003934" resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.0.tgz#ae0caa561111498c5ba13723d6fb631d24003934"
@ -6083,15 +6101,15 @@ react-redux-loading-bar@^2.9.3:
prop-types "^15.5.6" prop-types "^15.5.6"
react-redux@^5.0.4: react-redux@^5.0.4:
version "5.0.6" version "5.0.7"
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-5.0.6.tgz#23ed3a4f986359d68b5212eaaa681e60d6574946" resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-5.0.7.tgz#0dc1076d9afb4670f993ffaef44b8f8c1155a4c8"
dependencies: dependencies:
hoist-non-react-statics "^2.2.1" hoist-non-react-statics "^2.5.0"
invariant "^2.0.0" invariant "^2.0.0"
lodash "^4.2.0" lodash "^4.17.5"
lodash-es "^4.2.0" lodash-es "^4.17.5"
loose-envify "^1.1.0" loose-envify "^1.1.0"
prop-types "^15.5.10" prop-types "^15.6.0"
react-router-dom@^4.1.1: react-router-dom@^4.1.1:
version "4.2.2" version "4.2.2"