Unverified Commit ad1a57f6 authored by Mattermost Build's avatar Mattermost Build Committed by GitHub
Browse files

MM-26718 Fix the perf of animation on DM modal (#5929)



* Instead of dispatching API calls on mount change it to onEntered callback
Co-authored-by: default avatarsudheer <sudheer.105@gmail.com>
parent 02943efe
......@@ -24,6 +24,7 @@ exports[`components/MoreDirectChannels should exclude deleted users if there is
"remove": [Function],
}
}
onEntered={[Function]}
onExited={[Function]}
onHide={[Function]}
renderBackdrop={[Function]}
......@@ -245,6 +246,7 @@ exports[`components/MoreDirectChannels should match snapshot 1`] = `
"remove": [Function],
}
}
onEntered={[Function]}
onExited={[Function]}
onHide={[Function]}
renderBackdrop={[Function]}
......
......@@ -3,6 +3,7 @@
import React from 'react';
import {shallow} from 'enzyme';
import {Modal} from 'react-bootstrap';
import MoreDirectChannels from 'components/more_direct_channels/more_direct_channels';
......@@ -79,8 +80,14 @@ describe('components/MoreDirectChannels', () => {
const props = {...baseProps, actions: {...baseProps.actions, getStatusesByIds: jest.fn()}};
const wrapper = shallow(<MoreDirectChannels {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should call for modal data on callback of modal onEntered', () => {
const props = {...baseProps, actions: {...baseProps.actions, getStatusesByIds: jest.fn()}};
const wrapper = shallow(<MoreDirectChannels {...props}/>);
wrapper.find(Modal).prop('onEntered')();
// on componentDidMount
expect(props.actions.getProfiles).toHaveBeenCalledTimes(1);
expect(props.actions.getTotalUsersStats).toHaveBeenCalledTimes(1);
expect(props.actions.getProfiles).toBeCalledWith(0, 100);
......@@ -95,6 +102,7 @@ describe('components/MoreDirectChannels', () => {
test('should call actions.getStatusesByIds on loadProfilesMissingStatus', () => {
const props = {...baseProps, actions: {...baseProps.actions, getStatusesByIds: jest.fn()}};
const wrapper = shallow(<MoreDirectChannels {...props}/>);
wrapper.find(Modal).prop('onEntered')();
wrapper.instance().loadProfilesMissingStatus(props.users, props.statuses);
expect(props.actions.getStatusesByIds).toHaveBeenCalledTimes(2);
......
......@@ -118,7 +118,7 @@ export default class MoreDirectChannels extends React.PureComponent<Props, State
};
}
componentDidMount() {
loadModalData = () => {
this.getUserProfiles();
this.props.actions.getTotalUsersStats();
this.loadProfilesMissingStatus(this.props.users, this.props.statuses);
......@@ -507,6 +507,7 @@ export default class MoreDirectChannels extends React.PureComponent<Props, State
show={this.state.show}
onHide={this.handleHide}
onExited={this.handleExit}
onEntered={this.loadModalData}
role='dialog'
aria-labelledby='moreDmModalLabel'
id='moreDmModal'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment