diff --git a/app/components/markdown/markdown_image/markdown_image.js b/app/components/markdown/markdown_image/markdown_image.js index b8a7bac8e..882d4fbc6 100644 --- a/app/components/markdown/markdown_image/markdown_image.js +++ b/app/components/markdown/markdown_image/markdown_image.js @@ -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; diff --git a/app/init/credentials.js b/app/init/credentials.js index 14b401467..5148a43be 100644 --- a/app/init/credentials.js +++ b/app/init/credentials.js @@ -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); }; diff --git a/app/store/ephemeral_store.js b/app/store/ephemeral_store.js index 997abfbb0..eeb451f44 100644 --- a/app/store/ephemeral_store.js +++ b/app/store/ephemeral_store.js @@ -7,6 +7,7 @@ class EphemeralStore { this.appStartedFromPushNotification = false; this.deviceToken = null; this.navigationComponentIdStack = []; + this.currentServerUrl = null; } getNavigationTopComponentId = () => this.navigationComponentIdStack[0];