MM-16463 Fix replying from push notification to a message in a thread (#2927)
This commit is contained in:
parent
02f97002d0
commit
c121f66526
5 changed files with 8 additions and 29 deletions
|
|
@ -57,7 +57,6 @@ public class InitializationModule extends ReactContextBaseJavaModule {
|
|||
*
|
||||
* Miscellaneous:
|
||||
* MattermostManaged.Config
|
||||
* replyFromPushNotification
|
||||
*/
|
||||
|
||||
MainApplication app = (MainApplication) mApplication;
|
||||
|
|
@ -138,8 +137,6 @@ public class InitializationModule extends ReactContextBaseJavaModule {
|
|||
}
|
||||
|
||||
constants.put("managedConfig", config[0]);
|
||||
constants.put("replyFromPushNotification", app.replyFromPushNotification);
|
||||
app.replyFromPushNotification = false;
|
||||
|
||||
return constants;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ import android.util.Log;
|
|||
public class MainApplication extends NavigationApplication implements INotificationsApplication, INotificationsDrawerApplication {
|
||||
public NotificationsLifecycleFacade notificationsLifecycleFacade;
|
||||
public Boolean sharedExtensionIsOpened = false;
|
||||
public Boolean replyFromPushNotification = false;
|
||||
|
||||
public long APP_START_TIME;
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,11 @@ public class NotificationReplyBroadcastReceiver extends BroadcastReceiver {
|
|||
|
||||
protected void replyToMessage(final String serverUrl, final String token, final int notificationId, final CharSequence message) {
|
||||
final String channelId = bundle.getString("channel_id");
|
||||
final String rootId = bundle.getString("post_id");
|
||||
final String postId = bundle.getString("post_id");
|
||||
String rootId = bundle.getString("root_id");
|
||||
if (android.text.TextUtils.isEmpty(rootId)) {
|
||||
rootId = postId;
|
||||
}
|
||||
|
||||
if (token == null || serverUrl == null) {
|
||||
onReplyFailed(notificationManager, notificationId, channelId);
|
||||
|
|
|
|||
|
|
@ -511,9 +511,8 @@ const launchEntry = () => {
|
|||
|
||||
configurePushNotifications();
|
||||
const startedSharedExtension = Platform.OS === 'android' && MattermostShare.isOpened;
|
||||
const fromPushNotification = Platform.OS === 'android' && Initialization.replyFromPushNotification;
|
||||
|
||||
if (startedSharedExtension || fromPushNotification) {
|
||||
if (startedSharedExtension) {
|
||||
// Hold on launching Entry screen
|
||||
app.setAppStarted(true);
|
||||
}
|
||||
|
|
@ -523,7 +522,7 @@ if (!app.appStarted) {
|
|||
}
|
||||
|
||||
new NativeEventsReceiver().appLaunched(() => {
|
||||
if (startedSharedExtension || fromPushNotification) {
|
||||
if (startedSharedExtension) {
|
||||
app.setAppStarted(false);
|
||||
launchEntry();
|
||||
} else if (app.token && app.url) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {AppRegistry, AppState, NativeModules} from 'react-native';
|
||||
import {AppState, NativeModules} from 'react-native';
|
||||
import {NotificationsAndroid, PendingNotifications} from 'react-native-notifications';
|
||||
import Notification from 'react-native-notifications/notification.android';
|
||||
|
||||
import {emptyFunction} from 'app/utils/general';
|
||||
|
||||
const {NotificationPreferences} = NativeModules;
|
||||
|
||||
|
|
@ -37,23 +34,6 @@ class PushNotification {
|
|||
this.handleNotification(data, true);
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerHeadlessTask('notificationReplied', () => async (deviceNotification) => {
|
||||
const notification = new Notification(deviceNotification);
|
||||
const data = notification.getData();
|
||||
const completed = emptyFunction;
|
||||
|
||||
if (this.onReply) {
|
||||
this.onReply(data, data.text, parseInt(data.badge, 10) - parseInt(data.msg_count, 10), completed);
|
||||
} else {
|
||||
this.deviceNotification = {
|
||||
data,
|
||||
text: data.text,
|
||||
badge: parseInt(data.badge, 10) - parseInt(data.msg_count, 10),
|
||||
completed, // used to identify that the notification belongs to a reply
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
handleNotification = (data, userInteraction) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue