diff --git a/app/actions/views/root.js b/app/actions/views/root.js index 3495be554..73d838492 100644 --- a/app/actions/views/root.js +++ b/app/actions/views/root.js @@ -4,6 +4,7 @@ import {GeneralTypes, PostTypes} from 'mattermost-redux/action_types'; import {Client4} from 'mattermost-redux/client'; import {General} from 'mattermost-redux/constants'; +import {markChannelAsRead} from 'mattermost-redux/actions/channels'; import {getClientConfig, getDataRetentionPolicy, getLicenseConfig} from 'mattermost-redux/actions/general'; import {getPosts} from 'mattermost-redux/actions/posts'; import {getMyTeams, getMyTeamMembers, selectTeam} from 'mattermost-redux/actions/teams'; @@ -62,9 +63,11 @@ export function loadFromPushNotification(notification) { // when the notification is from the same channel as the current channel // we should get the posts if (channelId === currentChannelId) { + markChannelAsRead(channelId, null, false)(dispatch, getState); await retryGetPostsAction(getPosts(channelId), dispatch, getState); } else { // when the notification is from a channel other than the current channel + markChannelAsRead(channelId, currentChannelId, false)(dispatch, getState); dispatch(setChannelDisplayName('')); handleSelectChannel(channelId)(dispatch, getState); } diff --git a/app/components/root/root.js b/app/components/root/root.js index 47b58ec08..1a27d2c1f 100644 --- a/app/components/root/root.js +++ b/app/components/root/root.js @@ -101,6 +101,11 @@ export default class Root extends PureComponent { handleNotificationTapped = async () => { const {navigator} = this.props; + + if (Platform.OS === 'android') { + navigator.dismissModal({animation: 'none'}); + } + navigator.popToRoot({ animated: false }); diff --git a/app/mattermost.js b/app/mattermost.js index 335705897..43ef3e91b 100644 --- a/app/mattermost.js +++ b/app/mattermost.js @@ -467,7 +467,7 @@ export default class Mattermost { this.isConfigured = true; }; - onPushNotification = async (deviceNotification) => { + onPushNotification = (deviceNotification) => { const {dispatch, getState} = this.store; const state = getState(); const {token, url} = state.entities.general.credentials; @@ -494,6 +494,7 @@ export default class Mattermost { } else if (foreground) { EventEmitter.emit(ViewTypes.NOTIFICATION_IN_APP, notification); } else if (userInteraction && !notification.localNotification) { + EventEmitter.emit('close_channel_drawer'); if (startAppFromPushNotification) { Client.setToken(token); Client4.setToken(token); @@ -501,13 +502,15 @@ export default class Mattermost { Client.setUrl(stripTrailingSlashes(url)); } - await loadFromPushNotification(notification)(dispatch, getState); + InteractionManager.runAfterInteractions(async () => { + await loadFromPushNotification(notification)(dispatch, getState); - if (startAppFromPushNotification) { - this.startAppFromPushNotification(); - } else { - EventEmitter.emit(ViewTypes.NOTIFICATION_TAPPED); - } + if (startAppFromPushNotification) { + this.startAppFromPushNotification(); + } else { + EventEmitter.emit(ViewTypes.NOTIFICATION_TAPPED); + } + }); } }; diff --git a/app/screens/notification/notification.js b/app/screens/notification/notification.js index 161f16233..e3bf175c7 100644 --- a/app/screens/notification/notification.js +++ b/app/screens/notification/notification.js @@ -5,6 +5,7 @@ import React, {PureComponent} from 'react'; import PropTypes from 'prop-types'; import { Image, + InteractionManager, Platform, StyleSheet, Text, @@ -17,6 +18,7 @@ import ProfilePicture from 'app/components/profile_picture'; import {changeOpacity} from 'app/utils/theme'; import {isDirectChannel} from 'mattermost-redux/utils/channel_utils'; +import EventEmitter from 'mattermost-redux/utils/event_emitter'; import {displayUsername} from 'mattermost-redux/utils/user_utils'; import logo from 'assets/images/icon.png'; @@ -40,22 +42,23 @@ export default class Notification extends PureComponent { }; notificationTapped = () => { - const {actions, navigator, notification, theme} = this.props; + const {actions, navigator, notification} = this.props; - navigator.dismissInAppNotification(); - if (!notification.localNotification) { - actions.loadFromPushNotification(notification); - navigator.resetTo({ - screen: 'Channel', - animated: false, - navigatorStyle: { - navBarHidden: true, - statusBarHidden: false, - statusBarHideWithNavBar: false, - screenBackgroundColor: theme.centerChannelBg + EventEmitter.emit('close_channel_drawer'); + InteractionManager.runAfterInteractions(() => { + navigator.dismissInAppNotification(); + if (!notification.localNotification) { + actions.loadFromPushNotification(notification); + + if (Platform.OS === 'android') { + navigator.dismissModal({animation: 'none'}); } - }); - } + + navigator.popToRoot({ + animated: false + }); + } + }); }; getNotificationIcon = () => {