Skip to content

Commit 01abc6f

Browse files
authored
Merge pull request #13010 from margelo/@thomas/revert-fast-image
Revert "Merge pull request #12648 from margelo/@thomas/fast-image-cac…
2 parents 164f0a0 + 94a90e1 commit 01abc6f

11 files changed

Lines changed: 149 additions & 253 deletions

File tree

src/CONST.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,6 @@ const CONST = {
862862
},
863863

864864
TFA_CODE_LENGTH: 6,
865-
866-
CHAT_ATTACHMENT_TOKEN_KEY: 'X-Chat-Attachment-Token',
867865
};
868866

869867
export default CONST;

src/components/AttachmentModal.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class AttachmentModal extends PureComponent {
115115
* @param {String} sourceURL
116116
*/
117117
downloadAttachment(sourceURL) {
118-
fileDownload(this.props.isAuthTokenRequired ? addEncryptedAuthTokenToURL(sourceURL) : sourceURL, this.props.originalFileName);
118+
fileDownload(sourceURL, this.props.originalFileName);
119119

120120
// At ios, if the keyboard is open while opening the attachment, then after downloading
121121
// the attachment keyboard will show up. So, to fix it we need to dismiss the keyboard.
@@ -229,7 +229,9 @@ class AttachmentModal extends PureComponent {
229229
}
230230

231231
render() {
232-
const sourceURL = this.state.sourceURL;
232+
const sourceURL = this.props.isAuthTokenRequired
233+
? addEncryptedAuthTokenToURL(this.state.sourceURL)
234+
: this.state.sourceURL;
233235

234236
const {fileName, fileExtension} = FileUtils.splitExtensionFromFileName(this.props.originalFileName || lodashGet(this.state, 'file.name', ''));
235237

@@ -264,7 +266,6 @@ class AttachmentModal extends PureComponent {
264266
<View style={styles.imageModalImageCenterContainer}>
265267
{this.state.sourceURL && (
266268
<AttachmentView
267-
isAuthTokenRequired={this.props.isAuthTokenRequired}
268269
sourceURL={sourceURL}
269270
file={this.state.file}
270271
onToggleKeyboard={this.updateConfirmButtonVisibility}

src/components/AttachmentView.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,8 @@ import compose from '../libs/compose';
1212
import Text from './Text';
1313
import Tooltip from './Tooltip';
1414
import themeColors from '../styles/themes/default';
15-
import addEncryptedAuthTokenToURL from '../libs/addEncryptedAuthTokenToURL';
1615

1716
const propTypes = {
18-
19-
/** Do the urls require an authToken? */
20-
isAuthTokenRequired: PropTypes.bool,
21-
2217
/** URL to full-sized attachment */
2318
sourceURL: PropTypes.string.isRequired,
2419

@@ -40,7 +35,6 @@ const propTypes = {
4035
};
4136

4237
const defaultProps = {
43-
isAuthTokenRequired: false,
4438
file: {
4539
name: '',
4640
},
@@ -54,12 +48,9 @@ const AttachmentView = (props) => {
5448
// will appear with a sourceURL that is a blob
5549
if (Str.isPDF(props.sourceURL)
5650
|| (props.file && Str.isPDF(props.file.name || props.translate('attachmentView.unknownFilename')))) {
57-
const sourceURL = props.isAuthTokenRequired
58-
? addEncryptedAuthTokenToURL(props.sourceURL)
59-
: props.sourceURL;
6051
return (
6152
<PDFView
62-
sourceURL={sourceURL}
53+
sourceURL={props.sourceURL}
6354
style={styles.imageModalPDF}
6455
onToggleKeyboard={props.onToggleKeyboard}
6556
/>
@@ -70,7 +61,7 @@ const AttachmentView = (props) => {
7061
// both PDFs and images will appear as images when pasted into the the text field
7162
if (Str.isImage(props.sourceURL) || (props.file && Str.isImage(props.file.name))) {
7263
return (
73-
<ImageView url={props.sourceURL} isAuthTokenRequired={props.isAuthTokenRequired} />
64+
<ImageView url={props.sourceURL} />
7465
);
7566
}
7667

src/components/Avatar.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {PureComponent} from 'react';
2-
import {View} from 'react-native';
2+
import {Image, View} from 'react-native';
33
import PropTypes from 'prop-types';
44
import _ from 'underscore';
55
import stylePropTypes from '../styles/stylePropTypes';
@@ -10,7 +10,6 @@ import * as StyleUtils from '../styles/StyleUtils';
1010
import * as Expensicons from './Icon/Expensicons';
1111
import getAvatarDefaultSource from '../libs/getAvatarDefaultSource';
1212
import styles from '../styles/styles';
13-
import FastImage from './FastImage';
1413

1514
const propTypes = {
1615
/** Source for the avatar. Can be a URL or an icon. */
@@ -81,7 +80,7 @@ class Avatar extends PureComponent {
8180
</View>
8281
)
8382
: (
84-
<FastImage
83+
<Image
8584
source={{uri: this.props.source}}
8685
defaultSource={getAvatarDefaultSource(this.props.source)}
8786
style={imageStyle}

src/components/FastImage/index.js

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/components/FastImage/index.native.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/components/ImageView/index.js

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,20 @@
11
import React, {PureComponent} from 'react';
22
import PropTypes from 'prop-types';
33
import {
4-
View, Pressable,
4+
View, Image, Pressable,
55
} from 'react-native';
6-
import {withOnyx} from 'react-native-onyx';
7-
import FastImage from '../FastImage';
86
import styles from '../../styles/styles';
97
import * as StyleUtils from '../../styles/StyleUtils';
108
import canUseTouchScreen from '../../libs/canUseTouchscreen';
119
import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions';
1210
import FullscreenLoadingIndicator from '../FullscreenLoadingIndicator';
13-
import compose from '../../libs/compose';
14-
import ONYXKEYS from '../../ONYXKEYS';
15-
import chatAttachmentTokenHeaders from '../../libs/chatAttachmentTokenHeaders';
1611

1712
const propTypes = {
18-
19-
/** Do the urls require an authToken? */
20-
isAuthTokenRequired: PropTypes.bool,
21-
2213
/** URL to full-sized image */
2314
url: PropTypes.string.isRequired,
2415
...windowDimensionsPropTypes,
2516
};
2617

27-
const defaultProps = {
28-
isAuthTokenRequired: false,
29-
};
30-
3118
class ImageView extends PureComponent {
3219
constructor(props) {
3320
super(props);
@@ -36,7 +23,6 @@ class ImageView extends PureComponent {
3623
this.onContainerLayoutChanged = this.onContainerLayoutChanged.bind(this);
3724
this.onContainerPressIn = this.onContainerPressIn.bind(this);
3825
this.onContainerPress = this.onContainerPress.bind(this);
39-
this.imageLoad = this.imageLoad.bind(this);
4026
this.imageLoadingStart = this.imageLoadingStart.bind(this);
4127
this.imageLoadingEnd = this.imageLoadingEnd.bind(this);
4228
this.trackMovement = this.trackMovement.bind(this);
@@ -60,6 +46,9 @@ class ImageView extends PureComponent {
6046
}
6147

6248
componentDidMount() {
49+
Image.getSize(this.props.url, (width, height) => {
50+
this.setImageRegion(width, height);
51+
});
6352
if (this.canUseTouchScreen) {
6453
return;
6554
}
@@ -218,10 +207,6 @@ class ImageView extends PureComponent {
218207
this.setState(prevState => ({isDragging: prevState.isMouseDown}));
219208
}
220209

221-
imageLoad({nativeEvent}) {
222-
this.setImageRegion(nativeEvent.width, nativeEvent.height);
223-
}
224-
225210
imageLoadingStart() {
226211
this.setState({isLoading: true});
227212
}
@@ -231,29 +216,24 @@ class ImageView extends PureComponent {
231216
}
232217

233218
render() {
234-
const headers = this.props.isAuthTokenRequired ? chatAttachmentTokenHeaders() : undefined;
235219
if (this.canUseTouchScreen) {
236220
return (
237221
<View
238222
style={[styles.imageViewContainer, styles.overflowHidden]}
239223
onLayout={this.onContainerLayoutChanged}
240224
>
241-
<FastImage
242-
source={{
243-
uri: this.props.url,
244-
headers,
245-
}}
225+
<Image
226+
source={{uri: this.props.url}}
246227
style={this.state.zoomScale === 0 ? undefined : [
247228
styles.w100,
248229
styles.h100,
249230
]} // Hide image until zoomScale calculated to prevent showing preview with wrong dimensions.
250231

251232
// When Image dimensions are lower than the container boundary(zoomscale <= 1), use `contain` to render the image with natural dimensions.
252233
// Both `center` and `contain` keeps the image centered on both x and y axis.
253-
resizeMode={this.state.zoomScale > 1 ? FastImage.resizeMode.center : FastImage.resizeMode.contain}
234+
resizeMode={this.state.zoomScale > 1 ? 'center' : 'contain'}
254235
onLoadStart={this.imageLoadingStart}
255236
onLoadEnd={this.imageLoadingEnd}
256-
onLoad={this.imageLoad}
257237
/>
258238
{this.state.isLoading && (
259239
<FullscreenLoadingIndicator
@@ -285,19 +265,15 @@ class ImageView extends PureComponent {
285265
onPressIn={this.onContainerPressIn}
286266
onPress={this.onContainerPress}
287267
>
288-
<FastImage
289-
source={{
290-
uri: this.props.url,
291-
headers,
292-
}}
268+
<Image
269+
source={{uri: this.props.url}}
293270
style={this.state.zoomScale === 0 ? undefined : [
294271
styles.h100,
295272
styles.w100,
296273
]} // Hide image until zoomScale calculated to prevent showing preview with wrong dimensions.
297-
resizeMode={FastImage.resizeMode.contain}
274+
resizeMode="contain"
298275
onLoadStart={this.imageLoadingStart}
299276
onLoadEnd={this.imageLoadingEnd}
300-
onLoad={this.imageLoad}
301277
/>
302278
</Pressable>
303279

@@ -312,7 +288,4 @@ class ImageView extends PureComponent {
312288
}
313289

314290
ImageView.propTypes = propTypes;
315-
ImageView.defaultProps = defaultProps;
316-
export default compose(withWindowDimensions, withOnyx({
317-
session: {key: ONYXKEYS.SESSION},
318-
}))(ImageView);
291+
export default withWindowDimensions(ImageView);

0 commit comments

Comments
 (0)