From 7bf3020490302d52e83cf9345d486dcc8b3a640f Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Tue, 13 Aug 2019 16:29:32 +0200 Subject: [PATCH] Automated cherry pick of #3107 (#3112) * MM-17692 execute callback after closing post options * Fix unit tests * Fix snapshot --- .../slide_up_panel/slide_up_panel.js | 4 +-- app/screens/post_options/post_options.js | 29 ++++++++++--------- ...on_settings_mentions_keywords.test.js.snap | 2 ++ ...ication_settings_mentions_keywords.test.js | 1 + 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/components/slide_up_panel/slide_up_panel.js b/app/components/slide_up_panel/slide_up_panel.js index 02473d2e9..59a9d7440 100644 --- a/app/components/slide_up_panel/slide_up_panel.js +++ b/app/components/slide_up_panel/slide_up_panel.js @@ -130,12 +130,12 @@ export default class SlideUpPanel extends PureComponent { }).start(); } - closeWithAnimation = () => { + closeWithAnimation = (cb) => { Animated.timing(this.translateYOffset, { duration: 200, toValue: this.snapPoints[2], useNativeDriver: true, - }).start(() => this.props.onRequestClose()); + }).start(() => this.props.onRequestClose(cb)); }; onHeaderHandlerStateChange = ({nativeEvent}) => { diff --git a/app/screens/post_options/post_options.js b/app/screens/post_options/post_options.js index 64c934ebd..ff4032bb5 100644 --- a/app/screens/post_options/post_options.js +++ b/app/screens/post_options/post_options.js @@ -49,15 +49,19 @@ export default class PostOptions extends PureComponent { intl: intlShape.isRequired, }; - close = () => { - this.props.actions.dismissModal(); + close = async (cb) => { + await this.props.actions.dismissModal(); + + if (typeof cb === 'function') { + setTimeout(cb, 300); + } }; - closeWithAnimation = () => { + closeWithAnimation = (cb) => { if (this.slideUpPanel) { - this.slideUpPanel.closeWithAnimation(); + this.slideUpPanel.closeWithAnimation(cb); } else { - this.close(); + this.close(cb); } }; @@ -268,8 +272,7 @@ export default class PostOptions extends PureComponent { const {actions, theme} = this.props; const {formatMessage} = this.context.intl; - this.close(); - setTimeout(() => { + this.close(() => { MaterialIcon.getImageSource('close', 20, theme.sidebarHeaderTextColor).then((source) => { const screen = 'AddReaction'; const title = formatMessage({id: 'mobile.post_info.add_reaction', defaultMessage: 'Add Reaction'}); @@ -280,15 +283,14 @@ export default class PostOptions extends PureComponent { actions.showModal(screen, title, passProps); }); - }, 300); + }); }; handleReply = () => { const {post} = this.props; - this.closeWithAnimation(); - setTimeout(() => { + this.closeWithAnimation(() => { EventEmitter.emit('goToThread', post); - }, 250); + }); }; handleAddReactionToPost = (emoji) => { @@ -359,8 +361,7 @@ export default class PostOptions extends PureComponent { const {actions, theme, post} = this.props; const {intl} = this.context; - this.close(); - setTimeout(() => { + this.close(() => { MaterialIcon.getImageSource('close', 20, theme.sidebarHeaderTextColor).then((source) => { const screen = 'EditPost'; const title = intl.formatMessage({id: 'mobile.edit_post.title', defaultMessage: 'Editing Message'}); @@ -371,7 +372,7 @@ export default class PostOptions extends PureComponent { actions.showModal(screen, title, passProps); }); - }, 300); + }); }; handleUnflagPost = () => { diff --git a/app/screens/settings/notification_settings_mentions_keywords/__snapshots__/notification_settings_mentions_keywords.test.js.snap b/app/screens/settings/notification_settings_mentions_keywords/__snapshots__/notification_settings_mentions_keywords.test.js.snap index f8a6236ef..79949a53d 100644 --- a/app/screens/settings/notification_settings_mentions_keywords/__snapshots__/notification_settings_mentions_keywords.test.js.snap +++ b/app/screens/settings/notification_settings_mentions_keywords/__snapshots__/notification_settings_mentions_keywords.test.js.snap @@ -39,6 +39,7 @@ NotificationSettingsMentionsKeywords { "textComponent": "span", "timeZone": null, }, + "isLandscape": false, "keywords": "", "onBack": [MockFunction], "theme": Object { @@ -125,6 +126,7 @@ NotificationSettingsMentionsKeywords { "timeZone": null, } } + isLandscape={false} keywords="" onBack={[MockFunction]} theme={ diff --git a/app/screens/settings/notification_settings_mentions_keywords/notification_settings_mentions_keywords.test.js b/app/screens/settings/notification_settings_mentions_keywords/notification_settings_mentions_keywords.test.js index afb44f247..3f1c11e41 100644 --- a/app/screens/settings/notification_settings_mentions_keywords/notification_settings_mentions_keywords.test.js +++ b/app/screens/settings/notification_settings_mentions_keywords/notification_settings_mentions_keywords.test.js @@ -16,6 +16,7 @@ describe('NotificationSettingsMentionsKeywords', () => { }, componentId: 'component-id', keywords: '', + isLandscape: false, onBack: jest.fn(), theme: Preferences.THEMES.default, };