Fix reset to channel view when push notification is tapped (#1201)
This commit is contained in:
parent
be682240f4
commit
b761872c59
4 changed files with 35 additions and 21 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue