Skip to content

Commit

Permalink
Merge pull request #13016 from Expensify/OSBotify-cherry-pick-staging…
Browse files Browse the repository at this point in the history
…-13010

🍒 Cherry pick PR #13010 to staging 🍒
  • Loading branch information
luacmartins authored Nov 24, 2022
2 parents 698fc55 + f5b8bad commit 0d1deaa
Show file tree
Hide file tree
Showing 16 changed files with 156 additions and 260 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001023105
versionName "1.2.31-5"
versionCode 1001023106
versionName "1.2.31-6"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()

if (isNewArchitectureEnabled()) {
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.2.31.5</string>
<string>1.2.31.6</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.2.31.5</string>
<string>1.2.31.6</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.2.31-5",
"version": "1.2.31-6",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
2 changes: 0 additions & 2 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,6 @@ const CONST = {
},

TFA_CODE_LENGTH: 6,

CHAT_ATTACHMENT_TOKEN_KEY: 'X-Chat-Attachment-Token',
};

export default CONST;
7 changes: 4 additions & 3 deletions src/components/AttachmentModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class AttachmentModal extends PureComponent {
* @param {String} sourceURL
*/
downloadAttachment(sourceURL) {
fileDownload(this.props.isAuthTokenRequired ? addEncryptedAuthTokenToURL(sourceURL) : sourceURL, this.props.originalFileName);
fileDownload(sourceURL, this.props.originalFileName);

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

render() {
const sourceURL = this.state.sourceURL;
const sourceURL = this.props.isAuthTokenRequired
? addEncryptedAuthTokenToURL(this.state.sourceURL)
: this.state.sourceURL;

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

Expand Down Expand Up @@ -264,7 +266,6 @@ class AttachmentModal extends PureComponent {
<View style={styles.imageModalImageCenterContainer}>
{this.state.sourceURL && (
<AttachmentView
isAuthTokenRequired={this.props.isAuthTokenRequired}
sourceURL={sourceURL}
file={this.state.file}
onToggleKeyboard={this.updateConfirmButtonVisibility}
Expand Down
13 changes: 2 additions & 11 deletions src/components/AttachmentView.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ import compose from '../libs/compose';
import Text from './Text';
import Tooltip from './Tooltip';
import themeColors from '../styles/themes/default';
import addEncryptedAuthTokenToURL from '../libs/addEncryptedAuthTokenToURL';

const propTypes = {

/** Do the urls require an authToken? */
isAuthTokenRequired: PropTypes.bool,

/** URL to full-sized attachment */
sourceURL: PropTypes.string.isRequired,

Expand All @@ -40,7 +35,6 @@ const propTypes = {
};

const defaultProps = {
isAuthTokenRequired: false,
file: {
name: '',
},
Expand All @@ -54,12 +48,9 @@ const AttachmentView = (props) => {
// will appear with a sourceURL that is a blob
if (Str.isPDF(props.sourceURL)
|| (props.file && Str.isPDF(props.file.name || props.translate('attachmentView.unknownFilename')))) {
const sourceURL = props.isAuthTokenRequired
? addEncryptedAuthTokenToURL(props.sourceURL)
: props.sourceURL;
return (
<PDFView
sourceURL={sourceURL}
sourceURL={props.sourceURL}
style={styles.imageModalPDF}
onToggleKeyboard={props.onToggleKeyboard}
/>
Expand All @@ -70,7 +61,7 @@ const AttachmentView = (props) => {
// both PDFs and images will appear as images when pasted into the the text field
if (Str.isImage(props.sourceURL) || (props.file && Str.isImage(props.file.name))) {
return (
<ImageView url={props.sourceURL} isAuthTokenRequired={props.isAuthTokenRequired} />
<ImageView url={props.sourceURL} />
);
}

Expand Down
5 changes: 2 additions & 3 deletions src/components/Avatar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {PureComponent} from 'react';
import {View} from 'react-native';
import {Image, View} from 'react-native';
import PropTypes from 'prop-types';
import _ from 'underscore';
import stylePropTypes from '../styles/stylePropTypes';
Expand All @@ -9,7 +9,6 @@ import CONST from '../CONST';
import * as StyleUtils from '../styles/StyleUtils';
import * as Expensicons from './Icon/Expensicons';
import getAvatarDefaultSource from '../libs/getAvatarDefaultSource';
import FastImage from './FastImage';

const propTypes = {
/** Source for the avatar. Can be a URL or an icon. */
Expand Down Expand Up @@ -73,7 +72,7 @@ class Avatar extends PureComponent {
/>
)
: (
<FastImage
<Image
source={{uri: this.props.source}}
defaultSource={getAvatarDefaultSource(this.props.source)}
style={imageStyle}
Expand Down
61 changes: 0 additions & 61 deletions src/components/FastImage/index.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/components/FastImage/index.native.js

This file was deleted.

49 changes: 11 additions & 38 deletions src/components/ImageView/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {
View, Pressable,
View, Image, Pressable,
} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import FastImage from '../FastImage';
import styles from '../../styles/styles';
import * as StyleUtils from '../../styles/StyleUtils';
import canUseTouchScreen from '../../libs/canUseTouchscreen';
import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions';
import FullscreenLoadingIndicator from '../FullscreenLoadingIndicator';
import compose from '../../libs/compose';
import ONYXKEYS from '../../ONYXKEYS';
import chatAttachmentTokenHeaders from '../../libs/chatAttachmentTokenHeaders';

const propTypes = {

/** Do the urls require an authToken? */
isAuthTokenRequired: PropTypes.bool,

/** URL to full-sized image */
url: PropTypes.string.isRequired,
...windowDimensionsPropTypes,
};

const defaultProps = {
isAuthTokenRequired: false,
};

class ImageView extends PureComponent {
constructor(props) {
super(props);
Expand All @@ -36,7 +23,6 @@ class ImageView extends PureComponent {
this.onContainerLayoutChanged = this.onContainerLayoutChanged.bind(this);
this.onContainerPressIn = this.onContainerPressIn.bind(this);
this.onContainerPress = this.onContainerPress.bind(this);
this.imageLoad = this.imageLoad.bind(this);
this.imageLoadingStart = this.imageLoadingStart.bind(this);
this.imageLoadingEnd = this.imageLoadingEnd.bind(this);
this.trackMovement = this.trackMovement.bind(this);
Expand All @@ -60,6 +46,9 @@ class ImageView extends PureComponent {
}

componentDidMount() {
Image.getSize(this.props.url, (width, height) => {
this.setImageRegion(width, height);
});
if (this.canUseTouchScreen) {
return;
}
Expand Down Expand Up @@ -218,10 +207,6 @@ class ImageView extends PureComponent {
this.setState(prevState => ({isDragging: prevState.isMouseDown}));
}

imageLoad({nativeEvent}) {
this.setImageRegion(nativeEvent.width, nativeEvent.height);
}

imageLoadingStart() {
this.setState({isLoading: true});
}
Expand All @@ -231,29 +216,24 @@ class ImageView extends PureComponent {
}

render() {
const headers = this.props.isAuthTokenRequired ? chatAttachmentTokenHeaders() : undefined;
if (this.canUseTouchScreen) {
return (
<View
style={[styles.imageViewContainer, styles.overflowHidden]}
onLayout={this.onContainerLayoutChanged}
>
<FastImage
source={{
uri: this.props.url,
headers,
}}
<Image
source={{uri: this.props.url}}
style={this.state.zoomScale === 0 ? undefined : [
styles.w100,
styles.h100,
]} // Hide image until zoomScale calculated to prevent showing preview with wrong dimensions.

// When Image dimensions are lower than the container boundary(zoomscale <= 1), use `contain` to render the image with natural dimensions.
// Both `center` and `contain` keeps the image centered on both x and y axis.
resizeMode={this.state.zoomScale > 1 ? FastImage.resizeMode.center : FastImage.resizeMode.contain}
resizeMode={this.state.zoomScale > 1 ? 'center' : 'contain'}
onLoadStart={this.imageLoadingStart}
onLoadEnd={this.imageLoadingEnd}
onLoad={this.imageLoad}
/>
{this.state.isLoading && (
<FullscreenLoadingIndicator
Expand Down Expand Up @@ -285,19 +265,15 @@ class ImageView extends PureComponent {
onPressIn={this.onContainerPressIn}
onPress={this.onContainerPress}
>
<FastImage
source={{
uri: this.props.url,
headers,
}}
<Image
source={{uri: this.props.url}}
style={this.state.zoomScale === 0 ? undefined : [
styles.h100,
styles.w100,
]} // Hide image until zoomScale calculated to prevent showing preview with wrong dimensions.
resizeMode={FastImage.resizeMode.contain}
resizeMode="contain"
onLoadStart={this.imageLoadingStart}
onLoadEnd={this.imageLoadingEnd}
onLoad={this.imageLoad}
/>
</Pressable>

Expand All @@ -312,7 +288,4 @@ class ImageView extends PureComponent {
}

ImageView.propTypes = propTypes;
ImageView.defaultProps = defaultProps;
export default compose(withWindowDimensions, withOnyx({
session: {key: ONYXKEYS.SESSION},
}))(ImageView);
export default withWindowDimensions(ImageView);
Loading

0 comments on commit 0d1deaa

Please sign in to comment.