MM-18764 Remove deprecated lifecycles (#4981)
* create_channel: remove componentWillReceiveProps * lint fix * list: removed componentwillreceiveprops * removed deprecated lifecycle methods * removed deprecated lifecycle methods
This commit is contained in:
parent
20f210cb03
commit
6e2936e2e9
4 changed files with 42 additions and 28 deletions
|
|
@ -80,14 +80,16 @@ class FilteredList extends Component {
|
|||
return !deepEqual(this.props, nextProps, {strict: true}) || !deepEqual(this.state, nextState, {strict: true});
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.term !== nextProps.term) {
|
||||
const {actions, currentTeam} = this.props;
|
||||
const {term} = nextProps;
|
||||
setDataSourceAndTerm(dataSource, term) {
|
||||
this.setState({dataSource, term});
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (prevProps.term !== this.props.term) {
|
||||
const {actions, currentTeam, term} = this.props;
|
||||
const {searchChannels, searchProfiles} = actions;
|
||||
const dataSource = this.buildData(this.props, term);
|
||||
|
||||
this.setState({dataSource, term});
|
||||
this.setDataSourceAndTerm(dataSource, term);
|
||||
clearTimeout(this.searchTimeoutId);
|
||||
|
||||
this.searchTimeoutId = setTimeout(() => {
|
||||
|
|
|
|||
|
|
@ -81,21 +81,23 @@ export default class List extends PureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
setSections(sections) {
|
||||
this.setState({sections});
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
const {
|
||||
canCreatePrivateChannels,
|
||||
orderedChannelIds,
|
||||
unreadChannelIds,
|
||||
} = this.props;
|
||||
} = prevProps;
|
||||
|
||||
if (nextProps.canCreatePrivateChannels !== canCreatePrivateChannels ||
|
||||
nextProps.unreadChannelIds !== unreadChannelIds ||
|
||||
nextProps.orderedChannelIds !== orderedChannelIds) {
|
||||
this.setState({sections: this.buildSections(nextProps)});
|
||||
if (this.props.canCreatePrivateChannels !== canCreatePrivateChannels ||
|
||||
this.props.unreadChannelIds !== unreadChannelIds ||
|
||||
this.props.orderedChannelIds !== orderedChannelIds) {
|
||||
this.setSections(this.buildSections(this.props));
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
if (prevState.sections !== this.state.sections && this.listRef?._wrapperListRef?.getListRef()._viewabilityHelper) { //eslint-disable-line
|
||||
this.listRef.recordInteraction();
|
||||
this.updateUnreadIndicators({
|
||||
|
|
|
|||
|
|
@ -72,14 +72,20 @@ export default class CreateChannel extends PureComponent {
|
|||
this.emitCanCreateChannel(false);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const {createChannelRequest} = nextProps;
|
||||
onRequestStart() {
|
||||
this.setState({error: null, creating: true});
|
||||
}
|
||||
|
||||
if (this.props.createChannelRequest !== createChannelRequest) {
|
||||
switch (createChannelRequest.status) {
|
||||
onRequestFailure(error) {
|
||||
this.setState({error, creating: false});
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (this.props.createChannelRequest !== prevProps.createChannelRequest) {
|
||||
switch (this.props.createChannelRequest.status) {
|
||||
case RequestStatus.STARTED:
|
||||
this.emitCreating(true);
|
||||
this.setState({error: null, creating: true});
|
||||
this.onRequestStart();
|
||||
break;
|
||||
case RequestStatus.SUCCESS:
|
||||
EventEmitter.emit(NavigationTypes.CLOSE_MAIN_SIDEBAR);
|
||||
|
|
@ -91,7 +97,7 @@ export default class CreateChannel extends PureComponent {
|
|||
break;
|
||||
case RequestStatus.FAILURE:
|
||||
this.emitCreating(false);
|
||||
this.setState({error: createChannelRequest.error, creating: false});
|
||||
this.onRequestFailure(this.props.createChannelRequest.error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,22 +102,26 @@ export default class MoreChannels extends PureComponent {
|
|||
this.mounted = false;
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
setChannelsOrArchivedChannels(state) {
|
||||
this.setState(state);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
const {term} = this.state;
|
||||
let channels;
|
||||
let archivedChannels;
|
||||
|
||||
if (nextProps.channels !== this.props.channels) {
|
||||
channels = nextProps.channels;
|
||||
if (this.props.channels !== prevProps.channels) {
|
||||
channels = this.props.channels;
|
||||
if (term) {
|
||||
channels = this.filterChannels(nextProps.channels, term);
|
||||
channels = this.filterChannels(this.props.channels, term);
|
||||
}
|
||||
}
|
||||
|
||||
if (nextProps.archivedChannels !== this.props.archivedChannels) {
|
||||
archivedChannels = nextProps.archivedChannels;
|
||||
if (this.props.archivedChannels !== prevProps.archivedChannels) {
|
||||
archivedChannels = this.props.archivedChannels;
|
||||
if (term) {
|
||||
archivedChannels = this.filterChannels(nextProps.archivedChannels, term);
|
||||
archivedChannels = this.filterChannels(this.props.archivedChannels, term);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -131,7 +135,7 @@ export default class MoreChannels extends PureComponent {
|
|||
}
|
||||
|
||||
if (nextState.archivedChannels || nextState.channels) {
|
||||
this.setState(nextState);
|
||||
this.setChannelsOrArchivedChannels(nextState);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue