* Await getSource * Use server url from EphemeralStore * Set currentServerUrl in getAppCredentials too
This commit is contained in:
parent
e03b72861c
commit
ff7548251b
3 changed files with 7 additions and 8 deletions
|
|
@ -18,7 +18,7 @@ import {
|
|||
import FormattedText from 'app/components/formatted_text';
|
||||
import ProgressiveImage from 'app/components/progressive_image';
|
||||
import CustomPropTypes from 'app/constants/custom_prop_types';
|
||||
import {getCurrentServerUrl} from 'app/init/credentials';
|
||||
import EphemeralStore from 'app/store/ephemeral_store';
|
||||
import mattermostManaged from 'app/mattermost_managed';
|
||||
import BottomSheet from 'app/utils/bottom_sheet';
|
||||
import ImageCacheManager from 'app/utils/image_cache_manager';
|
||||
|
|
@ -43,7 +43,6 @@ export default class MarkdownImage extends React.Component {
|
|||
imagesMetadata: PropTypes.object,
|
||||
linkDestination: PropTypes.string,
|
||||
isReplyPost: PropTypes.bool,
|
||||
serverURL: PropTypes.string,
|
||||
source: PropTypes.string.isRequired,
|
||||
errorTextStyle: CustomPropTypes.Style,
|
||||
};
|
||||
|
|
@ -96,15 +95,11 @@ export default class MarkdownImage extends React.Component {
|
|||
this.mounted = false;
|
||||
}
|
||||
|
||||
getSource = async () => {
|
||||
getSource = () => {
|
||||
let source = this.props.source;
|
||||
let serverUrl = this.props.serverURL;
|
||||
if (!serverUrl) {
|
||||
serverUrl = await getCurrentServerUrl();
|
||||
}
|
||||
|
||||
if (source.startsWith('/')) {
|
||||
source = serverUrl + source;
|
||||
source = EphemeralStore.currentServerUrl + source;
|
||||
}
|
||||
|
||||
return source;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ export const setAppCredentials = (deviceToken, currentUserId, token, url) => {
|
|||
const username = `${deviceToken}, ${currentUserId}`;
|
||||
|
||||
EphemeralStore.deviceToken = deviceToken;
|
||||
EphemeralStore.currentServerUrl = url;
|
||||
AsyncStorage.setItem(CURRENT_SERVER, url);
|
||||
KeyChain.setInternetCredentials(url, username, token, {accessGroup: mattermostManaged.appGroupIdentifier});
|
||||
} catch (e) {
|
||||
|
|
@ -39,6 +40,7 @@ export const getAppCredentials = async () => {
|
|||
const serverUrl = await AsyncStorage.getItem(CURRENT_SERVER);
|
||||
|
||||
if (serverUrl) {
|
||||
EphemeralStore.currentServerUrl = serverUrl;
|
||||
return getInternetCredentials(serverUrl);
|
||||
}
|
||||
|
||||
|
|
@ -59,6 +61,7 @@ export const removeAppCredentials = async () => {
|
|||
}
|
||||
|
||||
KeyChain.resetGenericPassword();
|
||||
EphemeralStore.currentServerUrl = null;
|
||||
AsyncStorage.removeItem(CURRENT_SERVER);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ class EphemeralStore {
|
|||
this.appStartedFromPushNotification = false;
|
||||
this.deviceToken = null;
|
||||
this.navigationComponentIdStack = [];
|
||||
this.currentServerUrl = null;
|
||||
}
|
||||
|
||||
getNavigationTopComponentId = () => this.navigationComponentIdStack[0];
|
||||
|
|
|
|||
Loading…
Reference in a new issue