diff --git a/app/javascript/flavours/glitch/components/autosuggest_input.jsx b/app/javascript/flavours/glitch/components/autosuggest_input.jsx index f059356f09..9e342a353a 100644 --- a/app/javascript/flavours/glitch/components/autosuggest_input.jsx +++ b/app/javascript/flavours/glitch/components/autosuggest_input.jsx @@ -159,8 +159,8 @@ export default class AutosuggestInput extends ImmutablePureComponent { this.input.focus(); }; - UNSAFE_componentWillReceiveProps (nextProps) { - if (nextProps.suggestions !== this.props.suggestions && nextProps.suggestions.size > 0 && this.state.suggestionsHidden && this.state.focused) { + componentDidUpdate (prevProps) { + if (prevProps.suggestions !== this.props.suggestions && this.props.suggestions.size > 0 && this.state.suggestionsHidden && this.state.focused) { this.setState({ suggestionsHidden: false }); } } diff --git a/app/javascript/flavours/glitch/components/media_gallery.jsx b/app/javascript/flavours/glitch/components/media_gallery.jsx index 4abfe55e17..bf89a2d4f8 100644 --- a/app/javascript/flavours/glitch/components/media_gallery.jsx +++ b/app/javascript/flavours/glitch/components/media_gallery.jsx @@ -251,15 +251,13 @@ class MediaGallery extends PureComponent { window.removeEventListener('resize', this.handleResize); } - UNSAFE_componentWillReceiveProps (nextProps) { - if (!is(nextProps.media, this.props.media) && nextProps.visible === undefined) { - this.setState({ visible: displayMedia !== 'hide_all' && !nextProps.sensitive || displayMedia === 'show_all' }); - } else if (!is(nextProps.visible, this.props.visible) && nextProps.visible !== undefined) { - this.setState({ visible: nextProps.visible }); + componentDidUpdate (prevProps) { + if (!is(prevProps.media, this.props.media) && this.props.visible === undefined) { + this.setState({ visible: displayMedia !== 'hide_all' && !this.props.sensitive || displayMedia === 'show_all' }); + } else if (!is(prevProps.visible, this.props.visible) && this.props.visible !== undefined) { + this.setState({ visible: this.props.visible }); } - } - componentDidUpdate () { if (this.node) { this.handleResize(); } diff --git a/app/javascript/flavours/glitch/components/modal_root.jsx b/app/javascript/flavours/glitch/components/modal_root.jsx index 9bbe23ce0c..86016706a6 100644 --- a/app/javascript/flavours/glitch/components/modal_root.jsx +++ b/app/javascript/flavours/glitch/components/modal_root.jsx @@ -66,14 +66,6 @@ class ModalRoot extends PureComponent { } } - UNSAFE_componentWillReceiveProps (nextProps) { - if (!!nextProps.children && !this.props.children) { - this.activeElement = document.activeElement; - - this.getSiblings().forEach(sibling => sibling.setAttribute('inert', true)); - } - } - componentDidUpdate (prevProps) { if (!this.props.children && !!prevProps.children) { this.getSiblings().forEach(sibling => sibling.removeAttribute('inert')); @@ -90,9 +82,15 @@ class ModalRoot extends PureComponent { this._handleModalClose(); } + if (this.props.children && !prevProps.children) { + this.activeElement = document.activeElement; + + this.getSiblings().forEach(sibling => sibling.setAttribute('inert', true)); + this._handleModalOpen(); } + if (this.props.children) { this._ensureHistoryBuffer(); } diff --git a/app/javascript/flavours/glitch/features/blocks/index.jsx b/app/javascript/flavours/glitch/features/blocks/index.jsx index 3ce76c4330..6de7456243 100644 --- a/app/javascript/flavours/glitch/features/blocks/index.jsx +++ b/app/javascript/flavours/glitch/features/blocks/index.jsx @@ -38,7 +38,7 @@ class Blocks extends ImmutablePureComponent { multiColumn: PropTypes.bool, }; - UNSAFE_componentWillMount () { + componentDidMount () { this.props.dispatch(fetchBlocks()); } diff --git a/app/javascript/flavours/glitch/features/compose/components/emoji_picker_dropdown.jsx b/app/javascript/flavours/glitch/features/compose/components/emoji_picker_dropdown.jsx index d368fb6a20..699c0b4a2e 100644 --- a/app/javascript/flavours/glitch/features/compose/components/emoji_picker_dropdown.jsx +++ b/app/javascript/flavours/glitch/features/compose/components/emoji_picker_dropdown.jsx @@ -61,8 +61,14 @@ class ModifierPickerMenu extends PureComponent { this.props.onSelect(e.currentTarget.getAttribute('data-index') * 1); }; - UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.active) { + componentDidMount() { + if (this.props.active) { + this.attachListeners(); + } + } + + componentDidUpdate() { + if (this.props.active) { this.attachListeners(); } else { this.removeListeners(); diff --git a/app/javascript/flavours/glitch/features/favourites/index.jsx b/app/javascript/flavours/glitch/features/favourites/index.jsx index 9e0b79ab5f..2c6289af3a 100644 --- a/app/javascript/flavours/glitch/features/favourites/index.jsx +++ b/app/javascript/flavours/glitch/features/favourites/index.jsx @@ -43,7 +43,7 @@ class Favourites extends ImmutablePureComponent { intl: PropTypes.object.isRequired, }; - UNSAFE_componentWillMount () { + componentDidMount () { if (!this.props.accountIds) { this.props.dispatch(fetchFavourites(this.props.params.statusId)); } diff --git a/app/javascript/flavours/glitch/features/follow_requests/index.jsx b/app/javascript/flavours/glitch/features/follow_requests/index.jsx index 7d651f2ca6..91648412b5 100644 --- a/app/javascript/flavours/glitch/features/follow_requests/index.jsx +++ b/app/javascript/flavours/glitch/features/follow_requests/index.jsx @@ -45,7 +45,7 @@ class FollowRequests extends ImmutablePureComponent { multiColumn: PropTypes.bool, }; - UNSAFE_componentWillMount () { + componentDidMount () { this.props.dispatch(fetchFollowRequests()); } diff --git a/app/javascript/flavours/glitch/features/list_timeline/index.jsx b/app/javascript/flavours/glitch/features/list_timeline/index.jsx index 6283379b5b..5b8194f666 100644 --- a/app/javascript/flavours/glitch/features/list_timeline/index.jsx +++ b/app/javascript/flavours/glitch/features/list_timeline/index.jsx @@ -73,11 +73,10 @@ class ListTimeline extends PureComponent { this.disconnect = dispatch(connectListStream(id)); } - UNSAFE_componentWillReceiveProps (nextProps) { - const { dispatch } = this.props; - const { id } = nextProps.params; + componentDidUpdate (prevProps) { + const { dispatch, params: {id} } = this.props; - if (id !== this.props.params.id) { + if (id !== prevProps.params.id) { if (this.disconnect) { this.disconnect(); this.disconnect = null; diff --git a/app/javascript/flavours/glitch/features/mutes/index.jsx b/app/javascript/flavours/glitch/features/mutes/index.jsx index 26ebff17f4..476606abf0 100644 --- a/app/javascript/flavours/glitch/features/mutes/index.jsx +++ b/app/javascript/flavours/glitch/features/mutes/index.jsx @@ -40,7 +40,7 @@ class Mutes extends ImmutablePureComponent { multiColumn: PropTypes.bool, }; - UNSAFE_componentWillMount () { + componentDidMount () { this.props.dispatch(fetchMutes()); } diff --git a/app/javascript/flavours/glitch/features/pinned_statuses/index.jsx b/app/javascript/flavours/glitch/features/pinned_statuses/index.jsx index 7b4e36cdaf..f50435a2f6 100644 --- a/app/javascript/flavours/glitch/features/pinned_statuses/index.jsx +++ b/app/javascript/flavours/glitch/features/pinned_statuses/index.jsx @@ -34,7 +34,7 @@ class PinnedStatuses extends ImmutablePureComponent { multiColumn: PropTypes.bool, }; - UNSAFE_componentWillMount () { + componentDidMount () { this.props.dispatch(fetchPinnedStatuses()); } diff --git a/app/javascript/flavours/glitch/features/reblogs/index.jsx b/app/javascript/flavours/glitch/features/reblogs/index.jsx index 69bc423563..6e7faa3db6 100644 --- a/app/javascript/flavours/glitch/features/reblogs/index.jsx +++ b/app/javascript/flavours/glitch/features/reblogs/index.jsx @@ -44,7 +44,7 @@ class Reblogs extends ImmutablePureComponent { intl: PropTypes.object.isRequired, }; - UNSAFE_componentWillMount () { + componentDidMount () { if (!this.props.accountIds) { this.props.dispatch(fetchReblogs(this.props.params.statusId)); } diff --git a/app/javascript/flavours/glitch/features/ui/components/bundle.jsx b/app/javascript/flavours/glitch/features/ui/components/bundle.jsx index 15c4220b34..3617baf4f1 100644 --- a/app/javascript/flavours/glitch/features/ui/components/bundle.jsx +++ b/app/javascript/flavours/glitch/features/ui/components/bundle.jsx @@ -33,13 +33,13 @@ class Bundle extends PureComponent { forceRender: false, }; - UNSAFE_componentWillMount() { + componentDidMount() { this.load(this.props); } - UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.fetchComponent !== this.props.fetchComponent) { - this.load(nextProps); + componentDidUpdate(prevProps) { + if (prevProps.fetchComponent !== this.props.fetchComponent) { + this.load(this.props); } } diff --git a/app/javascript/flavours/glitch/features/ui/index.jsx b/app/javascript/flavours/glitch/features/ui/index.jsx index ddb30ba4cf..f18c44c4c8 100644 --- a/app/javascript/flavours/glitch/features/ui/index.jsx +++ b/app/javascript/flavours/glitch/features/ui/index.jsx @@ -116,7 +116,7 @@ class SwitchingColumnsArea extends PureComponent { forceOnboarding: PropTypes.bool, }; - UNSAFE_componentWillMount () { + componentDidMount () { document.body.classList.toggle('layout-single-column', this.props.singleColumn); document.body.classList.toggle('layout-multiple-columns', !this.props.singleColumn); }