From 87466568f3ad5a9f566c6e68ae9698373c9ee00b Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 12 Jun 2023 22:57:22 +0700 Subject: [PATCH 1/6] fix: move comment --- ios/Podfile.lock | 6 +++--- src/components/AttachmentCarousel/index.js | 6 +++++- src/components/AttachmentView.js | 4 ++++ src/components/PDFView/PDFPasswordForm.js | 16 ++++++++++++++++ src/components/PDFView/index.js | 1 + src/components/PDFView/index.native.js | 1 + src/components/PDFView/pdfViewPropTypes.js | 3 +++ src/libs/Permissions.js | 2 +- 8 files changed, 34 insertions(+), 5 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 6cb4235c58c8..c6c8ee0b4dce 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1019,7 +1019,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Airship: c70eed50e429f97f5adb285423c7291fb7a032ae AirshipFrameworkProxy: 7bc4130c668c6c98e2d4c60fe4c9eb61a999be99 - boost: a7c83b31436843459a1961bfd74b96033dc77234 + boost: 57d2868c099736d80fcd648bf211b4431e51a558 CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 FBLazyVector: ff54429f0110d3c722630a98096ba689c39f6d5f @@ -1062,7 +1062,7 @@ SPEC CHECKSUMS: Permission-LocationWhenInUse: 3ba99e45c852763f730eabecec2870c2382b7bd4 Plaid: 7d340abeadb46c7aa1a91f896c5b22395a31fcf2 PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef - RCT-Folly: 0080d0a6ebf2577475bda044aa59e2ca1f909cda + RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 RCTRequired: e9e7b8b45aa9bedb2fdad71740adf07a7265b9be RCTTypeSafety: 9ae0e9206625e995f0df4d5b9ddc94411929fb30 React: a71c8e1380f07e01de721ccd52bcf9c03e81867d @@ -1135,4 +1135,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 4ed1c7b099741c82e2b0411b95f6468e72be6c76 -COCOAPODS: 1.12.0 +COCOAPODS: 1.11.3 diff --git a/src/components/AttachmentCarousel/index.js b/src/components/AttachmentCarousel/index.js index 77ab66400ae2..6b63b1cc5731 100644 --- a/src/components/AttachmentCarousel/index.js +++ b/src/components/AttachmentCarousel/index.js @@ -1,5 +1,5 @@ import React from 'react'; -import {View, FlatList, PixelRatio} from 'react-native'; +import {View, FlatList, PixelRatio, Keyboard} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; @@ -212,6 +212,7 @@ class AttachmentCarousel extends React.Component { * @param {Array<{item: {source, file}, index: Number}>} viewableItems */ updatePage({viewableItems}) { + console.log("updatePage") // Since we can have only one item in view at a time, we can use the first item in the array // to get the index of the current page const entry = _.first(viewableItems); @@ -222,6 +223,7 @@ class AttachmentCarousel extends React.Component { const page = entry.index; this.props.onNavigate(entry.item); this.setState({page, isZoomed: false}); + Keyboard.dismiss() } /** @@ -252,6 +254,7 @@ class AttachmentCarousel extends React.Component { renderItem({item}) { return ( 0 && ( {}, onToggleKeyboard: () => {}, containerStyles: [], + isFocused: false }; const AttachmentView = (props) => { @@ -82,9 +84,11 @@ const AttachmentView = (props) => { // will appear with a source that is a blob if (Str.isPDF(props.source) || (props.file && Str.isPDF(props.file.name || props.translate('attachmentView.unknownFilename')))) { const sourceURL = props.isAuthTokenRequired ? addEncryptedAuthTokenToURL(props.source) : props.source; + console.log("AttachmentView: ", props.isFocused) const children = ( {this.props.translate('attachmentView.pdfPasswordForm.formLabel')} (this.textInputRef = el)} label={this.props.translate('common.password')} autoComplete="off" autoCorrect={false} diff --git a/src/components/PDFView/index.js b/src/components/PDFView/index.js index 85821b8d8ca3..aad57d0344e8 100644 --- a/src/components/PDFView/index.js +++ b/src/components/PDFView/index.js @@ -150,6 +150,7 @@ class PDFView extends Component { {this.state.shouldRequestPassword && ( this.setState({isPasswordInvalid: false})} isPasswordInvalid={this.state.isPasswordInvalid} diff --git a/src/components/PDFView/index.native.js b/src/components/PDFView/index.native.js index 7f9f33fca6f6..b668e9109470 100644 --- a/src/components/PDFView/index.native.js +++ b/src/components/PDFView/index.native.js @@ -158,6 +158,7 @@ class PDFView extends Component { {this.state.shouldRequestPassword && ( this.setState({isPasswordInvalid: false})} isPasswordInvalid={this.state.isPasswordInvalid} diff --git a/src/components/PDFView/pdfViewPropTypes.js b/src/components/PDFView/pdfViewPropTypes.js index f87cee3a11b6..0b1cb1ca7ad2 100644 --- a/src/components/PDFView/pdfViewPropTypes.js +++ b/src/components/PDFView/pdfViewPropTypes.js @@ -21,6 +21,8 @@ const propTypes = { /** Handles load complete event in PDF component */ onLoadComplete: PropTypes.func, + isFocused: PropTypes.bool, + ...windowDimensionsPropTypes, }; @@ -31,6 +33,7 @@ const defaultProps = { onToggleKeyboard: () => {}, onScaleChanged: () => {}, onLoadComplete: () => {}, + isFocused: false }; export {propTypes, defaultProps}; diff --git a/src/libs/Permissions.js b/src/libs/Permissions.js index d3e407260e20..cf4904cce6e5 100644 --- a/src/libs/Permissions.js +++ b/src/libs/Permissions.js @@ -99,7 +99,7 @@ function canUsePasswordlessLogins(betas) { * @returns {Boolean} */ function canUseTasks(betas) { - return _.contains(betas, CONST.BETAS.TASKS) || _.contains(betas, CONST.BETAS.ALL); + return true } export default { From 909d7c95f8e65460734b2f0f077a7a1b34f5ef65 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 12 Jun 2023 23:28:18 +0700 Subject: [PATCH 2/6] fix: update --- src/components/AttachmentCarousel/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/AttachmentCarousel/index.js b/src/components/AttachmentCarousel/index.js index 6b63b1cc5731..cc8b069caa54 100644 --- a/src/components/AttachmentCarousel/index.js +++ b/src/components/AttachmentCarousel/index.js @@ -187,6 +187,7 @@ class AttachmentCarousel extends React.Component { shouldShowArrow: this.canUseTouchScreen, containerWidth: 0, isZoomed: false, + activeSource: null }; } @@ -212,18 +213,20 @@ class AttachmentCarousel extends React.Component { * @param {Array<{item: {source, file}, index: Number}>} viewableItems */ updatePage({viewableItems}) { - console.log("updatePage") + Keyboard.dismiss(); + console.log("updatePage", viewableItems) // Since we can have only one item in view at a time, we can use the first item in the array // to get the index of the current page const entry = _.first(viewableItems); if (!entry) { + this.setState({ activeSource: null }); return; } + console.log('entry.item', entry.item); const page = entry.index; this.props.onNavigate(entry.item); - this.setState({page, isZoomed: false}); - Keyboard.dismiss() + this.setState({page, isZoomed: false, activeSource: entry.item.source}); } /** @@ -254,7 +257,7 @@ class AttachmentCarousel extends React.Component { renderItem({item}) { return ( Date: Fri, 23 Jun 2023 08:19:04 +0700 Subject: [PATCH 3/6] remove redundant --- ios/Podfile.lock | 6 +++--- src/libs/Permissions.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 80ba0e0b5b79..048eeca5f76f 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1024,7 +1024,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Airship: c70eed50e429f97f5adb285423c7291fb7a032ae AirshipFrameworkProxy: 7bc4130c668c6c98e2d4c60fe4c9eb61a999be99 - boost: 57d2868c099736d80fcd648bf211b4431e51a558 + boost: a7c83b31436843459a1961bfd74b96033dc77234 CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 FBLazyVector: ff54429f0110d3c722630a98096ba689c39f6d5f @@ -1067,7 +1067,7 @@ SPEC CHECKSUMS: Permission-LocationWhenInUse: 3ba99e45c852763f730eabecec2870c2382b7bd4 Plaid: 7d340abeadb46c7aa1a91f896c5b22395a31fcf2 PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef - RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 + RCT-Folly: 0080d0a6ebf2577475bda044aa59e2ca1f909cda RCTRequired: e9e7b8b45aa9bedb2fdad71740adf07a7265b9be RCTTypeSafety: 9ae0e9206625e995f0df4d5b9ddc94411929fb30 React: a71c8e1380f07e01de721ccd52bcf9c03e81867d @@ -1141,4 +1141,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 4ed1c7b099741c82e2b0411b95f6468e72be6c76 -COCOAPODS: 1.11.3 +COCOAPODS: 1.12.0 diff --git a/src/libs/Permissions.js b/src/libs/Permissions.js index cf4904cce6e5..d3e407260e20 100644 --- a/src/libs/Permissions.js +++ b/src/libs/Permissions.js @@ -99,7 +99,7 @@ function canUsePasswordlessLogins(betas) { * @returns {Boolean} */ function canUseTasks(betas) { - return true + return _.contains(betas, CONST.BETAS.TASKS) || _.contains(betas, CONST.BETAS.ALL); } export default { From 86f29aab7cd21b71e9944a7716c1a1ccc8facb97 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 23 Jun 2023 08:21:18 +0700 Subject: [PATCH 4/6] remove redundant --- src/components/AttachmentCarousel/index.js | 6 ++---- src/components/AttachmentView.js | 3 +-- src/components/PDFView/PDFPasswordForm.js | 6 ------ src/components/PDFView/index.js | 2 +- src/components/PDFView/pdfViewPropTypes.js | 2 +- 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/components/AttachmentCarousel/index.js b/src/components/AttachmentCarousel/index.js index 71dec1a56342..d25d87a3ba49 100644 --- a/src/components/AttachmentCarousel/index.js +++ b/src/components/AttachmentCarousel/index.js @@ -195,7 +195,7 @@ class AttachmentCarousel extends React.Component { shouldShowArrow: this.canUseTouchScreen, containerWidth: 0, isZoomed: false, - activeSource: null + activeSource: null, }; } @@ -227,15 +227,13 @@ class AttachmentCarousel extends React.Component { */ updatePage({viewableItems}) { Keyboard.dismiss(); - console.log("updatePage", viewableItems) // Since we can have only one item in view at a time, we can use the first item in the array // to get the index of the current page const entry = _.first(viewableItems); if (!entry) { - this.setState({ activeSource: null }); + this.setState({activeSource: null}); return; } - console.log('entry.item', entry.item); const page = entry.index; this.props.onNavigate(entry.item); diff --git a/src/components/AttachmentView.js b/src/components/AttachmentView.js index 28ff43a46cff..6ce10e364194 100755 --- a/src/components/AttachmentView.js +++ b/src/components/AttachmentView.js @@ -63,7 +63,7 @@ const defaultProps = { onScaleChanged: () => {}, onToggleKeyboard: () => {}, containerStyles: [], - isFocused: false + isFocused: false, }; function AttachmentView(props) { @@ -85,7 +85,6 @@ function AttachmentView(props) { // will appear with a source that is a blob if (Str.isPDF(props.source) || (props.file && Str.isPDF(props.file.name || props.translate('attachmentView.unknownFilename')))) { const sourceURL = props.isAuthTokenRequired ? addEncryptedAuthTokenToURL(props.source) : props.source; - console.log("AttachmentView: ", props.isFocused) const children = ( {this.state.shouldRequestPassword && ( this.setState({isPasswordInvalid: false})} isPasswordInvalid={this.state.isPasswordInvalid} diff --git a/src/components/PDFView/pdfViewPropTypes.js b/src/components/PDFView/pdfViewPropTypes.js index 0b1cb1ca7ad2..d965234b799a 100644 --- a/src/components/PDFView/pdfViewPropTypes.js +++ b/src/components/PDFView/pdfViewPropTypes.js @@ -33,7 +33,7 @@ const defaultProps = { onToggleKeyboard: () => {}, onScaleChanged: () => {}, onLoadComplete: () => {}, - isFocused: false + isFocused: false, }; export {propTypes, defaultProps}; From 388bba074f87ca6b20ebd65dfd821d8cb7bb3e29 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Sun, 25 Jun 2023 22:22:27 +0700 Subject: [PATCH 5/6] add comment for prop --- src/components/AttachmentView.js | 2 ++ src/components/PDFView/PDFPasswordForm.js | 7 ++++--- src/components/PDFView/pdfViewPropTypes.js | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/AttachmentView.js b/src/components/AttachmentView.js index 6ce10e364194..8516c6c6587f 100755 --- a/src/components/AttachmentView.js +++ b/src/components/AttachmentView.js @@ -35,7 +35,9 @@ const propTypes = { /** Flag to show the loading indicator */ shouldShowLoadingSpinnerIcon: PropTypes.bool, + /** Should focus to the password input */ isFocused: PropTypes.bool, + /** Function for handle on press */ onPress: PropTypes.func, diff --git a/src/components/PDFView/PDFPasswordForm.js b/src/components/PDFView/PDFPasswordForm.js index 43ac66093dac..423bc49511c2 100644 --- a/src/components/PDFView/PDFPasswordForm.js +++ b/src/components/PDFView/PDFPasswordForm.js @@ -30,6 +30,7 @@ const propTypes = { /** Notify parent that a text field has been focused or blurred */ onPasswordFieldFocused: PropTypes.func, + /** Should focus to the password input */ isFocused: PropTypes.bool.isRequired, ...withLocalizePropTypes, @@ -58,11 +59,11 @@ class PDFPasswordForm extends Component { this.validateAndNotifyPasswordBlur = this.validateAndNotifyPasswordBlur.bind(this); } - // eslint-disable-next-line rulesdir/prefer-early-return componentDidUpdate(prevProps) { - if (!prevProps.isFocused && this.props.isFocused && this.textInputRef) { - this.textInputRef.focus(); + if (prevProps.isFocused || !this.props.isFocused || !this.textInputRef) { + return; } + this.textInputRef.focus(); } submitPassword() { diff --git a/src/components/PDFView/pdfViewPropTypes.js b/src/components/PDFView/pdfViewPropTypes.js index d965234b799a..74a4c7f48524 100644 --- a/src/components/PDFView/pdfViewPropTypes.js +++ b/src/components/PDFView/pdfViewPropTypes.js @@ -21,6 +21,7 @@ const propTypes = { /** Handles load complete event in PDF component */ onLoadComplete: PropTypes.func, + /** Should focus to the password input */ isFocused: PropTypes.bool, ...windowDimensionsPropTypes, From e02647e795f2b8b8976d189a39bce52ad628290a Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Sun, 25 Jun 2023 22:37:24 +0700 Subject: [PATCH 6/6] update comment --- src/components/AttachmentView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/AttachmentView.js b/src/components/AttachmentView.js index 8516c6c6587f..383770f9279b 100755 --- a/src/components/AttachmentView.js +++ b/src/components/AttachmentView.js @@ -35,7 +35,7 @@ const propTypes = { /** Flag to show the loading indicator */ shouldShowLoadingSpinnerIcon: PropTypes.bool, - /** Should focus to the password input */ + /** Whether this view is the active screen */ isFocused: PropTypes.bool, /** Function for handle on press */