Fix assigning credentials during app init (#3034)
* Fix assigning credentials during app init * remove setAppCredentials in entry screen
This commit is contained in:
parent
ffa4a2253e
commit
339ff1ae8f
3 changed files with 14 additions and 36 deletions
|
|
@ -6,6 +6,7 @@ import {Linking, NativeModules, Platform, Text} from 'react-native';
|
|||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import {setGenericPassword, getGenericPassword, resetGenericPassword} from 'react-native-keychain';
|
||||
|
||||
import {setDeviceToken} from 'mattermost-redux/actions/general';
|
||||
import {loadMe} from 'mattermost-redux/actions/users';
|
||||
import {Client4} from 'mattermost-redux/client';
|
||||
import EventEmitter from 'mattermost-redux/utils/event_emitter';
|
||||
|
|
@ -127,10 +128,12 @@ export default class App {
|
|||
|
||||
// if for any case the url and the token aren't valid proceed with re-hydration
|
||||
if (url && url !== 'undefined' && token && token !== 'undefined') {
|
||||
this.deviceToken = deviceToken;
|
||||
const {dispatch} = store;
|
||||
|
||||
this.currentUserId = currentUserId;
|
||||
this.token = token;
|
||||
this.url = url;
|
||||
dispatch(setDeviceToken(deviceToken));
|
||||
Client4.setUrl(url);
|
||||
Client4.setToken(token);
|
||||
await setCSRFFromCookie(url);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import {
|
|||
} from 'app/mattermost';
|
||||
import {ViewTypes} from 'app/constants';
|
||||
import PushNotifications from 'app/push_notifications';
|
||||
import {stripTrailingSlashes} from 'app/utils/url';
|
||||
import {wrapWithContextProvider} from 'app/utils/wrap_context_provider';
|
||||
|
||||
import ChannelLoader from 'app/components/channel_loader';
|
||||
|
|
@ -64,7 +63,6 @@ export default class Entry extends PureComponent {
|
|||
initializeModules: PropTypes.func,
|
||||
actions: PropTypes.shape({
|
||||
autoUpdateTimezone: PropTypes.func.isRequired,
|
||||
setDeviceToken: PropTypes.func.isRequired,
|
||||
}).isRequired,
|
||||
};
|
||||
|
||||
|
|
@ -128,7 +126,16 @@ export default class Entry extends PureComponent {
|
|||
autoUpdateTimezone(deviceTimezone);
|
||||
}
|
||||
|
||||
this.setAppCredentials();
|
||||
const {currentUserId} = state.entities.users;
|
||||
|
||||
if (app.waitForRehydration) {
|
||||
app.waitForRehydration = false;
|
||||
}
|
||||
|
||||
if (currentUserId) {
|
||||
Client4.setUserId(currentUserId);
|
||||
}
|
||||
|
||||
this.setStartupThemes();
|
||||
this.handleNotification();
|
||||
this.loadSystemEmojis();
|
||||
|
|
@ -147,36 +154,6 @@ export default class Entry extends PureComponent {
|
|||
configureNotifications();
|
||||
};
|
||||
|
||||
setAppCredentials = () => {
|
||||
const {
|
||||
actions: {
|
||||
setDeviceToken,
|
||||
},
|
||||
} = this.props;
|
||||
const {getState} = store;
|
||||
const state = getState();
|
||||
|
||||
const {credentials} = state.entities.general;
|
||||
const {currentUserId} = state.entities.users;
|
||||
|
||||
if (app.deviceToken) {
|
||||
setDeviceToken(app.deviceToken);
|
||||
}
|
||||
|
||||
if (credentials.token && credentials.url) {
|
||||
Client4.setToken(credentials.token);
|
||||
Client4.setUrl(stripTrailingSlashes(credentials.url));
|
||||
} else if (app.waitForRehydration) {
|
||||
app.waitForRehydration = false;
|
||||
}
|
||||
|
||||
if (currentUserId) {
|
||||
Client4.setUserId(currentUserId);
|
||||
}
|
||||
|
||||
app.setAppCredentials(app.deviceToken, currentUserId, credentials.token, credentials.url);
|
||||
};
|
||||
|
||||
setStartupThemes = () => {
|
||||
const {theme} = this.props;
|
||||
if (app.toolbarBackground === theme.sidebarHeaderBg) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
import {bindActionCreators} from 'redux';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import {setDeviceToken} from 'mattermost-redux/actions/general';
|
||||
import {autoUpdateTimezone} from 'mattermost-redux/actions/timezone';
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {isTimezoneEnabled} from 'mattermost-redux/selectors/entities/timezone';
|
||||
|
|
@ -31,7 +30,6 @@ function mapDispatchToProps(dispatch) {
|
|||
return {
|
||||
actions: bindActionCreators({
|
||||
autoUpdateTimezone,
|
||||
setDeviceToken,
|
||||
}, dispatch),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue