From a09e1ebcc1e929417dd95cfc636887a517de1259 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Fri, 22 Sep 2017 10:16:56 -0400 Subject: [PATCH] Revert changes that select channel before channel drawer is closed (#930) --- .../channel_drawer/channel_drawer.js | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/app/components/channel_drawer/channel_drawer.js b/app/components/channel_drawer/channel_drawer.js index 7d5a890cb..438f2f657 100644 --- a/app/components/channel_drawer/channel_drawer.js +++ b/app/components/channel_drawer/channel_drawer.js @@ -48,6 +48,8 @@ export default class ChannelDrawer extends PureComponent { theme: PropTypes.object.isRequired }; + closeLeftHandle = null; + openLeftHandle = null; swiperIndex = 1; constructor(props) { @@ -112,6 +114,11 @@ export default class ChannelDrawer extends PureComponent { handleDrawerClose = () => { this.resetDrawer(); + if (this.closeLeftHandle) { + InteractionManager.clearInteractionHandle(this.closeLeftHandle); + this.closeLeftHandle = null; + } + if (this.state.openDrawer) { // The state doesn't get updated if you swipe to close this.setState({ @@ -120,13 +127,28 @@ export default class ChannelDrawer extends PureComponent { } }; + handleDrawerCloseStart = () => { + if (!this.closeLeftHandle) { + this.closeLeftHandle = InteractionManager.createInteractionHandle(); + } + } + handleDrawerOpen = () => { if (this.state.openDrawerOffset !== 0) { Keyboard.dismiss(); } + + if (this.openLeftHandle) { + InteractionManager.clearInteractionHandle(this.openLeftHandle); + this.openLeftHandle = null; + } }; handleDrawerOpenStart = () => { + if (!this.openLeftHandle) { + this.openLeftHandle = InteractionManager.createInteractionHandle(); + } + if (!this.state.openDrawer) { // The state doesn't get updated if you swipe to open this.setState({ @@ -183,15 +205,15 @@ export default class ChannelDrawer extends PureComponent { viewChannel } = actions; + markChannelAsRead(channel.id, currentChannelId); setChannelLoading(); + viewChannel(currentChannelId); setChannelDisplayName(channel.display_name); - handleSelectChannel(channel.id); this.closeChannelDrawer(); InteractionManager.runAfterInteractions(() => { - markChannelAsRead(channel.id, currentChannelId); - viewChannel(currentChannelId); + handleSelectChannel(channel.id); }); }; @@ -346,7 +368,7 @@ export default class ChannelDrawer extends PureComponent { panThreshold={0.25} acceptPan={true} negotiatePan={true} - useInteractionManager={true} + useInteractionManager={false} tweenDuration={100} tweenHandler={this.handleDrawerTween} elevation={-5}