From 13f6de11738b3cc52b040ccec937669248b7e582 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Tue, 11 Feb 2025 17:21:26 +0800 Subject: [PATCH] 2.25 fixes (#8578) --- .../NotificationReplyBroadcastReceiver.java | 30 +++++++-------- .../mattermost/rnbeta/ReceiptDelivery.java | 1 + .../home/recent_mentions/recent_mentions.tsx | 16 ++++---- .../home/saved_messages/saved_messages.tsx | 16 ++++---- app/screens/home/search/search.tsx | 38 +++++++++---------- ios/Podfile.lock | 4 +- package-lock.json | 8 ++-- package.json | 2 +- 8 files changed, 57 insertions(+), 58 deletions(-) diff --git a/android/app/src/main/java/com/mattermost/rnbeta/NotificationReplyBroadcastReceiver.java b/android/app/src/main/java/com/mattermost/rnbeta/NotificationReplyBroadcastReceiver.java index 3fd32a77863..36c4eae78f1 100644 --- a/android/app/src/main/java/com/mattermost/rnbeta/NotificationReplyBroadcastReceiver.java +++ b/android/app/src/main/java/com/mattermost/rnbeta/NotificationReplyBroadcastReceiver.java @@ -9,20 +9,18 @@ import android.content.Intent; import android.os.Bundle; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.app.NotificationCompat; import androidx.core.app.Person; -import com.facebook.react.ReactApplication; -import com.facebook.react.ReactNativeHost; import com.facebook.react.bridge.Arguments; -import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.WritableMap; import com.mattermost.helpers.*; import com.mattermost.turbolog.TurboLog; import com.wix.reactnativenotifications.core.NotificationIntentAdapter; -import com.wix.reactnativenotifications.core.notification.INotificationsApplication; import com.wix.reactnativenotifications.core.notification.PushNotificationProps; public class NotificationReplyBroadcastReceiver extends BroadcastReceiver { @@ -30,15 +28,6 @@ public class NotificationReplyBroadcastReceiver extends BroadcastReceiver { private Bundle bundle; private NotificationManager notificationManager; - private ReactApplicationContext getReactContext(Context context) { - if (context instanceof ReactApplication) { - ReactNativeHost host = ((ReactApplication) context).getReactNativeHost(); - return (ReactApplicationContext) host.getReactInstanceManager().getCurrentReactContext(); - } - - return null; - } - @Override public void onReceive(Context context, Intent intent) { try { @@ -80,7 +69,6 @@ protected void replyToMessage(final String serverUrl, final int notificationId, WritableMap headers = Arguments.createMap(); headers.putString("Content-Type", "application/json"); - WritableMap body = Arguments.createMap(); body.putString("channel_id", channelId); body.putString("message", message.toString()); @@ -92,9 +80,19 @@ protected void replyToMessage(final String serverUrl, final int notificationId, String postsEndpoint = "/api/v4/posts?set_online=false"; Network.post(serverUrl, postsEndpoint, options, new ResolvePromise() { + private boolean isSuccessful(int statusCode) { + return statusCode >= 200 && statusCode < 300; + } @Override public void resolve(@Nullable Object value) { if (value != null) { + ReadableMap response = (ReadableMap)value; + ReadableMap data = response.getMap("data"); + if (data != null && data.hasKey("status_code") && !isSuccessful(data.getInt("status_code"))) { + TurboLog.Companion.i("ReactNative", String.format("Reply FAILED exception %s", data.getString("message"))); + onReplyFailed(notificationId); + return; + } onReplySuccess(notificationId, message); TurboLog.Companion.i("ReactNative", "Reply SUCCESS"); } else { @@ -104,13 +102,13 @@ public void resolve(@Nullable Object value) { } @Override - public void reject(Throwable reason) { + public void reject(@NonNull Throwable reason) { TurboLog.Companion.i("ReactNative", String.format("Reply FAILED exception %s", reason.getMessage())); onReplyFailed(notificationId); } @Override - public void reject(String code, String message) { + public void reject(@NonNull String code, String message) { TurboLog.Companion.i("ReactNative", String.format("Reply FAILED status %s BODY %s", code, message) ); diff --git a/android/app/src/main/java/com/mattermost/rnbeta/ReceiptDelivery.java b/android/app/src/main/java/com/mattermost/rnbeta/ReceiptDelivery.java index 09a5e20f2c1..c88c1eea585 100644 --- a/android/app/src/main/java/com/mattermost/rnbeta/ReceiptDelivery.java +++ b/android/app/src/main/java/com/mattermost/rnbeta/ReceiptDelivery.java @@ -38,6 +38,7 @@ public static Bundle send(final String ackId, final String serverUrl, final Stri JSONObject jsonResponse = new JSONObject(responseBody); return parseAckResponse(jsonResponse); } catch (Exception e) { + TurboLog.Companion.e("ReactNative", "Send receipt delivery failed " + e.getMessage()); e.printStackTrace(); return null; } diff --git a/app/screens/home/recent_mentions/recent_mentions.tsx b/app/screens/home/recent_mentions/recent_mentions.tsx index de6d36fddc8..195d5f5fd6e 100644 --- a/app/screens/home/recent_mentions/recent_mentions.tsx +++ b/app/screens/home/recent_mentions/recent_mentions.tsx @@ -162,19 +162,19 @@ const RecentMentionsScreen = ({appsEnabled, customEmojiNames, mentions, currentT return ( - + diff --git a/app/screens/home/saved_messages/saved_messages.tsx b/app/screens/home/saved_messages/saved_messages.tsx index 930eaf0671b..5137ed9a2a7 100644 --- a/app/screens/home/saved_messages/saved_messages.tsx +++ b/app/screens/home/saved_messages/saved_messages.tsx @@ -164,19 +164,19 @@ function SavedMessages({appsEnabled, posts, currentTimezone, customEmojiNames}: return ( - + diff --git a/app/screens/home/search/search.tsx b/app/screens/home/search/search.tsx index d58bfc5d9b9..2c195c0e02a 100644 --- a/app/screens/home/search/search.tsx +++ b/app/screens/home/search/search.tsx @@ -370,31 +370,31 @@ const SearchScreen = ({teamId, teams, crossTeamSearchEnabled}: Props) => { return ( - + 5.10.2) - DoubleConversion - glog @@ -2518,7 +2518,7 @@ SPEC CHECKSUMS: react-native-emm: f6003bebdf4fef4feef7c61f96a5c174f43c6b5f react-native-image-picker: 130fad649d07e4eec8faaed361d3bba570e1e5ff react-native-netinfo: cec9c4e86083cb5b6aba0e0711f563e2fbbff187 - react-native-network-client: f2996a6440c422e64e787bdf8c8e3f992be1cee6 + react-native-network-client: fdbd7f5f4c2818d6b90b4dcf9613d0a54ab41303 react-native-notifications: 3bafa1237ae8a47569a84801f17d80242fe9f6a5 react-native-paste-input: d33daa183942fa57f34dff2088805a60895f14d2 react-native-performance: 125a96c145e29918b55b45ce25cbba54f1e24dcd diff --git a/package-lock.json b/package-lock.json index deecfacd8aa..8f088e9ca26 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "@mattermost/compass-icons": "0.1.48", "@mattermost/hardware-keyboard": "file:./libraries/@mattermost/hardware-keyboard", "@mattermost/react-native-emm": "1.5.1", - "@mattermost/react-native-network-client": "1.8.1", + "@mattermost/react-native-network-client": "1.8.2", "@mattermost/react-native-paste-input": "0.8.1", "@mattermost/react-native-turbo-log": "0.5.0", "@mattermost/rnshare": "file:./libraries/@mattermost/rnshare", @@ -4631,9 +4631,9 @@ } }, "node_modules/@mattermost/react-native-network-client": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/@mattermost/react-native-network-client/-/react-native-network-client-1.8.1.tgz", - "integrity": "sha512-CrIVcIkSJej2Dg2162z2U4qyL0QIV/LYuHd0wXh9wnrcGBjk8Dt0TDhUkUaTe8V1YKYVQiJU7vsL9GlDMxVuXQ==", + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@mattermost/react-native-network-client/-/react-native-network-client-1.8.2.tgz", + "integrity": "sha512-wveW7wuXqwjxt3udip1H3Uw72ApNmSo6ii2qx9HZ81+LX3FnhBJhlB6q7xF6KP8DUEOxRZHvPWwAtGxYKWI0lw==", "license": "MIT", "dependencies": { "validator": "13.12.0", diff --git a/package.json b/package.json index 203d9bdaac7..ef31b095a52 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@mattermost/compass-icons": "0.1.48", "@mattermost/hardware-keyboard": "file:./libraries/@mattermost/hardware-keyboard", "@mattermost/react-native-emm": "1.5.1", - "@mattermost/react-native-network-client": "1.8.1", + "@mattermost/react-native-network-client": "1.8.2", "@mattermost/react-native-paste-input": "0.8.1", "@mattermost/react-native-turbo-log": "0.5.0", "@mattermost/rnshare": "file:./libraries/@mattermost/rnshare",