Compare commits

...

6 Commits

Author SHA1 Message Date
Elias Nahum
6e08d69b10 Bump app version to 1.6.1 2018-02-12 16:15:53 -03:00
Elias Nahum
a8a95a98e7 Bump app build to 86 2018-02-12 15:21:22 -03:00
Stephen Kiers
b4b23d4d46 ICU-639- Fixes bug with Samsung keyboard (#1427)
* Internalized value to local state so that there is less ‘delay’ and less surface area for bugs to happen

* removed toLowercase on comparison and fixed parent components instead

* Update more_channels.js
2018-02-12 14:04:17 -03:00
enahum
99cff03193 Fix Android stuck when opening from push notification (#1429) 2018-02-12 14:04:02 -03:00
enahum
b9864bf26f Fix Android app stuck in splash screen when killed by the OS (#1403) 2018-02-12 09:09:07 -03:00
enahum
e73b9017fc Fix race condition preventing the app opened from a PN to go to the correct channel (#1398)
* Fix race condition preventing the app opened from a PN to go to the correct channel

* Feedback review
2018-02-12 09:08:23 -03:00
26 changed files with 276 additions and 458 deletions

View File

@@ -76,6 +76,7 @@ post-install:
@sed -i'' -e 's|"./locale-data/complete.js": false|"./locale-data/complete.js": "./locale-data/complete.js"|g' node_modules/intl/package.json
@sed -i'' -e 's|auto("auto", Configuration.ORIENTATION_UNDEFINED, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);|auto("auto", Configuration.ORIENTATION_UNDEFINED, ActivityInfo.SCREEN_ORIENTATION_FULL_USER);|g' node_modules/react-native-navigation/android/app/src/main/java/com/reactnativenavigation/params/Orientation.java
@sed -i'' -e "s|var AndroidTextInput = requireNativeComponent('AndroidTextInput', null);|var AndroidTextInput = requireNativeComponent('CustomTextInput', null);|g" node_modules/react-native/Libraries/Components/TextInput/TextInput.js
@sed -i'' -e "s|super.onBackPressed();|this.moveTaskToBack(true);|g" node_modules/react-native-navigation/android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java
@if [ $(shell grep "const Platform" node_modules/react-native/Libraries/Lists/VirtualizedList.js | grep -civ grep) -eq 0 ]; then \
sed $ -i'' -e "s|const ReactNative = require('ReactNative');|const ReactNative = require('ReactNative');`echo $\\\\\\r;`const Platform = require('Platform');|g" node_modules/react-native/Libraries/Lists/VirtualizedList.js; \
fi

View File

@@ -106,8 +106,8 @@ android {
applicationId "com.mattermost.rnbeta"
minSdkVersion 21
targetSdkVersion 23
versionCode 85
versionName "1.6.0"
versionCode 86
versionName "1.6.1"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86"

View File

@@ -1,10 +1,31 @@
package com.mattermost.rnbeta;
import android.os.Bundle;
import android.support.annotation.Nullable;
import com.reactnativenavigation.controllers.SplashActivity;
public class MainActivity extends SplashActivity {
@Override
public int getSplashLayout() {
return R.layout.launch_screen;
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/**
* Reference: https://stackoverflow.com/questions/7944338/resume-last-activity-when-launcher-icon-is-clicked
* 1. Open app from launcher/appDrawer
* 2. Go home
* 3. Send notification and open
* 4. It creates a new Activity and Destroys the old
* 5. Causing an unnecessary app restart
* 6. This solution short-circuits the restart
*/
if (!isTaskRoot()) {
finish();
return;
}
}
@Override
public int getSplashLayout() {
return R.layout.launch_screen;
}
}

View File

@@ -93,6 +93,13 @@ public class MainApplication extends NavigationApplication implements INotificat
SoLoader.init(this, /* native exopackage */ false);
}
@Override
public boolean clearHostOnActivityDestroy() {
// This solves the issue where the splash screen does not go away
// after the app is killed by the OS cause of memory or a long time in the background
return false;
}
@Override
public IPushNotification getPushNotification(Context context, Bundle bundle, AppLifecycleFacade defaultFacade, AppLaunchHelper defaultAppLaunchHelper) {
return new CustomPushNotification(

View File

@@ -39,12 +39,11 @@ public class NotificationsLifecycleFacade extends ActivityCallbacks implements A
private final BroadcastReceiver restrictionsReceiver = new BroadcastReceiver() {
@Override public void onReceive(Context context, Intent intent) {
if (mVisibleActivity != null) {
if (context != null) {
// Get the current configuration bundle
RestrictionsManager myRestrictionsMgr =
(RestrictionsManager) mVisibleActivity
.getSystemService(Context.RESTRICTIONS_SERVICE);
(RestrictionsManager) context
.getSystemService(Context.RESTRICTIONS_SERVICE);
managedConfig = myRestrictionsMgr.getApplicationRestrictions();
// Check current configuration settings, change your app's UI and
@@ -66,11 +65,11 @@ public class NotificationsLifecycleFacade extends ActivityCallbacks implements A
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
MattermostManagedModule managedModule = MattermostManagedModule.getInstance();
if (managedModule != null && managedModule.isBlurAppScreenEnabled()) {
if (managedModule != null && managedModule.isBlurAppScreenEnabled() && activity != null) {
activity.getWindow().setFlags(LayoutParams.FLAG_SECURE,
LayoutParams.FLAG_SECURE);
}
if (managedConfig!= null && managedConfig.size() > 0) {
if (managedConfig!= null && managedConfig.size() > 0 && activity != null) {
activity.registerReceiver(restrictionsReceiver, restrictionsFilter);
}
}
@@ -79,9 +78,11 @@ public class NotificationsLifecycleFacade extends ActivityCallbacks implements A
public void onActivityResumed(Activity activity) {
switchToVisible(activity);
if (managedConfig != null && managedConfig.size() > 0) {
ReactContext ctx = getRunningReactContext();
if (managedConfig != null && managedConfig.size() > 0 && ctx != null) {
RestrictionsManager myRestrictionsMgr =
(RestrictionsManager) activity
(RestrictionsManager) ctx
.getSystemService(Context.RESTRICTIONS_SERVICE);
Bundle newConfig = myRestrictionsMgr.getApplicationRestrictions();
@@ -174,13 +175,15 @@ public class NotificationsLifecycleFacade extends ActivityCallbacks implements A
}
}
public synchronized void LoadManagedConfig(Activity activity) {
RestrictionsManager myRestrictionsMgr =
(RestrictionsManager) activity
.getSystemService(Context.RESTRICTIONS_SERVICE);
public synchronized void LoadManagedConfig(ReactContext ctx) {
if (ctx != null) {
RestrictionsManager myRestrictionsMgr =
(RestrictionsManager) ctx
.getSystemService(Context.RESTRICTIONS_SERVICE);
managedConfig = myRestrictionsMgr.getApplicationRestrictions();
myRestrictionsMgr = null;
managedConfig = myRestrictionsMgr.getApplicationRestrictions();
myRestrictionsMgr = null;
}
}
public synchronized Bundle getManagedConfig() {
@@ -188,8 +191,10 @@ public class NotificationsLifecycleFacade extends ActivityCallbacks implements A
return managedConfig;
}
if (mVisibleActivity != null) {
LoadManagedConfig(mVisibleActivity);
ReactContext ctx = getRunningReactContext();
if (ctx != null) {
LoadManagedConfig(ctx);
return managedConfig;
}
@@ -198,9 +203,11 @@ public class NotificationsLifecycleFacade extends ActivityCallbacks implements A
public void sendConfigChanged(Bundle config) {
Object result = Arguments.fromBundle(config);
getRunningReactContext().
getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).
emit("managedConfigDidChange", result);
ReactContext ctx = getRunningReactContext();
if (ctx != null) {
ctx.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).
emit("managedConfigDidChange", result);
}
}
private boolean equalBundles(Bundle one, Bundle two) {

View File

@@ -460,7 +460,8 @@ export function increasePostVisibility(channelId, focusedPostId) {
// Check if we already have the posts that we want to show
if (!focusedPostId) {
const loadedPostCount = state.entities.posts.postsInChannel[channelId].length;
const postsInChannel = state.entities.posts.postsInChannel[channelId] || [];
const loadedPostCount = postsInChannel.length;
const desiredPostVisibility = currentPostVisibility + ViewTypes.POST_VISIBILITY_CHUNK_SIZE;
if (loadedPostCount >= desiredPostVisibility) {

View File

@@ -3,7 +3,7 @@
import {getDataRetentionPolicy} from 'mattermost-redux/actions/general';
import {GeneralTypes} from 'mattermost-redux/action_types';
import {Client, Client4} from 'mattermost-redux/client';
import {Client4} from 'mattermost-redux/client';
import {ViewTypes} from 'app/constants';
@@ -39,9 +39,6 @@ export function handleSuccessfulLogin() {
}
}, getState);
Client.setToken(token);
Client.setUrl(url);
if (config.DataRetentionEnableMessageDeletion && config.DataRetentionEnableMessageDeletion === 'true' &&
license.IsLicensed === 'true' && license.DataRetention === 'true') {
getDataRetentionPolicy()(dispatch, getState);

View File

@@ -3,7 +3,7 @@
import {connect} from 'react-redux';
import {Client, Client4} from 'mattermost-redux/client';
import {Client4} from 'mattermost-redux/client';
import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels';
import {getCurrentUrl} from 'mattermost-redux/selectors/entities/general';
@@ -15,7 +15,6 @@ import Root from './root';
function mapStateToProps(state) {
const locale = getCurrentLocale(state);
Client.setLocale(locale);
Client4.setAcceptLanguage(locale);
return {

View File

@@ -66,9 +66,15 @@ export default class SearchBarAndroid extends PureComponent {
constructor(props) {
super(props);
this.state = {
value: props.value,
isFocused: false
};
}
componentWillReceiveProps(nextProps) {
if (this.state.value !== nextProps.value) {
this.setState({value: nextProps.value});
}
}
cancel = () => {
this.onCancelButtonPress();
@@ -102,7 +108,9 @@ export default class SearchBarAndroid extends PureComponent {
};
onChangeText = (value) => {
this.props.onChangeText(value);
this.setState({value}, () => {
this.props.onChangeText(value);
});
};
onSelectionChange = (event) => {
@@ -196,7 +204,7 @@ export default class SearchBarAndroid extends PureComponent {
<TextInput
ref='input'
blurOnSubmit={blurOnSubmit}
value={value}
value={this.state.value}
autoCapitalize={autoCapitalize}
autoCorrect={false}
returnKeyType={returnKeyType || 'search'}

View File

@@ -23,9 +23,9 @@ import {General} from 'mattermost-redux/constants';
import {setAppState, setDeviceToken, setServerVersion} from 'mattermost-redux/actions/general';
import {markChannelAsRead} from 'mattermost-redux/actions/channels';
import {logError} from 'mattermost-redux/actions/errors';
import {logout} from 'mattermost-redux/actions/users';
import {loadMe, logout} from 'mattermost-redux/actions/users';
import {close as closeWebSocket} from 'mattermost-redux/actions/websocket';
import {Client, Client4} from 'mattermost-redux/client';
import {Client4} from 'mattermost-redux/client';
import EventEmitter from 'mattermost-redux/utils/event_emitter';
import {
@@ -52,58 +52,41 @@ import configureStore from 'app/store';
import mattermostManaged from 'app/mattermost_managed';
import {deleteFileCache} from 'app/utils/file';
import {init as initAnalytics} from 'app/utils/segment';
import {
captureException,
initializeSentry,
LOGGER_JAVASCRIPT,
LOGGER_NATIVE
} from 'app/utils/sentry';
import {captureException, initializeSentry, LOGGER_JAVASCRIPT, LOGGER_NATIVE} from 'app/utils/sentry';
import tracker from 'app/utils/time_tracker';
import {stripTrailingSlashes} from 'app/utils/url';
import Config from 'assets/config';
import LocalConfig from 'assets/config';
const {StatusBarManager} = NativeModules;
const AUTHENTICATION_TIMEOUT = 5 * 60 * 1000;
export default class Mattermost {
constructor() {
if (Platform.OS === 'android') {
// This is to remove the warnings for the scaleY property used in android.
// The property is necessary because some Android devices won't render the posts
// properly if we use transform: {scaleY: -1} in the stylesheet.
console.ignoredYellowBox = ['`scaleY`']; //eslint-disable-line
}
this.isConfigured = false;
this.allowOtherServers = true;
this.startAppFromPushNotification = false;
this.emmEnabled = false;
Client4.setUserAgent(DeviceInfo.getUserAgent());
Orientation.unlockAllOrientations();
initializeSentry();
this.store = configureStore(initialState);
registerScreens(this.store, Provider);
this.unsubscribeFromStore = this.store.subscribe(this.listenForHydration);
AppState.addEventListener('change', this.handleAppStateChange);
EventEmitter.on(General.CONFIG_CHANGED, this.handleConfigChanged);
EventEmitter.on(NavigationTypes.NAVIGATION_RESET, this.handleReset);
EventEmitter.on(General.DEFAULT_CHANNEL, this.handleResetDisplayName);
EventEmitter.on(General.CONFIG_CHANGED, this.handleServerConfigChanged);
EventEmitter.on(NavigationTypes.NAVIGATION_RESET, this.handleLogout);
EventEmitter.on(General.DEFAULT_CHANNEL, this.handleResetChannelDisplayName);
EventEmitter.on(NavigationTypes.RESTART_APP, this.restartApp);
Orientation.addOrientationListener(this.orientationDidChange);
mattermostManaged.addEventListener('managedConfigDidChange', this.handleManagedConfig);
this.handleAppStateChange(AppState.currentState);
Client4.setUserAgent(DeviceInfo.getUserAgent());
if (Platform.OS === 'ios') {
StatusBarSizeIOS.addEventListener('willChange', this.handleStatusBarHeightChange);
StatusBarManager.getHeight(
(data) => {
this.handleStatusBarHeightChange(data.height);
}
);
}
registerScreens(this.store, Provider);
setJSExceptionHandler(this.errorHandler, false);
setNativeExceptionHandler(this.nativeErrorHandler, false);
}
@@ -114,7 +97,10 @@ export default class Mattermost {
const intl = this.getIntl();
closeWebSocket()(this.store.dispatch, this.store.getState);
logError(e)(this.store.dispatch);
if (Client4.getUrl()) {
logError(e)(this.store.dispatch);
}
if (isFatal) {
Alert.alert(
@@ -150,7 +136,7 @@ export default class Mattermost {
};
configureAnalytics = (config) => {
if (config && config.DiagnosticsEnabled === 'true' && config.DiagnosticId && Config.SegmentApiKey) {
if (config && config.DiagnosticsEnabled === 'true' && config.DiagnosticId && LocalConfig.SegmentApiKey) {
initAnalytics(config);
} else {
global.analytics = null;
@@ -171,37 +157,39 @@ export default class Mattermost {
handleAppStateChange = async (appState) => {
const {dispatch, getState} = this.store;
const isActive = appState === 'active';
setAppState(isActive)(dispatch, getState);
if (isActive && this.shouldRelaunchonActive) {
if (isActive && this.shouldRelaunchWhenActive) {
// This handles when the app was started in the background
// cause of an iOS push notification reply
this.launchApp();
this.shouldRelaunchonActive = false;
} else {
this.shouldRelaunchWhenActive = false;
} else if (!isActive && !this.inBackgroundSince) {
// When the app is sent to the background we set the time when that happens
// and perform a data clean up to improve on performance
this.inBackgroundSince = Date.now();
dispatch({type: ViewTypes.DATA_CLEANUP, payload: getState()});
} else if (isActive && this.inBackgroundSince && (Date.now() - this.inBackgroundSince) >= AUTHENTICATION_TIMEOUT && this.emmEnabled) {
// Once the app becomes active after more than 5 minutes in the background and is controlled by an EMM
try {
if (!isActive && !this.inBackgroundSince) {
this.inBackgroundSince = Date.now();
dispatch({type: ViewTypes.DATA_CLEANUP, payload: getState()});
} else if (isActive && this.inBackgroundSince && (Date.now() - this.inBackgroundSince) >= AUTHENTICATION_TIMEOUT) {
this.inBackgroundSince = null;
if (this.mdmEnabled) {
const config = await mattermostManaged.getConfig();
const authNeeded = config.inAppPinCode && config.inAppPinCode === 'true';
if (authNeeded) {
const authenticated = await this.handleAuthentication(config.vendor);
if (!authenticated) {
mattermostManaged.quitApp();
}
}
const config = await mattermostManaged.getConfig();
const authNeeded = config.inAppPinCode && config.inAppPinCode === 'true';
if (authNeeded) {
const authenticated = await this.handleAuthentication(config.vendor);
if (!authenticated) {
mattermostManaged.quitApp();
}
} else if (isActive) {
this.inBackgroundSince = null;
Keyboard.dismiss();
}
} catch (error) {
// do nothing
}
}
if (isActive) {
this.inBackgroundSince = null;
Keyboard.dismiss();
}
};
handleAuthentication = async (vendor) => {
@@ -227,20 +215,20 @@ export default class Mattermost {
return true;
};
handleConfigChanged = async (serverVersion) => {
handleServerConfigChanged = async (serverVersion) => {
const {dispatch, getState} = this.store;
const version = serverVersion.match(/^[0-9]*.[0-9]*.[0-9]*(-[a-zA-Z0-9.-]*)?/g)[0];
const intl = this.getIntl();
const state = getState();
if (serverVersion) {
if (semver.valid(version) && semver.lt(version, Config.MinServerVersion)) {
if (semver.valid(version) && semver.lt(version, LocalConfig.MinServerVersion)) {
Alert.alert(
intl.formatMessage({id: 'mobile.server_upgrade.title', defaultMessage: 'Server upgrade required'}),
intl.formatMessage({id: 'mobile.server_upgrade.description', defaultMessage: '\nA server upgrade is required to use the Mattermost app. Please ask your System Administrator for details.\n'}),
[{
text: intl.formatMessage({id: 'mobile.server_upgrade.button', defaultMessage: 'OK'}),
onPress: this.handleVersionUpgrade
onPress: this.handleServerVersionUpgradeNeeded
}],
{cancelable: false}
);
@@ -263,15 +251,15 @@ export default class Mattermost {
let serverUrl = null;
let username = null;
if (Config.AutoSelectServerUrl) {
handleServerUrlChanged(Config.DefaultServerUrl)(dispatch, getState);
if (LocalConfig.AutoSelectServerUrl) {
handleServerUrlChanged(LocalConfig.DefaultServerUrl)(dispatch, getState);
this.allowOtherServers = false;
}
try {
const config = await mattermostManaged.getConfig();
if (config) {
this.mdmEnabled = true;
if (config && Object.keys(config).length) {
this.emmEnabled = true;
authNeeded = config.inAppPinCode && config.inAppPinCode === 'true';
blurApplicationScreen = config.blurApplicationScreen && config.blurApplicationScreen === 'true';
jailbreakProtection = config.jailbreakProtection && config.jailbreakProtection === 'true';
@@ -285,74 +273,72 @@ export default class Mattermost {
this.allowOtherServers = false;
}
}
if (jailbreakProtection) {
const isTrusted = mattermostManaged.isTrustedDevice();
if (!isTrusted) {
const intl = this.getIntl();
Alert.alert(
intl.formatMessage({
id: 'mobile.managed.blocked_by',
defaultMessage: 'Blocked by {vendor}'
}, {vendor}),
intl.formatMessage({
id: 'mobile.managed.jailbreak',
defaultMessage: 'Jailbroken devices are not trusted by {vendor}, please exit the app.'
}, {vendor}),
[{
text: intl.formatMessage({id: 'mobile.managed.exit', defaultMessage: 'Exit'}),
style: 'destructive',
onPress: () => {
mattermostManaged.quitApp();
}
}],
{cancelable: false}
);
return false;
}
}
if (authNeeded && !serverConfig) {
if (Platform.OS === 'android') {
//Start a fake app as we need at least one activity for android
await this.startFakeApp();
}
const authenticated = await this.handleAuthentication(vendor);
if (!authenticated) {
return false;
}
}
if (blurApplicationScreen) {
mattermostManaged.blurAppScreen(true);
}
if (serverUrl) {
handleServerUrlChanged(serverUrl)(dispatch, getState);
}
if (username) {
handleLoginIdChanged(username)(dispatch, getState);
}
}
} catch (error) {
return true;
}
if (this.mdmEnabled) {
if (jailbreakProtection) {
const isTrusted = mattermostManaged.isTrustedDevice();
if (!isTrusted) {
const intl = this.getIntl();
Alert.alert(
intl.formatMessage({
id: 'mobile.managed.blocked_by',
defaultMessage: 'Blocked by {vendor}'
}, {vendor}),
intl.formatMessage({
id: 'mobile.managed.jailbreak',
defaultMessage: 'Jailbroken devices are not trusted by {vendor}, please exit the app.'
}, {vendor}),
[{
text: intl.formatMessage({id: 'mobile.managed.exit', defaultMessage: 'Exit'}),
style: 'destructive',
onPress: () => {
mattermostManaged.quitApp();
}
}],
{cancelable: false}
);
return false;
}
}
if (authNeeded && !serverConfig) {
if (Platform.OS === 'android') {
//Start a fake app as we need at least one activity for android
await this.startFakeApp();
}
const authenticated = await this.handleAuthentication(vendor);
if (!authenticated) {
return false;
}
}
if (blurApplicationScreen) {
mattermostManaged.blurAppScreen(true);
}
if (serverUrl) {
handleServerUrlChanged(serverUrl)(dispatch, getState);
}
if (username) {
handleLoginIdChanged(username)(dispatch, getState);
}
}
return true;
};
handleReset = () => {
handleLogout = () => {
this.appStarted = false;
deleteFileCache();
this.resetBadgeAndVersion();
this.startApp('fade');
};
handleResetDisplayName = (displayName) => {
handleResetChannelDisplayName = (displayName) => {
this.store.dispatch(setChannelDisplayName(displayName));
};
@@ -360,48 +346,65 @@ export default class Mattermost {
this.store.dispatch(setStatusBarHeight(nextStatusBarHeight));
};
handleVersionUpgrade = async () => {
handleServerVersionUpgradeNeeded = async () => {
const {dispatch, getState} = this.store;
Client4.serverVersion = '';
PushNotifications.setApplicationIconBadgeNumber(0);
this.resetBadgeAndVersion();
if (getState().entities.general.credentials.token) {
InteractionManager.runAfterInteractions(() => {
logout()(dispatch, getState);
});
} else {
this.resetBadgeAndVersion();
}
};
// We need to wait for hydration to occur before load the router.
listenForHydration = () => {
const state = this.store.getState();
const {dispatch, getState} = this.store;
const state = getState();
if (!this.isConfigured) {
this.configurePushNotifications();
}
if (state.views.root.hydrationComplete) {
const orientation = Orientation.getInitialOrientation();
const {credentials, config} = state.entities.general;
const {currentUserId} = state.entities.users;
const isNotActive = AppState.currentState !== 'active';
const notification = PushNotifications.getNotification();
this.unsubscribeFromStore();
const orientation = Orientation.getInitialOrientation();
if (this.deviceToken) {
// If the deviceToken is set we need to dispatch it to the redux store
setDeviceToken(this.deviceToken)(dispatch, getState);
}
if (orientation) {
this.orientationDidChange(orientation);
}
const {config} = state.entities.general;
if (config) {
this.configureAnalytics(config);
}
const {currentUserId} = state.entities.users;
if (credentials.token && credentials.url) {
Client4.setToken(credentials.token);
Client4.setUrl(stripTrailingSlashes(credentials.url));
}
if (currentUserId) {
Client4.setUserId(currentUserId);
}
const isNotActive = AppState.currentState !== 'active';
const notification = PushNotifications.getNotification();
if (Platform.OS === 'ios') {
StatusBarManager.getHeight(
(data) => {
this.handleStatusBarHeightChange(data.height);
}
);
}
if (notification || this.replyNotificationData) {
// If we have a notification means that the app was started cause of a reply
// and the app was not sitting in the background nor opened
@@ -414,6 +417,10 @@ export default class Mattermost {
if (Platform.OS === 'android') {
// In case of Android we need to handle the bridge being initialized by HeadlessJS
Promise.resolve(Navigation.isAppLaunched()).then((appLaunched) => {
if (this.startAppFromPushNotification) {
return;
}
if (appLaunched) {
this.launchApp(); // App is launched -> show UI
} else {
@@ -422,7 +429,7 @@ export default class Mattermost {
});
} else if (isNotActive) {
// for IOS replying from push notification starts the app in the background
this.shouldRelaunchonActive = true;
this.shouldRelaunchWhenActive = true;
this.startFakeApp();
} else {
this.launchApp();
@@ -443,19 +450,23 @@ export default class Mattermost {
prefix = General.PUSH_NOTIFY_ANDROID_REACT_NATIVE;
}
setDeviceToken(`${prefix}:${data.token}`)(dispatch, getState);
const state = getState();
const token = `${prefix}:${data.token}`;
if (state.views.root.hydrationComplete) {
setDeviceToken(token)(dispatch, getState);
} else {
this.deviceToken = token;
}
};
onPushNotification = (deviceNotification) => {
const {dispatch, getState} = this.store;
const state = getState();
const {token, url} = state.entities.general.credentials;
let startAppFromPushNotification = false;
// mark the app as started as soon as possible
if (token && url && !this.appStarted) {
this.appStarted = true;
startAppFromPushNotification = true;
if (!this.appStarted && Platform.OS !== 'ios') {
this.startAppFromPushNotification = true;
}
const {data, foreground, message, userInfo, userInteraction} = deviceNotification;
@@ -474,18 +485,16 @@ export default class Mattermost {
EventEmitter.emit(ViewTypes.NOTIFICATION_IN_APP, notification);
} else if (userInteraction && !notification.localNotification) {
EventEmitter.emit('close_channel_drawer');
if (startAppFromPushNotification) {
Client.setToken(token);
if (this.startAppFromPushNotification) {
Client4.setToken(token);
Client4.setUrl(stripTrailingSlashes(url));
Client.setUrl(stripTrailingSlashes(url));
}
InteractionManager.runAfterInteractions(async () => {
await loadFromPushNotification(notification)(dispatch, getState);
if (startAppFromPushNotification) {
this.startAppFromPushNotification();
if (this.startAppFromPushNotification) {
this.launchApp();
} else {
EventEmitter.emit(ViewTypes.NOTIFICATION_TAPPED);
}
@@ -514,7 +523,7 @@ export default class Mattermost {
Client4.setUrl(state.entities.general.credentials.url);
}
if (!Client.getToken()) {
if (!Client4.getToken()) {
// Make sure the Client has the server token set
Client4.setToken(state.entities.general.credentials.token);
}
@@ -552,9 +561,7 @@ export default class Mattermost {
resetBadgeAndVersion = () => {
const {dispatch, getState} = this.store;
Client4.serverVersion = '';
Client.serverVersion = '';
Client.token = null;
Client4.userId = '';
Client4.setUserId('');
PushNotifications.setApplicationIconBadgeNumber(0);
PushNotifications.cancelAllLocalNotifications();
setServerVersion('')(dispatch, getState);
@@ -565,6 +572,7 @@ export default class Mattermost {
const {dispatch, getState} = this.store;
await loadConfigAndLicense()(dispatch, getState);
await loadMe()(dispatch, getState);
this.appStarted = false;
this.startApp('fade');
};
@@ -586,18 +594,29 @@ export default class Mattermost {
statusBarHidden: false,
statusBarHideWithNavBar: false
}
},
passProps: {
justInit: true
}
});
};
startApp = (animationType = 'none') => {
if (!this.appStarted) {
const {dispatch, getState} = this.store;
const {entities} = getState();
let screen = 'SelectServer';
if (entities) {
const {credentials} = entities.general;
if (credentials.token && credentials.url) {
screen = 'Channel';
tracker.initialLoad = Date.now();
loadMe()(dispatch, getState);
}
}
Navigation.startSingleScreenApp({
screen: {
screen: 'Root',
screen,
navigatorStyle: {
navBarHidden: true,
statusBarHidden: false,
@@ -615,28 +634,7 @@ export default class Mattermost {
});
this.appStarted = true;
this.startAppFromPushNotification = false;
}
};
startAppFromPushNotification = () => {
Navigation.startSingleScreenApp({
screen: {
screen: 'Channel',
navigatorStyle: {
navBarHidden: true,
statusBarHidden: false,
statusBarHideWithNavBar: false,
screenBackgroundColor: 'transparent'
}
},
passProps: {
allowOtherServers: this.allowOtherServers
},
appStyle: {
orientation: 'auto'
},
animationType: 'none'
});
this.appStarted = false;
};
}

View File

@@ -60,6 +60,8 @@ class Channel extends PureComponent {
if (this.props.currentTeamId) {
this.loadChannels(this.props.currentTeamId);
} else {
this.props.actions.selectFirstAvailableTeam();
}
}

View File

@@ -205,7 +205,7 @@ class ChannelAddMembers extends PureComponent {
};
searchProfiles = (text) => {
const term = text.toLowerCase();
const term = text;
const {actions, currentChannel, currentTeam} = this.props;
if (term) {
@@ -213,7 +213,7 @@ class ChannelAddMembers extends PureComponent {
clearTimeout(this.searchTimeoutId);
this.searchTimeoutId = setTimeout(() => {
actions.searchProfiles(term, {not_in_channel_id: currentChannel.id, team_id: currentTeam.id});
actions.searchProfiles(term.toLowerCase(), {not_in_channel_id: currentChannel.id, team_id: currentTeam.id});
}, General.SEARCH_TIMEOUT_MILLISECONDS);
} else {
this.cancelSearch();

View File

@@ -253,14 +253,14 @@ class ChannelMembers extends PureComponent {
};
searchProfiles = (text) => {
const term = text.toLowerCase();
const term = text;
if (term) {
this.setState({searching: true, term});
clearTimeout(this.searchTimeoutId);
this.searchTimeoutId = setTimeout(() => {
this.props.actions.searchProfiles(term, {in_channel_id: this.props.currentChannel.id});
this.props.actions.searchProfiles(term.toLowerCase(), {in_channel_id: this.props.currentChannel.id});
}, General.SEARCH_TIMEOUT_MILLISECONDS);
} else {
this.cancelSearch();

View File

@@ -22,7 +22,6 @@ import EditChannel from 'app/screens/edit_channel';
import EditPost from 'app/screens/edit_post';
import EditProfile from 'app/screens/edit_profile';
import ImagePreview from 'app/screens/image_preview';
import LoadTeam from 'app/screens/load_team';
import Login from 'app/screens/login';
import LoginOptions from 'app/screens/login_options';
import Mfa from 'app/screens/mfa';
@@ -78,7 +77,6 @@ export function registerScreens(store, Provider) {
Navigation.registerComponent('EditPost', () => wrapWithContextProvider(EditPost), store, Provider);
Navigation.registerComponent('EditProfile', () => wrapWithContextProvider(EditProfile), store, Provider);
Navigation.registerComponent('ImagePreview', () => wrapWithContextProvider(ImagePreview), store, Provider);
Navigation.registerComponent('LoadTeam', () => wrapWithContextProvider(LoadTeam, false), store, Provider);
Navigation.registerComponent('Login', () => wrapWithContextProvider(Login), store, Provider);
Navigation.registerComponent('LoginOptions', () => wrapWithContextProvider(LoginOptions), store, Provider);
Navigation.registerComponent('MFA', () => wrapWithContextProvider(Mfa), store, Provider);

View File

@@ -1,35 +0,0 @@
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {getTeams} from 'mattermost-redux/actions/teams';
import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';
import {handleTeamChange} from 'app/actions/views/select_team';
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
import LoadTeam from './load_team';
function mapStateToProps(state) {
return {
config: state.entities.general.config,
theme: getTheme(state),
teams: state.entities.teams.teams,
currentTeam: getCurrentTeam(state),
myMembers: state.entities.teams.myMembers,
notification: state.views.notification
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
getTeams,
handleTeamChange
}, dispatch)
};
}
export default connect(mapStateToProps, mapDispatchToProps)(LoadTeam);

View File

@@ -1,71 +0,0 @@
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {PureComponent} from 'react';
import PropTypes from 'prop-types';
import EventEmitter from 'mattermost-redux/utils/event_emitter';
import {NavigationTypes} from 'app/constants';
export default class LoadTeam extends PureComponent {
static propTypes = {
actions: PropTypes.shape({
getTeams: PropTypes.func.isRequired,
handleTeamChange: PropTypes.func.isRequired
}).isRequired,
currentTeam: PropTypes.object,
myMembers: PropTypes.object.isRequired,
navigator: PropTypes.object,
teams: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired
};
componentDidMount() {
const {currentTeam, myMembers, teams} = this.props;
if (currentTeam && myMembers[currentTeam.id]) {
return this.onSelectTeam(currentTeam);
}
return this.selectFirstTeam(teams, myMembers);
}
selectFirstTeam(allTeams, myMembers) {
const teams = Object.keys(myMembers).map((key) => allTeams[key]);
const firstTeam = Object.values(teams).sort((a, b) => a.display_name.localeCompare(b.display_name))[0];
if (firstTeam) {
this.onSelectTeam(firstTeam);
} else {
const {getTeams} = this.props.actions;
getTeams().then(() => {
EventEmitter.emit(NavigationTypes.NAVIGATION_NO_TEAMS);
});
}
}
onSelectTeam(team) {
const {handleTeamChange} = this.props.actions;
handleTeamChange(team.id).then(this.goToChannelView);
}
goToChannelView = () => {
const {navigator, theme} = this.props;
navigator.resetTo({
screen: 'Channel',
animated: true,
animationType: 'fade',
navigatorStyle: {
navBarHidden: true,
statusBarHidden: false,
statusBarHideWithNavBar: false,
screenBackgroundColor: theme.centerChannelBg
}
});
};
render() {
return null;
}
}

View File

@@ -77,7 +77,7 @@ class Login extends PureComponent {
}
goToLoadTeam = (expiresAt) => {
const {intl, navigator, theme} = this.props;
const {intl, navigator} = this.props;
tracker.initialLoad = Date.now();
if (expiresAt) {
@@ -94,17 +94,17 @@ class Login extends PureComponent {
}
navigator.resetTo({
screen: 'LoadTeam',
screen: 'Channel',
title: '',
animated: false,
backButtonTitle: '',
navigatorStyle: {
animated: true,
animationType: 'fade',
navBarHidden: true,
statusBarHidden: false,
statusBarHideWithNavBar: false,
navBarTextColor: theme.sidebarHeaderTextColor,
navBarBackgroundColor: theme.sidebarHeaderBg,
navBarButtonColor: theme.sidebarHeaderTextColor,
screenBackgroundColor: theme.centerChannelBg
screenBackgroundColor: 'transparent'
}
});
};

View File

@@ -153,7 +153,11 @@ class MoreChannels extends PureComponent {
if (term) {
const channels = this.filterChannels(this.state.channels, term);
this.setState({channels, term, searching: true});
this.setState({
channels,
term: text,
searching: true
});
clearTimeout(this.searchTimeoutId);
this.searchTimeoutId = setTimeout(() => {

View File

@@ -162,14 +162,14 @@ class MoreDirectMessages extends PureComponent {
};
onSearch = (text) => {
const term = text.toLowerCase();
const term = text;
if (term) {
this.setState({searching: true, term});
clearTimeout(this.searchTimeoutId);
this.searchTimeoutId = setTimeout(() => {
this.searchProfiles(term);
this.searchProfiles(term.toLowerCase());
}, General.SEARCH_TIMEOUT_MILLISECONDS);
} else {
this.cancelSearch();

View File

@@ -1,29 +1,12 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import React from 'react';
import {loadMe} from 'mattermost-redux/actions/users';
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
import Loading from 'app/components/loading';
import Root from './root';
function mapStateToProps(state) {
return {
currentUser: getCurrentUser(state),
credentials: state.entities.general.credentials,
theme: getTheme(state)
};
function Root() {
return <Loading/>;
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
loadMe
}, dispatch)
};
}
export default connect(mapStateToProps, mapDispatchToProps)(Root);
export default Root;

View File

@@ -1,101 +0,0 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {Client, Client4} from 'mattermost-redux/client';
import Loading from 'app/components/loading';
import {stripTrailingSlashes} from 'app/utils/url';
import tracker from 'app/utils/time_tracker';
export default class Root extends Component {
static propTypes = {
actions: PropTypes.shape({
loadMe: PropTypes.func.isRequired
}).isRequired,
allowOtherServers: PropTypes.bool,
currentUser: PropTypes.object,
credentials: PropTypes.object,
justInit: PropTypes.bool,
navigator: PropTypes.object,
theme: PropTypes.object
};
shouldComponentUpdate(nextProps) {
if (nextProps.credentials !== this.props.credentials) {
return true;
}
return false;
}
componentDidMount() {
if (!this.props.justInit) {
this.loadStoreAndScene();
}
}
goToLoadTeam = () => {
const {navigator, theme} = this.props;
tracker.initialLoad = Date.now();
navigator.resetTo({
screen: 'LoadTeam',
title: '',
animated: true,
animationType: 'fade',
backButtonTitle: '',
navigatorStyle: {
statusBarHidden: false,
statusBarHideWithNavBar: false,
navBarTextColor: theme.sidebarHeaderTextColor,
navBarBackgroundColor: theme.sidebarHeaderBg,
navBarButtonColor: theme.sidebarHeaderTextColor,
screenBackgroundColor: theme.centerChannelBg
}
});
};
goToSelectServer = () => {
const {allowOtherServers, navigator} = this.props;
navigator.resetTo({
screen: 'SelectServer',
animated: true,
animationType: 'fade',
navigatorStyle: {
navBarHidden: true,
navBarBackgroundColor: 'black',
statusBarHidden: false,
statusBarHideWithNavBar: false
},
passProps: {
allowOtherServers
}
});
};
loadStoreAndScene = () => {
const {actions, currentUser, credentials} = this.props;
const {loadMe} = actions;
if (credentials.token && credentials.url) {
Client.setToken(credentials.token);
Client4.setToken(credentials.token);
Client4.setUrl(stripTrailingSlashes(credentials.url));
Client.setUrl(stripTrailingSlashes(credentials.url));
if (currentUser) {
loadMe();
this.goToLoadTeam();
} else {
loadMe().then(this.goToLoadTeam).catch(this.goToLoadTeam);
}
} else {
this.goToSelectServer();
}
};
render() {
return <Loading/>;
}
}

View File

@@ -19,7 +19,7 @@ import {
import Button from 'react-native-button';
import urlParse from 'url-parse';
import {Client, Client4} from 'mattermost-redux/client';
import {Client4} from 'mattermost-redux/client';
import Config from 'assets/config';
import ErrorText from 'app/components/error_text';
@@ -224,7 +224,6 @@ class SelectServer extends PureComponent {
});
Client4.setUrl(url);
Client.setUrl(url);
handleServerUrlChanged(url);
let cancel = false;

View File

@@ -82,7 +82,7 @@ class SSO extends PureComponent {
}
goToLoadTeam = (expiresAt) => {
const {intl, navigator, theme} = this.props;
const {intl, navigator} = this.props;
tracker.initialLoad = Date.now();
if (expiresAt) {
@@ -99,17 +99,17 @@ class SSO extends PureComponent {
}
navigator.resetTo({
screen: 'LoadTeam',
screen: 'Channel',
title: '',
animated: false,
backButtonTitle: '',
navigatorStyle: {
animated: true,
animationType: 'fade',
navBarHidden: true,
statusBarHidden: false,
statusBarHideWithNavBar: false,
navBarTextColor: theme.sidebarHeaderTextColor,
navBarBackgroundColor: theme.sidebarHeaderBg,
navBarButtonColor: theme.sidebarHeaderTextColor,
screenBackgroundColor: theme.centerChannelBg
screenBackgroundColor: 'transparent'
}
});
};

View File

@@ -2225,7 +2225,7 @@
CODE_SIGN_ENTITLEMENTS = Mattermost/Mattermost.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 85;
CURRENT_PROJECT_VERSION = 86;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = UQ8HT4Q2XM;
ENABLE_BITCODE = NO;
@@ -2274,7 +2274,7 @@
CODE_SIGN_ENTITLEMENTS = Mattermost/Mattermost.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 85;
CURRENT_PROJECT_VERSION = 86;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = UQ8HT4Q2XM;
ENABLE_BITCODE = NO;

View File

@@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.6.0</string>
<string>1.6.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
@@ -34,7 +34,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>85</string>
<string>86</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>

View File

@@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.3.0</string>
<string>1.6.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>85</string>
<string>86</string>
</dict>
</plist>