From 13a33cf7df108bd0751b47412289b8a0a95856ff Mon Sep 17 00:00:00 2001 From: Ben Limpich Date: Tue, 30 Jan 2024 12:52:10 -0800 Subject: [PATCH 01/27] remove unnecessary concierge check --- src/libs/ReportUtils.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 58b0489314a0..853c306d1cec 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1561,14 +1561,6 @@ function getPersonalDetailsForAccountID(accountID: number): Partial Date: Thu, 1 Feb 2024 23:47:55 +0800 Subject: [PATCH 02/27] use the stack navigator to go back --- src/pages/NewChatSelectorPage.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pages/NewChatSelectorPage.js b/src/pages/NewChatSelectorPage.js index ba64ffec5a96..93669d79dab4 100755 --- a/src/pages/NewChatSelectorPage.js +++ b/src/pages/NewChatSelectorPage.js @@ -1,3 +1,4 @@ +import {useNavigation} from '@react-navigation/native'; import React from 'react'; import {withOnyx} from 'react-native-onyx'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; @@ -25,6 +26,8 @@ const defaultProps = { }; function NewChatSelectorPage(props) { + const navigation = useNavigation(); + return ( - + ( From 1503aad4e93116d68f1a484291d85298ec9b7fc5 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 2 Feb 2024 00:16:10 +0800 Subject: [PATCH 03/27] rename --- src/pages/NewChatSelectorPage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/NewChatSelectorPage.js b/src/pages/NewChatSelectorPage.js index 93669d79dab4..093cb285ed54 100755 --- a/src/pages/NewChatSelectorPage.js +++ b/src/pages/NewChatSelectorPage.js @@ -42,10 +42,10 @@ function NewChatSelectorPage(props) { /> ( + tabBar={({state, navigation: tabNavigation, position}) => ( )} From 382510499af817c7490a08c77472d5ff874f0444 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 6 Feb 2024 11:04:57 +0800 Subject: [PATCH 04/27] remove unused import --- src/pages/NewChatSelectorPage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/NewChatSelectorPage.js b/src/pages/NewChatSelectorPage.js index f5cdafc17df9..0e8e192db884 100755 --- a/src/pages/NewChatSelectorPage.js +++ b/src/pages/NewChatSelectorPage.js @@ -7,7 +7,6 @@ import TabSelector from '@components/TabSelector/TabSelector'; import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; import withWindowDimensions, {windowDimensionsPropTypes} from '@components/withWindowDimensions'; import compose from '@libs/compose'; -import Navigation from '@libs/Navigation/Navigation'; import OnyxTabNavigator, {TopTab} from '@libs/Navigation/OnyxTabNavigator'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; From 40b514fe11010b160d0ad6ba59cf263e0e4d9867 Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 6 Feb 2024 23:37:27 +0700 Subject: [PATCH 05/27] fix: incomplete referral link --- src/libs/actions/User.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 09cc6e49e6cc..5007fa96fa10 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -678,6 +678,13 @@ function generateStatementPDF(period: string) { function setContactMethodAsDefault(newDefaultContactMethod: string) { const oldDefaultContactMethod = currentEmail; const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.ACCOUNT, + value: { + primaryLogin: newDefaultContactMethod, + }, + }, { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.SESSION, @@ -724,6 +731,13 @@ function setContactMethodAsDefault(newDefaultContactMethod: string) { }, ]; const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.ACCOUNT, + value: { + primaryLogin: oldDefaultContactMethod, + }, + }, { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.SESSION, From 5c1ec242d5a45f3405f92562158260e31d55e95a Mon Sep 17 00:00:00 2001 From: Antony Kithinzi Date: Sun, 11 Feb 2024 04:09:42 +0100 Subject: [PATCH 06/27] Replaced 'isReportMessageAttachment' with 'ReportActionsUtils.isReportActionAttachment' --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 26280f95447d..fc0ebfcb394a 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2142,7 +2142,7 @@ function canEditReportAction(reportAction: OnyxEntry): boolean { reportAction?.actorAccountID === currentUserAccountID && isCommentOrIOU && canEditMoneyRequest(reportAction) && // Returns true for non-IOU actions - !isReportMessageAttachment(reportAction?.message?.[0] ?? {type: '', text: ''}) && + !ReportActionsUtils.isReportActionAttachment(reportAction) && !ReportActionsUtils.isDeletedAction(reportAction) && !ReportActionsUtils.isCreatedTaskReportAction(reportAction) && reportAction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, From 58189b8d99f891c4b118b136f997b66d7eda149a Mon Sep 17 00:00:00 2001 From: Antony Kithinzi Date: Mon, 12 Feb 2024 00:49:08 +0100 Subject: [PATCH 07/27] fix: Improved 'isReportActionAttachment' to detect video attachments from optimistic data --- src/libs/ReportActionsUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 1aeb6e6e7343..4a479708dcb8 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -667,8 +667,8 @@ function getAllReportActions(reportID: string): ReportActions { function isReportActionAttachment(reportAction: OnyxEntry): boolean { const message = reportAction?.message?.[0]; - if (reportAction && 'isAttachment' in reportAction) { - return reportAction.isAttachment ?? false; + if (reportAction && ('attachmentInfo' in reportAction || 'isAttachment' in reportAction)) { + return !!reportAction.attachmentInfo || !!reportAction.isAttachment; } if (message) { From 98cac0c9f16c7f927128ffd8a2b55362c73c7ad8 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Wed, 14 Feb 2024 17:25:40 +0100 Subject: [PATCH 08/27] feat: swipe to dismiss (initial changes) --- src/components/MultiGestureCanvas/index.tsx | 2 + src/components/MultiGestureCanvas/types.ts | 1 + .../MultiGestureCanvas/usePanGesture.ts | 57 ++++++++++++++++--- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/src/components/MultiGestureCanvas/index.tsx b/src/components/MultiGestureCanvas/index.tsx index a7eca6baa18f..6d00384cee1b 100644 --- a/src/components/MultiGestureCanvas/index.tsx +++ b/src/components/MultiGestureCanvas/index.tsx @@ -102,6 +102,7 @@ function MultiGestureCanvas({ const panTranslateX = useSharedValue(0); const panTranslateY = useSharedValue(0); + const isSwipingDownToClose = useSharedValue(false); const panGestureRef = useRef(Gesture.Pan()); const pinchScale = useSharedValue(1); @@ -186,6 +187,7 @@ function MultiGestureCanvas({ panTranslateX, panTranslateY, isPagerSwiping, + isSwipingDownToClose, stopAnimation, }) .simultaneousWithExternalGesture(...panGestureSimultaneousList) diff --git a/src/components/MultiGestureCanvas/types.ts b/src/components/MultiGestureCanvas/types.ts index bbd8f69e6947..00e7e3017dab 100644 --- a/src/components/MultiGestureCanvas/types.ts +++ b/src/components/MultiGestureCanvas/types.ts @@ -32,6 +32,7 @@ type MultiGestureCanvasVariables = { minContentScale: number; maxContentScale: number; isPagerSwiping: SharedValue; + isSwipingDownToClose: SharedValue; zoomScale: SharedValue; totalScale: SharedValue; pinchScale: SharedValue; diff --git a/src/components/MultiGestureCanvas/usePanGesture.ts b/src/components/MultiGestureCanvas/usePanGesture.ts index 8a646446fad4..026cf53d5598 100644 --- a/src/components/MultiGestureCanvas/usePanGesture.ts +++ b/src/components/MultiGestureCanvas/usePanGesture.ts @@ -13,19 +13,37 @@ const PAN_DECAY_DECELARATION = 0.9915; type UsePanGestureProps = Pick< MultiGestureCanvasVariables, - 'canvasSize' | 'contentSize' | 'zoomScale' | 'totalScale' | 'offsetX' | 'offsetY' | 'panTranslateX' | 'panTranslateY' | 'isPagerSwiping' | 'stopAnimation' + 'canvasSize' | 'contentSize' | 'zoomScale' | 'totalScale' | 'offsetX' | 'offsetY' | 'panTranslateX' | 'panTranslateY' | 'isPagerSwiping' | 'isSwipingDownToClose' | 'stopAnimation' >; -const usePanGesture = ({canvasSize, contentSize, zoomScale, totalScale, offsetX, offsetY, panTranslateX, panTranslateY, isPagerSwiping, stopAnimation}: UsePanGestureProps): PanGesture => { +const usePanGesture = ({ + canvasSize, + contentSize, + zoomScale, + totalScale, + offsetX, + offsetY, + panTranslateX, + panTranslateY, + isPagerSwiping, + isSwipingDownToClose, + stopAnimation, +}: UsePanGestureProps): PanGesture => { // The content size after fitting it to the canvas and zooming const zoomedContentWidth = useDerivedValue(() => contentSize.width * totalScale.value, [contentSize.width]); const zoomedContentHeight = useDerivedValue(() => contentSize.height * totalScale.value, [contentSize.height]); + // Used to track previous touch position for the "swipe down to close" gesture + const previousTouch = useSharedValue<{x: number; y: number} | null>(null); + // Velocity of the pan gesture // We need to keep track of the velocity to properly phase out/decay the pan animation const panVelocityX = useSharedValue(0); const panVelocityY = useSharedValue(0); + // Disable "swipe down to close" gesture when content is bigger than the canvas + const enableSwipeDownToClose = useDerivedValue(() => canvasSize.height < zoomedContentHeight.value, [canvasSize.height]); + // Calculates bounds of the scaled content // Can we pan left/right/up/down // Can be used to limit gesture or implementing tension effect @@ -117,11 +135,31 @@ const usePanGesture = ({canvasSize, contentSize, zoomScale, totalScale, offsetX, // eslint-disable-next-line @typescript-eslint/naming-convention .onTouchesMove((_evt, state) => { // We only allow panning when the content is zoomed in - if (zoomScale.value <= 1 || isPagerSwiping.value) { - return; + if (zoomScale.value > 1) { + state.activate(); + } + + // TODO: this needs tuning to work properly + if (!isPagerSwiping.value && zoomScale.value === 1 && previousTouch.value != null) { + const velocityX = Math.abs(_evt.allTouches[0].x - previousTouch.value.x); + const velocityY = _evt.allTouches[0].y - previousTouch.value.y; + + if (Math.abs(velocityY) > velocityX && velocityY > 20) { + state.activate(); + + isSwipingDownToClose.value = true; + previousTouch.value = null; + + return; + } } - state.activate(); + if (previousTouch.value == null) { + previousTouch.value = { + x: _evt.allTouches[0].x, + y: _evt.allTouches[0].y, + }; + } }) .onStart(() => { stopAnimation(); @@ -136,8 +174,13 @@ const usePanGesture = ({canvasSize, contentSize, zoomScale, totalScale, offsetX, panVelocityX.value = evt.velocityX; panVelocityY.value = evt.velocityY; - panTranslateX.value += evt.changeX; - panTranslateY.value += evt.changeY; + if (!isSwipingDownToClose.value) { + panTranslateX.value += evt.changeX; + } + + if (enableSwipeDownToClose.value || isSwipingDownToClose.value) { + panTranslateY.value += evt.changeY; + } }) .onEnd(() => { // Add pan translation to total offset and reset gesture variables From 34aa114b610cb28a7a4e06f1e13224ad12b0b132 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Thu, 15 Feb 2024 20:34:16 +0100 Subject: [PATCH 09/27] feat: swipeable card (in all states properly) --- .../MultiGestureCanvas/usePanGesture.ts | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/components/MultiGestureCanvas/usePanGesture.ts b/src/components/MultiGestureCanvas/usePanGesture.ts index 026cf53d5598..661dabadbb75 100644 --- a/src/components/MultiGestureCanvas/usePanGesture.ts +++ b/src/components/MultiGestureCanvas/usePanGesture.ts @@ -121,7 +121,9 @@ const usePanGesture = ({ } } else { // Animated back to the boundary - offsetY.value = withSpring(clampedOffset.y, SPRING_CONFIG); + offsetY.value = withSpring(clampedOffset.y, SPRING_CONFIG, () => { + isSwipingDownToClose.value = false; + }); } // Reset velocity variables after we finished the pan gesture @@ -132,17 +134,19 @@ const usePanGesture = ({ const panGesture = Gesture.Pan() .manualActivation(true) .averageTouches(true) - // eslint-disable-next-line @typescript-eslint/naming-convention - .onTouchesMove((_evt, state) => { + .onTouchesUp(() => { + previousTouch.value = null; + }) + .onTouchesMove((evt, state) => { // We only allow panning when the content is zoomed in if (zoomScale.value > 1) { state.activate(); } // TODO: this needs tuning to work properly - if (!isPagerSwiping.value && zoomScale.value === 1 && previousTouch.value != null) { - const velocityX = Math.abs(_evt.allTouches[0].x - previousTouch.value.x); - const velocityY = _evt.allTouches[0].y - previousTouch.value.y; + if (!isPagerSwiping.value && zoomScale.value === 1 && previousTouch.value !== null) { + const velocityX = Math.abs(evt.allTouches[0].x - previousTouch.value.x); + const velocityY = evt.allTouches[0].y - previousTouch.value.y; if (Math.abs(velocityY) > velocityX && velocityY > 20) { state.activate(); @@ -154,10 +158,10 @@ const usePanGesture = ({ } } - if (previousTouch.value == null) { + if (previousTouch.value === null) { previousTouch.value = { - x: _evt.allTouches[0].x, - y: _evt.allTouches[0].y, + x: evt.allTouches[0].x, + y: evt.allTouches[0].y, }; } }) @@ -186,8 +190,11 @@ const usePanGesture = ({ // Add pan translation to total offset and reset gesture variables offsetX.value += panTranslateX.value; offsetY.value += panTranslateY.value; + + // Reset pan gesture variables panTranslateX.value = 0; panTranslateY.value = 0; + previousTouch.value = null; // If we are swiping (in the pager), we don't want to return to boundaries if (isPagerSwiping.value) { From 08b39ca5850d7e637a4523f123a69d186254e905 Mon Sep 17 00:00:00 2001 From: Antony Kithinzi Date: Thu, 15 Feb 2024 23:33:37 +0100 Subject: [PATCH 10/27] fix: used isVideo in isReportMessageAttachment --- src/libs/ReportActionsUtils.ts | 4 ++-- src/libs/isReportMessageAttachment.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index d05224351392..026db9dbf8d1 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -700,8 +700,8 @@ function getAllReportActions(reportID: string): ReportActions { function isReportActionAttachment(reportAction: OnyxEntry): boolean { const message = reportAction?.message?.[0]; - if (reportAction && ('attachmentInfo' in reportAction || 'isAttachment' in reportAction)) { - return !!reportAction.attachmentInfo || !!reportAction.isAttachment; + if (reportAction && (reportAction.attachmentInfo ?? reportAction.isAttachment)) { + return true; } if (message) { diff --git a/src/libs/isReportMessageAttachment.ts b/src/libs/isReportMessageAttachment.ts index df8a589f7bdc..af4ec20b8d25 100644 --- a/src/libs/isReportMessageAttachment.ts +++ b/src/libs/isReportMessageAttachment.ts @@ -1,5 +1,6 @@ import CONST from '@src/CONST'; import type {Message} from '@src/types/onyx/ReportAction'; +import Str from 'expensify-common/lib/str'; /** * Check whether a report action is Attachment or not. @@ -15,7 +16,7 @@ export default function isReportMessageAttachment({text, html, translationKey}: if (translationKey && text === CONST.ATTACHMENT_MESSAGE_TEXT) { return translationKey === CONST.TRANSLATION_KEYS.ATTACHMENT; } - + const regex = new RegExp(` ${CONST.ATTACHMENT_SOURCE_ATTRIBUTE}="(.*)"`, 'i'); - return text === CONST.ATTACHMENT_MESSAGE_TEXT && (!!html.match(regex) || html === CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML); + return (text === CONST.ATTACHMENT_MESSAGE_TEXT || !!Str.isVideo(text)) && (!!html.match(regex) || html === CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML); } From 1b7b664be21232c4f239d25400b43edf6eeaa7f4 Mon Sep 17 00:00:00 2001 From: Antony Kithinzi Date: Thu, 15 Feb 2024 23:56:37 +0100 Subject: [PATCH 11/27] lint --- src/libs/isReportMessageAttachment.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/isReportMessageAttachment.ts b/src/libs/isReportMessageAttachment.ts index af4ec20b8d25..fd03adcffd93 100644 --- a/src/libs/isReportMessageAttachment.ts +++ b/src/libs/isReportMessageAttachment.ts @@ -1,6 +1,6 @@ +import Str from 'expensify-common/lib/str'; import CONST from '@src/CONST'; import type {Message} from '@src/types/onyx/ReportAction'; -import Str from 'expensify-common/lib/str'; /** * Check whether a report action is Attachment or not. @@ -16,7 +16,7 @@ export default function isReportMessageAttachment({text, html, translationKey}: if (translationKey && text === CONST.ATTACHMENT_MESSAGE_TEXT) { return translationKey === CONST.TRANSLATION_KEYS.ATTACHMENT; } - + const regex = new RegExp(` ${CONST.ATTACHMENT_SOURCE_ATTRIBUTE}="(.*)"`, 'i'); return (text === CONST.ATTACHMENT_MESSAGE_TEXT || !!Str.isVideo(text)) && (!!html.match(regex) || html === CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML); } From ece80bb74204bb9f5f5d8ab9e98526316e4db698 Mon Sep 17 00:00:00 2001 From: mkhutornyi Date: Sun, 18 Feb 2024 19:40:12 +0200 Subject: [PATCH 12/27] disable iOS bounce on private notes page --- src/pages/PrivateNotes/PrivateNotesListPage.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/PrivateNotes/PrivateNotesListPage.tsx b/src/pages/PrivateNotes/PrivateNotesListPage.tsx index 97ebc7dee2fb..0a6a2659ffb6 100644 --- a/src/pages/PrivateNotes/PrivateNotesListPage.tsx +++ b/src/pages/PrivateNotes/PrivateNotesListPage.tsx @@ -88,7 +88,12 @@ function PrivateNotesListPage({report, personalDetailsList, session}: PrivateNot onCloseButtonPress={() => Navigation.dismissModal()} /> {translate('privateNotes.personalNoteMessage')} - {privateNotes.map((item) => getMenuItem(item))} + + {privateNotes.map((item) => getMenuItem(item))} + ); } From e395ed660d319b07efaab30fdcdac5f4157d59f1 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Tue, 20 Feb 2024 19:35:57 +0100 Subject: [PATCH 13/27] feat: actually close carousel if gesture down happens --- .../Pager/AttachmentCarouselPagerContext.ts | 1 + .../AttachmentCarousel/Pager/index.tsx | 6 ++-- .../AttachmentCarousel/index.native.js | 5 +++ src/components/MultiGestureCanvas/index.tsx | 3 ++ src/components/MultiGestureCanvas/types.ts | 4 +++ .../MultiGestureCanvas/usePanGesture.ts | 35 +++++++++++++++---- 6 files changed, 46 insertions(+), 8 deletions(-) diff --git a/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPagerContext.ts b/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPagerContext.ts index 270e0b04909c..ac08591c2812 100644 --- a/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPagerContext.ts +++ b/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPagerContext.ts @@ -9,6 +9,7 @@ type AttachmentCarouselPagerContextValue = { isScrollEnabled: SharedValue; onTap: () => void; onScaleChanged: (scale: number) => void; + onSwipeDown: () => void; }; const AttachmentCarouselPagerContext = createContext(null); diff --git a/src/components/Attachments/AttachmentCarousel/Pager/index.tsx b/src/components/Attachments/AttachmentCarousel/Pager/index.tsx index 490afb6614ac..d5b8ba2d36f4 100644 --- a/src/components/Attachments/AttachmentCarousel/Pager/index.tsx +++ b/src/components/Attachments/AttachmentCarousel/Pager/index.tsx @@ -31,9 +31,10 @@ type AttachmentCarouselPagerProps = { initialIndex: number; onPageSelected: () => void; onRequestToggleArrows: (showArrows?: boolean) => void; + onClose: () => void; }; -function AttachmentCarouselPager({items, renderItem, initialIndex, onPageSelected, onRequestToggleArrows}: AttachmentCarouselPagerProps, ref: ForwardedRef) { +function AttachmentCarouselPager({items, renderItem, initialIndex, onPageSelected, onRequestToggleArrows, onClose}: AttachmentCarouselPagerProps, ref: ForwardedRef) { const styles = useThemeStyles(); const pagerRef = useRef(null); @@ -98,9 +99,10 @@ function AttachmentCarouselPager({items, renderItem, initialIndex, onPageSelecte isPagerScrolling, isScrollEnabled, onTap: handleTap, + onSwipeDown: onClose, onScaleChanged: handleScaleChange, }), - [isPagerScrolling, isScrollEnabled, handleTap, handleScaleChange], + [isPagerScrolling, isScrollEnabled, handleTap, handleScaleChange, onClose], ); const animatedProps = useAnimatedProps(() => ({ diff --git a/src/components/Attachments/AttachmentCarousel/index.native.js b/src/components/Attachments/AttachmentCarousel/index.native.js index fa24ccd0ef53..cd437740900b 100644 --- a/src/components/Attachments/AttachmentCarousel/index.native.js +++ b/src/components/Attachments/AttachmentCarousel/index.native.js @@ -103,6 +103,10 @@ function AttachmentCarousel({report, reportActions, parentReportActions, source, [setShouldShowArrows], ); + const goBack = useCallback(() => { + Navigation.goBack(); + }, []); + /** * Defines how a single attachment should be rendered * @param {{ reportActionID: String, isAuthTokenRequired: Boolean, source: String, file: { name: String }, hasBeenFlagged: Boolean }} item @@ -152,6 +156,7 @@ function AttachmentCarousel({report, reportActions, parentReportActions, source, initialIndex={page} onRequestToggleArrows={toggleArrows} onPageSelected={({nativeEvent: {position: newPage}}) => updatePage(newPage)} + onClose={goBack} ref={pagerRef} /> diff --git a/src/components/MultiGestureCanvas/index.tsx b/src/components/MultiGestureCanvas/index.tsx index 6d00384cee1b..1e89c81c0058 100644 --- a/src/components/MultiGestureCanvas/index.tsx +++ b/src/components/MultiGestureCanvas/index.tsx @@ -55,6 +55,7 @@ function MultiGestureCanvas({ const attachmentCarouselPagerContext = useContext(AttachmentCarouselPagerContext); const { onTap, + onSwipeDown, onScaleChanged: onScaleChangedContext, isPagerScrolling: isPagerSwiping, pagerRef, @@ -62,6 +63,7 @@ function MultiGestureCanvas({ () => attachmentCarouselPagerContext ?? { onTap: () => {}, + onSwipeDown: () => {}, onScaleChanged: () => {}, pagerRef: undefined, isPagerScrolling: isSwipingInPagerFallback, @@ -189,6 +191,7 @@ function MultiGestureCanvas({ isPagerSwiping, isSwipingDownToClose, stopAnimation, + onSwipeDown, }) .simultaneousWithExternalGesture(...panGestureSimultaneousList) .withRef(panGestureRef); diff --git a/src/components/MultiGestureCanvas/types.ts b/src/components/MultiGestureCanvas/types.ts index 00e7e3017dab..aa090a86fa37 100644 --- a/src/components/MultiGestureCanvas/types.ts +++ b/src/components/MultiGestureCanvas/types.ts @@ -24,6 +24,9 @@ type OnScaleChangedCallback = (zoomScale: number) => void; /** Triggered when the canvas is tapped (single tap) */ type OnTapCallback = () => void; +/** Triggered when the swipe down gesture on canvas occurs */ +type OnSwipeDownCallback = () => void; + /** Types used of variables used within the MultiGestureCanvas component and it's hooks */ type MultiGestureCanvasVariables = { canvasSize: CanvasSize; @@ -46,6 +49,7 @@ type MultiGestureCanvasVariables = { reset: (animated: boolean, callback: () => void) => void; onTap: OnTapCallback; onScaleChanged: OnScaleChangedCallback | undefined; + onSwipeDown: OnSwipeDownCallback; }; export type {CanvasSize, ContentSize, ZoomRange, OnScaleChangedCallback, MultiGestureCanvasVariables}; diff --git a/src/components/MultiGestureCanvas/usePanGesture.ts b/src/components/MultiGestureCanvas/usePanGesture.ts index 661dabadbb75..3d82a1306175 100644 --- a/src/components/MultiGestureCanvas/usePanGesture.ts +++ b/src/components/MultiGestureCanvas/usePanGesture.ts @@ -1,7 +1,7 @@ /* eslint-disable no-param-reassign */ import type {PanGesture} from 'react-native-gesture-handler'; import {Gesture} from 'react-native-gesture-handler'; -import {useDerivedValue, useSharedValue, useWorkletCallback, withDecay, withSpring} from 'react-native-reanimated'; +import {runOnJS, useDerivedValue, useSharedValue, useWorkletCallback, withDecay, withSpring} from 'react-native-reanimated'; import {SPRING_CONFIG} from './constants'; import type {MultiGestureCanvasVariables} from './types'; import * as MultiGestureCanvasUtils from './utils'; @@ -13,7 +13,18 @@ const PAN_DECAY_DECELARATION = 0.9915; type UsePanGestureProps = Pick< MultiGestureCanvasVariables, - 'canvasSize' | 'contentSize' | 'zoomScale' | 'totalScale' | 'offsetX' | 'offsetY' | 'panTranslateX' | 'panTranslateY' | 'isPagerSwiping' | 'isSwipingDownToClose' | 'stopAnimation' + | 'canvasSize' + | 'contentSize' + | 'zoomScale' + | 'totalScale' + | 'offsetX' + | 'offsetY' + | 'panTranslateX' + | 'panTranslateY' + | 'isPagerSwiping' + | 'isSwipingDownToClose' + | 'stopAnimation' + | 'onSwipeDown' >; const usePanGesture = ({ @@ -28,6 +39,7 @@ const usePanGesture = ({ isPagerSwiping, isSwipingDownToClose, stopAnimation, + onSwipeDown, }: UsePanGestureProps): PanGesture => { // The content size after fitting it to the canvas and zooming const zoomedContentWidth = useDerivedValue(() => contentSize.width * totalScale.value, [contentSize.width]); @@ -120,10 +132,21 @@ const usePanGesture = ({ }); } } else { - // Animated back to the boundary - offsetY.value = withSpring(clampedOffset.y, SPRING_CONFIG, () => { - isSwipingDownToClose.value = false; - }); + const finalTranslateY = offsetY.value + panVelocityY.value * 0.2; + + // TODO: calculate these values (250/500) programmatically + if (finalTranslateY > 250) { + offsetY.value = withSpring(500, SPRING_CONFIG, () => { + isSwipingDownToClose.value = false; + }); + + runOnJS(onSwipeDown)(); + } else { + // Animated back to the boundary + offsetY.value = withSpring(clampedOffset.y, SPRING_CONFIG, () => { + isSwipingDownToClose.value = false; + }); + } } // Reset velocity variables after we finished the pan gesture From 2b7ce7d97c40c64b82af7160a1b7d67b3a28c4b3 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Wed, 21 Feb 2024 18:12:20 +0100 Subject: [PATCH 14/27] fix: post merge fix --- src/components/MultiGestureCanvas/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MultiGestureCanvas/types.ts b/src/components/MultiGestureCanvas/types.ts index d56a210c2cda..ceb29a0333b4 100644 --- a/src/components/MultiGestureCanvas/types.ts +++ b/src/components/MultiGestureCanvas/types.ts @@ -52,4 +52,4 @@ type MultiGestureCanvasVariables = { onSwipeDown: OnSwipeDownCallback; }; -export type {CanvasSize, ContentSize, ZoomRange, OnScaleChangedCallback, OnTapCallback, MultiGestureCanvasVariables}; +export type {CanvasSize, ContentSize, ZoomRange, OnScaleChangedCallback, OnTapCallback, MultiGestureCanvasVariables, OnSwipeDownCallback}; From 25418abc7c6a5d25847336fc4f54eee20490d854 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Wed, 21 Feb 2024 18:26:26 +0100 Subject: [PATCH 15/27] fix: post merge fix (2) --- src/components/Lightbox/index.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/Lightbox/index.tsx b/src/components/Lightbox/index.tsx index 36cb175e3c45..69fa0d5e6e41 100644 --- a/src/components/Lightbox/index.tsx +++ b/src/components/Lightbox/index.tsx @@ -59,6 +59,7 @@ function Lightbox({isAuthTokenRequired = false, uri, onScaleChanged: onScaleChan activePage, onTap, onScaleChanged: onScaleChangedContext, + onSwipeDown, pagerRef, } = useMemo(() => { if (attachmentCarouselPagerContext === null) { @@ -70,6 +71,7 @@ function Lightbox({isAuthTokenRequired = false, uri, onScaleChanged: onScaleChan activePage: 0, onTap: () => {}, onScaleChanged: () => {}, + onSwipeDown: () => {}, pagerRef: undefined, }; } @@ -212,6 +214,7 @@ function Lightbox({isAuthTokenRequired = false, uri, onScaleChanged: onScaleChan shouldDisableTransformationGestures={isPagerScrolling} onTap={onTap} onScaleChanged={scaleChange} + onSwipeDown={onSwipeDown} > Date: Wed, 21 Feb 2024 18:55:01 +0100 Subject: [PATCH 16/27] fix: don't close if swipe down occurs when image zoomed in --- src/components/MultiGestureCanvas/usePanGesture.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MultiGestureCanvas/usePanGesture.ts b/src/components/MultiGestureCanvas/usePanGesture.ts index 04de6bd1912a..8075b089410e 100644 --- a/src/components/MultiGestureCanvas/usePanGesture.ts +++ b/src/components/MultiGestureCanvas/usePanGesture.ts @@ -135,7 +135,7 @@ const usePanGesture = ({ const finalTranslateY = offsetY.value + panVelocityY.value * 0.2; // TODO: calculate these values (250/500) programmatically - if (finalTranslateY > 250) { + if (finalTranslateY > 250 && zoomScale.value <= 1) { offsetY.value = withSpring(500, SPRING_CONFIG, () => { isSwipingDownToClose.value = false; }); From 20f51ca271a566727a61a40774837fb11468f75e Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Wed, 21 Feb 2024 19:45:50 +0100 Subject: [PATCH 17/27] fix: calculate snap points based on screen size --- src/components/MultiGestureCanvas/usePanGesture.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/MultiGestureCanvas/usePanGesture.ts b/src/components/MultiGestureCanvas/usePanGesture.ts index 8075b089410e..298d62ee6b9d 100644 --- a/src/components/MultiGestureCanvas/usePanGesture.ts +++ b/src/components/MultiGestureCanvas/usePanGesture.ts @@ -1,4 +1,5 @@ /* eslint-disable no-param-reassign */ +import {Dimensions} from 'react-native'; import type {PanGesture} from 'react-native-gesture-handler'; import {Gesture} from 'react-native-gesture-handler'; import {runOnJS, useDerivedValue, useSharedValue, useWorkletCallback, withDecay, withSpring} from 'react-native-reanimated'; @@ -10,6 +11,9 @@ import * as MultiGestureCanvasUtils from './utils'; // We're using a "withDecay" animation to smoothly phase out the pan animation // https://docs.swmansion.com/react-native-reanimated/docs/animations/withDecay/ const PAN_DECAY_DECELARATION = 0.9915; +const SCREEN_HEIGHT = Dimensions.get('screen').height; +const SNAP_POINT = SCREEN_HEIGHT / 4; +const SNAP_POINT_HIDDEN = SCREEN_HEIGHT / 1.2; type UsePanGestureProps = Pick< MultiGestureCanvasVariables, @@ -134,9 +138,8 @@ const usePanGesture = ({ } else { const finalTranslateY = offsetY.value + panVelocityY.value * 0.2; - // TODO: calculate these values (250/500) programmatically - if (finalTranslateY > 250 && zoomScale.value <= 1) { - offsetY.value = withSpring(500, SPRING_CONFIG, () => { + if (finalTranslateY > SNAP_POINT && zoomScale.value <= 1) { + offsetY.value = withSpring(SNAP_POINT_HIDDEN, SPRING_CONFIG, () => { isSwipingDownToClose.value = false; }); From ca612f4eafca811600ddefd2857fd0c50cf8e97d Mon Sep 17 00:00:00 2001 From: Ben Limpich Date: Wed, 21 Feb 2024 14:15:01 -0800 Subject: [PATCH 18/27] get rid of unnecessary check --- src/pages/DetailsPage.tsx | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/pages/DetailsPage.tsx b/src/pages/DetailsPage.tsx index d4438d3141bf..a9adb5310e58 100755 --- a/src/pages/DetailsPage.tsx +++ b/src/pages/DetailsPage.tsx @@ -64,22 +64,13 @@ function DetailsPage({personalDetails, route, session}: DetailsPageProps) { let details = Object.values(personalDetails ?? {}).find((personalDetail) => personalDetail?.login === login.toLowerCase()); if (!details) { - if (login === CONST.EMAIL.CONCIERGE) { - details = { - accountID: CONST.ACCOUNT_ID.CONCIERGE, - login, - displayName: 'Concierge', - avatar: UserUtils.getDefaultAvatar(CONST.ACCOUNT_ID.CONCIERGE), - }; - } else { - const optimisticAccountID = UserUtils.generateAccountID(login); - details = { - accountID: optimisticAccountID, - login, - displayName: login, - avatar: UserUtils.getDefaultAvatar(optimisticAccountID), - }; - } + const optimisticAccountID = UserUtils.generateAccountID(login); + details = { + accountID: optimisticAccountID, + login, + displayName: login, + avatar: UserUtils.getDefaultAvatar(optimisticAccountID), + }; } const isSMSLogin = details.login ? Str.isSMSLogin(details.login) : false; From 12834bb7898186f59549aaa6189e2bf66a3fe820 Mon Sep 17 00:00:00 2001 From: Ben Limpich Date: Wed, 21 Feb 2024 14:19:44 -0800 Subject: [PATCH 19/27] fix bad merge conflict resolution --- src/libs/ReportUtils.ts | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a493c51eaa52..b0e2513a3018 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1618,25 +1618,6 @@ function getPersonalDetailsForAccountID(accountID: number): Partial>>>>>> main return ( allPersonalDetails?.[accountID] ?? { avatar: UserUtils.getDefaultAvatar(accountID), From 0220afc1bbf8937c9c5fccb095137b145d55426c Mon Sep 17 00:00:00 2001 From: Antony Kithinzi Date: Thu, 22 Feb 2024 08:54:40 +0100 Subject: [PATCH 20/27] revert --- src/libs/ReportActionsUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 026db9dbf8d1..3773c16d52bb 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -700,8 +700,8 @@ function getAllReportActions(reportID: string): ReportActions { function isReportActionAttachment(reportAction: OnyxEntry): boolean { const message = reportAction?.message?.[0]; - if (reportAction && (reportAction.attachmentInfo ?? reportAction.isAttachment)) { - return true; + if (reportAction && ('isAttachment' in reportAction || 'attachmentInfo' in reportAction)) { + return reportAction.isAttachment ?? reportAction.attachmentInfo ?? false; } if (message) { From 9eea6eb87a77b62425a6f87f32d82845f2972075 Mon Sep 17 00:00:00 2001 From: Antony Kithinzi Date: Thu, 22 Feb 2024 08:56:48 +0100 Subject: [PATCH 21/27] typecheck checks --- src/libs/ReportActionsUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index c0470b0f445d..4285450b1aea 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -701,7 +701,7 @@ function isReportActionAttachment(reportAction: OnyxEntry): boolea const message = reportAction?.message?.[0]; if (reportAction && ('isAttachment' in reportAction || 'attachmentInfo' in reportAction)) { - return reportAction.isAttachment ?? reportAction.attachmentInfo ?? false; + return Boolean(reportAction.isAttachment ?? reportAction.attachmentInfo ?? false); } if (message) { From 035a5d6ce40700184543d18b4069f2c311948e24 Mon Sep 17 00:00:00 2001 From: Antony Kithinzi Date: Thu, 22 Feb 2024 09:50:07 +0100 Subject: [PATCH 22/27] imporving condition --- src/libs/ReportActionsUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 4285450b1aea..e03441c7baca 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -701,7 +701,7 @@ function isReportActionAttachment(reportAction: OnyxEntry): boolea const message = reportAction?.message?.[0]; if (reportAction && ('isAttachment' in reportAction || 'attachmentInfo' in reportAction)) { - return Boolean(reportAction.isAttachment ?? reportAction.attachmentInfo ?? false); + return reportAction.isAttachment ?? !!reportAction.attachmentInfo ?? false; } if (message) { From 4acae04331f13fd495dd385add9362f7a4245cf1 Mon Sep 17 00:00:00 2001 From: Antony Kithinzi Date: Thu, 22 Feb 2024 10:42:16 +0100 Subject: [PATCH 23/27] check reportAction?.attachmentInfo if reportAction?.isAttachment is null or undefined --- src/libs/ReportActionsUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index e03441c7baca..7b1a9ff13634 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -701,7 +701,7 @@ function isReportActionAttachment(reportAction: OnyxEntry): boolea const message = reportAction?.message?.[0]; if (reportAction && ('isAttachment' in reportAction || 'attachmentInfo' in reportAction)) { - return reportAction.isAttachment ?? !!reportAction.attachmentInfo ?? false; + return reportAction?.isAttachment ?? !!reportAction?.attachmentInfo ?? false; } if (message) { From 44efead61ab65abdf57edb3286552b5f4be4dc55 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Thu, 22 Feb 2024 13:41:10 +0100 Subject: [PATCH 24/27] fix: CI checks --- .../Attachments/AttachmentCarousel/Pager/index.tsx | 7 +++++-- src/components/MultiGestureCanvas/index.tsx | 2 +- src/components/MultiGestureCanvas/types.ts | 2 +- src/components/MultiGestureCanvas/usePanGesture.ts | 4 +++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/Attachments/AttachmentCarousel/Pager/index.tsx b/src/components/Attachments/AttachmentCarousel/Pager/index.tsx index fd5e177400e4..33d9f20b5e57 100644 --- a/src/components/Attachments/AttachmentCarousel/Pager/index.tsx +++ b/src/components/Attachments/AttachmentCarousel/Pager/index.tsx @@ -42,12 +42,15 @@ type AttachmentCarouselPagerProps = { * @param showArrows If set, it will show/hide the arrows. If not set, it will toggle the arrows. */ onRequestToggleArrows: (showArrows?: boolean) => void; - + /** A callback that is called when swipe-down-to-close gesture happens */ onClose: () => void; }; -function AttachmentCarouselPager({items, activeSource, initialPage, onPageSelected, onRequestToggleArrows, onClose}: AttachmentCarouselPagerProps, ref: ForwardedRef) { +function AttachmentCarouselPager( + {items, activeSource, initialPage, onPageSelected, onRequestToggleArrows, onClose}: AttachmentCarouselPagerProps, + ref: ForwardedRef, +) { const styles = useThemeStyles(); const pagerRef = useRef(null); diff --git a/src/components/MultiGestureCanvas/index.tsx b/src/components/MultiGestureCanvas/index.tsx index 940e71adb54f..9430ac9f2a19 100644 --- a/src/components/MultiGestureCanvas/index.tsx +++ b/src/components/MultiGestureCanvas/index.tsx @@ -10,7 +10,7 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import type ChildrenProps from '@src/types/utils/ChildrenProps'; import {DEFAULT_ZOOM_RANGE, SPRING_CONFIG, ZOOM_RANGE_BOUNCE_FACTORS} from './constants'; -import type {CanvasSize, ContentSize, OnScaleChangedCallback, OnTapCallback, ZoomRange, OnSwipeDownCallback} from './types'; +import type {CanvasSize, ContentSize, OnScaleChangedCallback, OnSwipeDownCallback, OnTapCallback, ZoomRange} from './types'; import usePanGesture from './usePanGesture'; import usePinchGesture from './usePinchGesture'; import useTapGestures from './useTapGestures'; diff --git a/src/components/MultiGestureCanvas/types.ts b/src/components/MultiGestureCanvas/types.ts index ceb29a0333b4..fbb2f3deb88c 100644 --- a/src/components/MultiGestureCanvas/types.ts +++ b/src/components/MultiGestureCanvas/types.ts @@ -49,7 +49,7 @@ type MultiGestureCanvasVariables = { reset: (animated: boolean, callback: () => void) => void; onTap: OnTapCallback | undefined; onScaleChanged: OnScaleChangedCallback | undefined; - onSwipeDown: OnSwipeDownCallback; + onSwipeDown: OnSwipeDownCallback | undefined; }; export type {CanvasSize, ContentSize, ZoomRange, OnScaleChangedCallback, OnTapCallback, MultiGestureCanvasVariables, OnSwipeDownCallback}; diff --git a/src/components/MultiGestureCanvas/usePanGesture.ts b/src/components/MultiGestureCanvas/usePanGesture.ts index 298d62ee6b9d..97843e118871 100644 --- a/src/components/MultiGestureCanvas/usePanGesture.ts +++ b/src/components/MultiGestureCanvas/usePanGesture.ts @@ -143,7 +143,9 @@ const usePanGesture = ({ isSwipingDownToClose.value = false; }); - runOnJS(onSwipeDown)(); + if (onSwipeDown) { + runOnJS(onSwipeDown)(); + } } else { // Animated back to the boundary offsetY.value = withSpring(clampedOffset.y, SPRING_CONFIG, () => { From 3784fd952645c368189de9f82769c7ed567e7d55 Mon Sep 17 00:00:00 2001 From: rory Date: Sun, 25 Feb 2024 09:04:51 -0800 Subject: [PATCH 25/27] Fix onImageSelected type --- src/components/AvatarWithImagePicker.tsx | 3 ++- src/pages/workspace/WorkspaceProfilePage.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/AvatarWithImagePicker.tsx b/src/components/AvatarWithImagePicker.tsx index 07c535ccd96c..1dd71408799e 100644 --- a/src/components/AvatarWithImagePicker.tsx +++ b/src/components/AvatarWithImagePicker.tsx @@ -6,6 +6,7 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import * as Browser from '@libs/Browser'; +import type {CustomRNImageManipulatorResult} from '@libs/cropOrRotateImage/types'; import * as FileUtils from '@libs/fileDownload/FileUtils'; import getImageResolution from '@libs/fileDownload/getImageResolution'; import type {AvatarSource} from '@libs/UserUtils'; @@ -54,7 +55,7 @@ type AvatarWithImagePickerProps = { disabledStyle?: StyleProp; /** Executed once an image has been selected */ - onImageSelected?: () => void; + onImageSelected?: (file: File | CustomRNImageManipulatorResult) => void; /** Execute when the user taps "remove" */ onImageRemoved?: () => void; diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx index 4ce5822dfaa0..2f41d0bbd3b9 100644 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -102,7 +102,7 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi fallbackIcon={Expensicons.FallbackWorkspaceAvatar} style={[styles.mb3, isSmallScreenWidth ? styles.mtn17 : styles.mtn20, styles.alignItemsStart, styles.sectionMenuItemTopDescription]} isUsingDefaultAvatar={!policy?.avatar ?? null} - onImageSelected={(file: File) => Policy.updateWorkspaceAvatar(policy?.id ?? '', file)} + onImageSelected={(file) => Policy.updateWorkspaceAvatar(policy?.id ?? '', file as File)} onImageRemoved={() => Policy.deleteWorkspaceAvatar(policy?.id ?? '')} editorMaskImage={Expensicons.ImageCropSquareMask} pendingAction={policy?.pendingFields?.avatar ?? null} From 44fe4276ef2fbd155595ddc7db73aac85aba0c49 Mon Sep 17 00:00:00 2001 From: rory Date: Sun, 25 Feb 2024 09:11:45 -0800 Subject: [PATCH 26/27] Fix pendingFields and errors --- src/components/AvatarWithImagePicker.tsx | 2 +- src/pages/workspace/WorkspaceProfilePage.tsx | 11 +++++------ src/types/onyx/Policy.ts | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/AvatarWithImagePicker.tsx b/src/components/AvatarWithImagePicker.tsx index 1dd71408799e..fa8a6d71516f 100644 --- a/src/components/AvatarWithImagePicker.tsx +++ b/src/components/AvatarWithImagePicker.tsx @@ -88,7 +88,7 @@ type AvatarWithImagePickerProps = { pendingAction?: OnyxCommon.PendingAction; /** The errors to display */ - errors?: OnyxCommon.Errors; + errors?: OnyxCommon.Errors | null; /** Title for avatar preview modal */ headerTitle?: string; diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx index 2f41d0bbd3b9..48dfe10a2a0e 100644 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -26,7 +26,6 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {CurrencyList} from '@src/types/onyx'; -import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import withPolicy from './withPolicy'; import type {WithPolicyProps} from './withPolicy'; @@ -105,8 +104,8 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi onImageSelected={(file) => Policy.updateWorkspaceAvatar(policy?.id ?? '', file as File)} onImageRemoved={() => Policy.deleteWorkspaceAvatar(policy?.id ?? '')} editorMaskImage={Expensicons.ImageCropSquareMask} - pendingAction={policy?.pendingFields?.avatar ?? null} - errors={policy?.errorFields?.avatar ?? null} + pendingAction={policy?.pendingFields?.avatar} + errors={policy?.errorFields?.avatar} onErrorClose={() => Policy.clearAvatarErrors(policy?.id ?? '')} previewSource={UserUtils.getFullSizeAvatar(policy?.avatar ?? '')} headerTitle={translate('workspace.common.workspaceAvatar')} @@ -115,7 +114,7 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi disabledStyle={styles.cursorDefault} errorRowStyles={undefined} /> - + {(!StringUtils.isEmptyString(policy?.description ?? '') || !readOnly) && ( - + )} - + ; + pendingFields?: Record; /** Original file name which is used for the policy avatar */ originalFileName?: string; From 1ceaddfd8a1a0fe0611982e9b72783436414e36d Mon Sep 17 00:00:00 2001 From: rory Date: Sun, 25 Feb 2024 09:21:09 -0800 Subject: [PATCH 27/27] Fix lint --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index d1cb3e066d99..fc1ed1d19560 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -20,7 +20,6 @@ import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSection import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import type SCREENS from '@src/SCREENS'; -import type {PendingAction} from '@src/types/onyx/OnyxCommon'; import ToggleSettingOptionRow from './ToggleSettingsOptionRow'; import type {ToggleSettingOptionRowProps} from './ToggleSettingsOptionRow'; @@ -60,7 +59,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { /> ), isActive: policy?.harvesting?.enabled ?? false, - pendingAction: policy?.pendingFields?.isAutoApprovalEnabled as PendingAction, + pendingAction: policy?.pendingFields?.isAutoApprovalEnabled, }, { icon: Illustrations.Approval, @@ -83,7 +82,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { /> ), isActive: policy?.isAutoApprovalEnabled ?? false, - pendingAction: policy?.pendingFields?.approvalMode as PendingAction, + pendingAction: policy?.pendingFields?.approvalMode, }, { icon: Illustrations.WalletAlt,