Skip to content

Commit

Permalink
update dependencies (mattermost#4958)
Browse files Browse the repository at this point in the history
* update dependencies

* revert keychain update

* Update dependencies & Fastlane

* set path agnostic for bash in scrips

* Fix open from push notification race

* patch react-native-localize
  • Loading branch information
enahum authored Nov 19, 2020
1 parent 4f668f0 commit b226d45
Show file tree
Hide file tree
Showing 62 changed files with 2,854 additions and 2,902 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

implementation project(':reactnativenotifications')
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation "com.google.firebase:firebase-messaging:$firebaseVersion"

// For animated GIF support
implementation 'com.facebook.fresco:fresco:2.0.0'
Expand Down
2 changes: 0 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
<meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" />
<meta-data android:name="android.content.APP_RESTRICTIONS"
android:resource="@xml/app_restrictions" />

<meta-data android:name="com.wix.reactnativenotifications.gcmSenderId" android:value="184930218130\"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,11 @@ private void setNotificationMessagingStyle(Notification.Builder notification, Bu

private Notification.MessagingStyle getMessagingStyle(Bundle bundle) {
Notification.MessagingStyle messagingStyle;
String senderId = bundle.getString("sender_id");

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P || senderId == null) {
messagingStyle = new Notification.MessagingStyle("");
} else {
String senderId = bundle.getString("sender_id");
Person sender = new Person.Builder()
.setKey(senderId)
.setName("")
Expand Down Expand Up @@ -364,15 +364,15 @@ private void addMessagingStyleMessages(Notification.MessagingStyle messagingStyl
int bundleCount = bundleList.size() - 1;
for (int i = bundleCount; i >= 0; i--) {
Bundle data = bundleList.get(i);
String message = data.getString("message");
String message = data.getString("message", data.getString("body"));
String senderId = data.getString("sender_id");
if (senderId == null) {
senderId = "sender_id";
}
Bundle userInfoBundle = data.getBundle("userInfo");
String senderName = getSenderName(data);
if (userInfoBundle != null) {
boolean localPushNotificationTest = userInfoBundle.getBoolean("localTest");
boolean localPushNotificationTest = userInfoBundle.getBoolean("test");
if (localPushNotificationTest) {
senderName = "Test";
}
Expand Down Expand Up @@ -403,13 +403,15 @@ private void setNotificationChannel(Notification.Builder notification, Bundle bu

NotificationChannel notificationChannel = mHighImportanceChannel;

boolean localPushNotificationTest = false;
boolean testNotification = false;
boolean localNotification = false;
Bundle userInfoBundle = bundle.getBundle("userInfo");
if (userInfoBundle != null) {
localPushNotificationTest = userInfoBundle.getBoolean("localTest");
testNotification = userInfoBundle.getBoolean("test");
localNotification = userInfoBundle.getBoolean("local");
}

if (mAppLifecycleFacade.isAppVisible() && !localPushNotificationTest) {
if (mAppLifecycleFacade.isAppVisible() && !testNotification && !localNotification) {
notificationChannel = mMinImportanceChannel;
}

Expand Down
3 changes: 2 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ buildscript {
targetSdkVersion = 29
supportLibVersion = "28.0.0"
kotlinVersion = "1.3.61"
firebaseVersion = "21.0.0"
RNNKotlinVersion = kotlinVersion

}
Expand All @@ -20,7 +21,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rootProject.name = 'Mattermost'
include ':reactnativenotifications'
project(':reactnativenotifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/android/app')
project(':reactnativenotifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/lib/android/app')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
2 changes: 2 additions & 0 deletions app/actions/views/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ export function markChannelViewedAndRead(channelId, previousChannelId, markOnSer
const actions = markAsViewedAndReadBatch(state, channelId, previousChannelId, markOnServer);

dispatch(batchActions(actions, 'BATCH_MARK_CHANNEL_VIEWED_AND_READ'));

return {data: true};
};
}

Expand Down
10 changes: 5 additions & 5 deletions app/actions/views/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {isTimezoneEnabled} from '@mm-redux/selectors/entities/timezone';
import {getCurrentUserId} from '@mm-redux/selectors/entities/users';

import {setAppCredentials} from 'app/init/credentials';
import PushNotifications from 'app/push_notifications';
import PushNotifications from '@init/push_notifications';
import {getDeviceTimezone} from 'app/utils/timezone';
import {setCSRFFromCookie} from 'app/utils/security';
import {loadConfigAndLicense} from 'app/actions/views/root';
Expand Down Expand Up @@ -94,11 +94,11 @@ export function scheduleExpiredNotification(intl) {
});

if (expiresAt) {
PushNotifications.localNotificationSchedule({
date: new Date(expiresAt),
message,
PushNotifications.scheduleNotification({
fireDate: expiresAt,
body: message,
userInfo: {
localNotification: true,
local: true,
},
});
}
Expand Down
10 changes: 6 additions & 4 deletions app/actions/views/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ export function loadConfigAndLicense() {
export function loadFromPushNotification(notification) {
return async (dispatch, getState) => {
const state = getState();
const {data} = notification;
const {payload} = notification;
const {currentTeamId, teams, myMembers: myTeamMembers} = state.entities.teams;
const {channels} = state.entities.channels;

let channelId = '';
let teamId = currentTeamId;
if (data) {
channelId = data.channel_id;
if (payload) {
channelId = payload.channel_id;

// when the notification does not have a team id is because its from a DM or GM
teamId = data.team_id || currentTeamId;
teamId = payload.team_id || currentTeamId;
}

// load any missing data
Expand All @@ -96,6 +96,8 @@ export function loadFromPushNotification(notification) {
}

dispatch(handleSelectTeamAndChannel(teamId, channelId));

return {data: true};
};
}

Expand Down
10 changes: 5 additions & 5 deletions app/actions/views/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {Client4} from '@mm-redux/client';
import {getConfig} from '@mm-redux/selectors/entities/general';
import {isMinimumServerVersion} from '@mm-redux/utils/helpers';

import PushNotifications from 'app/push_notifications';
import PushNotifications from '@init/push_notifications';

const sortByNewest = (a, b) => {
if (a.create_at > b.create_at) {
Expand Down Expand Up @@ -56,11 +56,11 @@ export function scheduleExpiredNotification(intl) {
if (expiresAt) {
// eslint-disable-next-line no-console
console.log('Schedule Session Expiry Local Push Notification', expiresAt);
PushNotifications.localNotificationSchedule({
date: new Date(expiresAt),
message,
PushNotifications.scheduleNotification({
fireDate: expiresAt,
body: message,
userInfo: {
localNotification: true,
local: true,
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/network_indicator/network_indicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import networkConnectionListener, {checkConnection} from '@utils/network';
import {t} from '@utils/i18n';

import mattermostBucket from 'app/mattermost_bucket';
import PushNotifications from 'app/push_notifications';
import PushNotifications from '@init/push_notifications';

const MAX_WEBSOCKET_RETRIES = 3;
const CONNECTION_RETRY_SECONDS = 5;
Expand Down
6 changes: 3 additions & 3 deletions app/init/global_event_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {loadMe, logout} from '@actions/views/user';
import LocalConfig from '@assets/config';
import {NavigationTypes, ViewTypes} from '@constants';
import {getTranslations, resetMomentLocale} from '@i18n';
import PushNotifications from '@init/push_notifications';
import {setAppState, setServerVersion} from '@mm-redux/actions/general';
import {getTeams} from '@mm-redux/actions/teams';
import {autoUpdateTimezone} from '@mm-redux/actions/timezone';
Expand All @@ -38,7 +39,6 @@ import {getDeviceTimezone} from '@utils/timezone';

import mattermostBucket from 'app/mattermost_bucket';
import mattermostManaged from 'app/mattermost_managed';
import PushNotifications from 'app/push_notifications';

import {getAppCredentials, removeAppCredentials} from './credentials';
import emmProvider from './emm_provider';
Expand Down Expand Up @@ -384,12 +384,12 @@ class GlobalEventHandler {
}

handleInAppNotification = (notification) => {
const {data} = notification;
const {payload} = notification;
const {getState} = Store.redux;
const state = getState();
const currentChannelId = getCurrentChannelId(state);

if (data && data.channel_id !== currentChannelId) {
if (payload?.channel_id !== currentChannelId) {
const screen = 'Notification';
const passProps = {
notification,
Expand Down
10 changes: 1 addition & 9 deletions app/init/global_event_handler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import semver from 'semver/preload';

import {MinServerVersion} from '@assets/config';
import * as I18n from '@i18n';
import PushNotification from '@init/push_notifications';
import EventEmitter from '@mm-redux/utils/event_emitter';
import Store from '@store/store';
import intitialState from '@store/initial_state';

import PushNotification from 'app/push_notifications';
import mattermostBucket from 'app/mattermost_bucket';

import GlobalEventHandler from './global_event_handler';
Expand All @@ -29,14 +29,6 @@ jest.mock('@utils/error_handling', () => ({
},
}));

jest.mock('react-native-notifications', () => ({
addEventListener: jest.fn(),
cancelAllLocalNotifications: jest.fn(),
setBadgesCount: jest.fn(),
NotificationAction: jest.fn(),
NotificationCategory: jest.fn(),
}));

jest.mock('react-native-status-bar-size', () => ({
addEventListener: jest.fn(),
}));
Expand Down
Loading

0 comments on commit b226d45

Please sign in to comment.