MM-18024 MM-18025 Fix race condition when push notification opens the app and credentials are not set (#3171)
This commit is contained in:
parent
0115610152
commit
b36b395a0b
4 changed files with 32 additions and 11 deletions
|
|
@ -134,6 +134,10 @@ export default class PostList extends PureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
getItemCount = () => {
|
||||
return this.props.postIds.length;
|
||||
};
|
||||
|
||||
handleClosePermalink = () => {
|
||||
const {actions} = this.props;
|
||||
actions.selectFocusedPostId('');
|
||||
|
|
@ -301,9 +305,8 @@ export default class PostList extends PureComponent {
|
|||
}, 250);
|
||||
};
|
||||
|
||||
scrollToInitialIndexIfNeeded = (index) => {
|
||||
if (!this.hasDoneInitialScroll && this.flatListRef?.current) {
|
||||
this.hasDoneInitialScroll = true;
|
||||
scrollToIndex = (index) => {
|
||||
if (this.flatListRef?.current) {
|
||||
this.animationFrameInitialIndex = requestAnimationFrame(() => {
|
||||
this.flatListRef.current.scrollToIndex({
|
||||
animated: false,
|
||||
|
|
@ -315,6 +318,20 @@ export default class PostList extends PureComponent {
|
|||
}
|
||||
};
|
||||
|
||||
scrollToInitialIndexIfNeeded = (index, count = 0) => {
|
||||
if (!this.hasDoneInitialScroll && this.flatListRef?.current) {
|
||||
this.hasDoneInitialScroll = true;
|
||||
|
||||
if (index > 0 && index <= this.getItemCount()) {
|
||||
this.scrollToIndex(index);
|
||||
} else if (count < 3) {
|
||||
setTimeout(() => {
|
||||
this.scrollToInitialIndexIfNeeded(index, count + 1);
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
showPermalinkView = (postId) => {
|
||||
const {actions} = this.props;
|
||||
|
||||
|
|
|
|||
|
|
@ -181,7 +181,8 @@ class GlobalEventHandler {
|
|||
}
|
||||
|
||||
if (this.launchApp) {
|
||||
this.launchApp();
|
||||
const credentials = await getAppCredentials();
|
||||
this.launchApp(credentials);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,9 @@ const sharedExtensionStarted = Platform.OS === 'android' && MattermostShare.isOp
|
|||
export const store = configureStore(initialState);
|
||||
|
||||
const init = async () => {
|
||||
const credentials = await getAppCredentials();
|
||||
if (EphemeralStore.appStarted) {
|
||||
launchApp();
|
||||
launchApp(credentials);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -44,17 +45,16 @@ const init = async () => {
|
|||
}
|
||||
|
||||
if (!EphemeralStore.appStarted) {
|
||||
launchAppAndAuthenticateIfNeeded();
|
||||
launchAppAndAuthenticateIfNeeded(credentials);
|
||||
}
|
||||
};
|
||||
|
||||
const launchApp = async () => {
|
||||
const launchApp = async (credentials) => {
|
||||
telemetry.start([
|
||||
'start:select_server_screen',
|
||||
'start:channel_screen',
|
||||
]);
|
||||
|
||||
const credentials = await getAppCredentials();
|
||||
if (credentials) {
|
||||
store.dispatch(loadMe());
|
||||
store.dispatch(resetToChannel({skipMetrics: true}));
|
||||
|
|
@ -66,9 +66,9 @@ const launchApp = async () => {
|
|||
EphemeralStore.appStarted = true;
|
||||
};
|
||||
|
||||
const launchAppAndAuthenticateIfNeeded = async () => {
|
||||
const launchAppAndAuthenticateIfNeeded = async (credentials) => {
|
||||
await emmProvider.handleManagedConfig(store);
|
||||
await launchApp();
|
||||
await launchApp(credentials);
|
||||
|
||||
if (emmProvider.enabled) {
|
||||
if (emmProvider.jailbreakProtection) {
|
||||
|
|
|
|||
|
|
@ -127,7 +127,10 @@ class PushNotification {
|
|||
...notification.getData(),
|
||||
message: notification.getMessage(),
|
||||
};
|
||||
this.handleNotification(info, false, userInteraction);
|
||||
|
||||
if (!userInteraction) {
|
||||
this.handleNotification(info, false, userInteraction);
|
||||
}
|
||||
};
|
||||
|
||||
onNotificationReceivedForeground = (notification) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue