PLT-5933 Fix drawer transition lag (#377)

* Fix drawer transition lag

* make handleSelectChannel perform actions in parallel
This commit is contained in:
enahum 2017-03-21 19:09:56 -03:00 committed by Harrison Healey
parent 18cc7f1e7f
commit 913e29e37b
3 changed files with 31 additions and 6 deletions

View file

@ -175,9 +175,9 @@ export function handleSelectChannel(channelId) {
return async (dispatch, getState) => {
const {currentTeamId} = getState().entities.teams;
await updateStorage(currentTeamId, {currentChannelId: channelId});
await selectChannel(channelId)(dispatch, getState);
await getChannelStats(currentTeamId, channelId)(dispatch, getState);
updateStorage(currentTeamId, {currentChannelId: channelId});
getChannelStats(currentTeamId, channelId)(dispatch, getState);
selectChannel(channelId)(dispatch, getState);
};
}

View file

@ -5,6 +5,7 @@ import React from 'react';
import {
Dimensions,
Easing,
InteractionManager,
NavigationExperimental,
View
} from 'react-native';
@ -216,6 +217,26 @@ class Router extends React.Component {
};
};
handleLeftDrawerClose = () => {
setTimeout(() => {
InteractionManager.clearInteractionHandle(this.closeLeftHandle);
});
};
handleLeftDrawerCloseStart = () => {
this.closeLeftHandle = InteractionManager.createInteractionHandle();
};
handleLeftDrawerOpen = () => {
setTimeout(() => {
InteractionManager.clearInteractionHandle(this.openLeftHandle);
});
};
handleLeftDrawerOpenStart = () => {
this.openLeftHandle = InteractionManager.createInteractionHandle();
};
render = () => {
const {
index,
@ -248,6 +269,10 @@ class Router extends React.Component {
>
<Drawer
open={leftDrawerOpen}
onOpenStart={this.handleLeftDrawerOpenStart}
onOpen={this.handleLeftDrawerOpen}
onCloseStart={this.handleLeftDrawerCloseStart}
onClose={this.handleLeftDrawerClose}
type='displace'
disabled={modalVisible}
content={leftDrawerContent}
@ -259,7 +284,7 @@ class Router extends React.Component {
panThreshold={0.2}
acceptPan={navigationProps.allowMenuSwipe}
negotiatePan={true}
useInteractionManager={true}
useInteractionManager={false}
tweenHandler={this.handleDrawerTween}
>
<Drawer

View file

@ -32,11 +32,11 @@ export default class ChannelDrawer extends PureComponent {
currentTeam
} = this.props;
this.props.actions.markChannelAsRead(id, currentChannel.id);
this.props.actions.viewChannel(currentTeam.id, id);
this.props.actions.closeDrawers();
InteractionManager.runAfterInteractions(() => {
this.props.actions.markChannelAsRead(id, currentChannel.id);
this.props.actions.handleSelectChannel(id);
this.props.actions.viewChannel(currentTeam.id, id);
});
};