* MM-15323 autofill server Url when opening the app from deeplink (#10788) * MM-15323 move autofill logic into select-server screen * MM-15323 removes scheme on deeplink on select-server * MM-15323 fix serverURL wrong prop name * MM-15323: use getDerivedStateFromProps for setting state.url * MM-15323 revert serverUrl and fix unchangeable deeplink * MM-15323 fix props.serverUrl * MM-15323 move props.serverUrl into getDerivedStateFromProps * MM-15323 fix iOS deeplink issue Co-authored-by: mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
parent
a909583025
commit
1bba361f89
3 changed files with 19 additions and 9 deletions
|
|
@ -57,6 +57,12 @@ const launchApp = (credentials) => {
|
|||
|
||||
const store = Store.redux;
|
||||
waitForHydration(store, async () => {
|
||||
Linking.getInitialURL().then((url) => {
|
||||
if (url) {
|
||||
store.dispatch(setDeepLinkURL(url));
|
||||
}
|
||||
});
|
||||
|
||||
if (credentials) {
|
||||
const {previousVersion} = store.getState().app;
|
||||
const valid = validatePreviousVersion(previousVersion);
|
||||
|
|
@ -78,12 +84,6 @@ const launchApp = (credentials) => {
|
|||
|
||||
telemetry.startSinceLaunch(['start:splash_screen']);
|
||||
EphemeralStore.appStarted = true;
|
||||
|
||||
Linking.getInitialURL().then((url) => {
|
||||
if (url) {
|
||||
store.dispatch(setDeepLinkURL(url));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const launchAppAndAuthenticateIfNeeded = async (credentials) => {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ function mapStateToProps(state) {
|
|||
...state.views.selectServer,
|
||||
config,
|
||||
currentVersion,
|
||||
deepLinkURL: state.views.root.deepLinkURL,
|
||||
hasConfigAndLicense: Object.keys(config).length > 0 && Object.keys(license).length > 0,
|
||||
latestVersion,
|
||||
license,
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import {
|
|||
import Button from 'react-native-button';
|
||||
import RNFetchBlob from 'rn-fetch-blob';
|
||||
import merge from 'deepmerge';
|
||||
import urlParse from 'url-parse';
|
||||
|
||||
import {resetToChannel, goToScreen} from '@actions/navigation';
|
||||
import LocalConfig from '@assets/config';
|
||||
|
|
@ -63,6 +64,7 @@ export default class SelectServer extends PureComponent {
|
|||
license: PropTypes.object,
|
||||
minVersion: PropTypes.string,
|
||||
serverUrl: PropTypes.string.isRequired,
|
||||
deepLinkURL: PropTypes.string,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
|
|
@ -80,12 +82,21 @@ export default class SelectServer extends PureComponent {
|
|||
connected: false,
|
||||
connecting: false,
|
||||
error: null,
|
||||
url: props.serverUrl,
|
||||
};
|
||||
|
||||
this.cancelPing = null;
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps(props, state) {
|
||||
if (state.url === undefined && props.allowOtherServers && props.deepLinkURL) {
|
||||
const url = urlParse(props.deepLinkURL).host;
|
||||
return {url};
|
||||
} else if (state.url === undefined && props.serverUrl) {
|
||||
return {url: props.serverUrl};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.navigationEventListener = Navigation.events().bindComponent(this);
|
||||
|
||||
|
|
@ -364,7 +375,6 @@ export default class SelectServer extends PureComponent {
|
|||
};
|
||||
|
||||
sanitizeUrl = (url, useHttp = false) => {
|
||||
const urlParse = require('url-parse');
|
||||
let preUrl = urlParse(url, true);
|
||||
|
||||
if (!preUrl.host || preUrl.protocol === 'file:') {
|
||||
|
|
@ -391,7 +401,6 @@ export default class SelectServer extends PureComponent {
|
|||
|
||||
this.cancelPing();
|
||||
|
||||
const urlParse = require('url-parse');
|
||||
const host = urlParse(this.state.url, true).host || this.state.url;
|
||||
|
||||
const {formatMessage} = this.context.intl;
|
||||
|
|
|
|||
Loading…
Reference in a new issue