forked from Ivasoft/mattermost-mobile
fix channel mention badge and posts after opening the app from push notification (which is initially at closed state) (#2648)
This commit is contained in:
@@ -355,7 +355,12 @@ export function handleSelectChannel(channelId, fromPushNotification = false) {
|
||||
const member = getMyChannelMember(state, channelId);
|
||||
|
||||
dispatch(setLoadMorePostsVisible(true));
|
||||
dispatch(loadPostsIfNecessaryWithRetry(channelId));
|
||||
|
||||
// If the app is open from push notification, we already fetched the posts.
|
||||
if (!fromPushNotification) {
|
||||
dispatch(loadPostsIfNecessaryWithRetry(channelId));
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
selectChannel(channelId),
|
||||
setChannelDisplayName(channel.display_name),
|
||||
@@ -376,8 +381,13 @@ export function handleSelectChannel(channelId, fromPushNotification = false) {
|
||||
},
|
||||
]));
|
||||
|
||||
dispatch(markChannelAsRead(channelId, fromPushNotification || sameChannel ? null : currentChannelId));
|
||||
dispatch(markChannelAsViewed(channelId, fromPushNotification || sameChannel ? null : currentChannelId));
|
||||
let markPreviousChannelId;
|
||||
if (!fromPushNotification && !sameChannel) {
|
||||
markPreviousChannelId = currentChannelId;
|
||||
}
|
||||
|
||||
dispatch(markChannelAsRead(channelId, markPreviousChannelId));
|
||||
dispatch(markChannelAsViewed(channelId, markPreviousChannelId));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -4,17 +4,14 @@
|
||||
import {GeneralTypes, PostTypes} from 'mattermost-redux/action_types';
|
||||
import {Client4} from 'mattermost-redux/client';
|
||||
import {General} from 'mattermost-redux/constants';
|
||||
import {fetchMyChannelsAndMembers, markChannelAsRead, markChannelAsViewed} from 'mattermost-redux/actions/channels';
|
||||
import {fetchMyChannelsAndMembers} from 'mattermost-redux/actions/channels';
|
||||
import {getClientConfig, getDataRetentionPolicy, getLicenseConfig} from 'mattermost-redux/actions/general';
|
||||
import {getMyTeams, getMyTeamMembers, selectTeam} from 'mattermost-redux/actions/teams';
|
||||
|
||||
import {ViewTypes} from 'app/constants';
|
||||
import {recordTime} from 'app/utils/segment';
|
||||
|
||||
import {
|
||||
handleSelectChannel,
|
||||
setChannelDisplayName,
|
||||
} from 'app/actions/views/channel';
|
||||
import {handleSelectChannel} from 'app/actions/views/channel';
|
||||
|
||||
export function startDataCleanup() {
|
||||
return async (dispatch, getState) => {
|
||||
@@ -54,7 +51,7 @@ export function loadFromPushNotification(notification, startAppFromPushNotificat
|
||||
const state = getState();
|
||||
const {data} = notification;
|
||||
const {currentTeamId, teams, myMembers: myTeamMembers} = state.entities.teams;
|
||||
const {currentChannelId, channels} = state.entities.channels;
|
||||
const {channels} = state.entities.channels;
|
||||
|
||||
let channelId = '';
|
||||
let teamId = currentTeamId;
|
||||
@@ -86,14 +83,7 @@ export function loadFromPushNotification(notification, startAppFromPushNotificat
|
||||
dispatch(selectTeam({id: teamId}));
|
||||
}
|
||||
|
||||
if (channelId === currentChannelId && !startAppFromPushNotification) {
|
||||
dispatch(markChannelAsRead(channelId, null, true));
|
||||
dispatch(markChannelAsViewed(channelId));
|
||||
} else if (channelId !== currentChannelId) {
|
||||
// when the notification is from a channel other than the current channel
|
||||
dispatch(setChannelDisplayName(''));
|
||||
dispatch(handleSelectChannel(channelId, true));
|
||||
}
|
||||
dispatch(handleSelectChannel(channelId, startAppFromPushNotification));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -37,12 +37,14 @@ const handleRedirectProtocol = (url, response) => {
|
||||
};
|
||||
|
||||
Client4.doFetchWithResponse = async (url, options) => {
|
||||
if (!Client4.online) {
|
||||
throw new ClientError(Client4.getUrl(), {
|
||||
message: 'no internet connection',
|
||||
url,
|
||||
});
|
||||
}
|
||||
// Removing the check of this flag to be handled natively.
|
||||
// In case Android presents the out of memory issue, consider uncommenting line 42-47.
|
||||
// if (!Client4.online) {
|
||||
// throw new ClientError(Client4.getUrl(), {
|
||||
// message: 'no internet connection',
|
||||
// url,
|
||||
// });
|
||||
// }
|
||||
|
||||
const customHeaders = LocalConfig.CustomRequestHeaders;
|
||||
let waitsForConnectivity = false;
|
||||
|
||||
@@ -50,7 +50,7 @@ const onRegisterDevice = (data) => {
|
||||
};
|
||||
|
||||
const loadFromNotification = async (notification) => {
|
||||
await store.dispatch(loadFromPushNotification(notification, app.startAppFromPushNotification));
|
||||
await store.dispatch(loadFromPushNotification(notification, true));
|
||||
if (!app.startAppFromPushNotification) {
|
||||
EventEmitter.emit(ViewTypes.NOTIFICATION_TAPPED);
|
||||
PushNotifications.resetNotification();
|
||||
|
||||
Reference in New Issue
Block a user