Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8451,6 +8451,12 @@ const CONST = {
TRANSACTION_ITEM_ROW: {
ARROW_RIGHT: 'TransactionItemRow-ArrowRight',
},
PDF_VIEW: {
DOCUMENT: 'PDFView-Document',
},
AVATAR_CROP_MODAL: {
ZOOM_SLIDER: 'AvatarCropModal-ZoomSlider',
},
PAYMENT_METHOD_LIST_ITEM: {
CHASE_ACCOUNT_HELP: 'PaymentMethodListItem-ChaseAccountHelp',
},
Expand Down
14 changes: 13 additions & 1 deletion src/components/AvatarCropModal/AvatarCropModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback, useEffect, useState} from 'react';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {InteractionManager, View} from 'react-native';
import type {LayoutChangeEvent} from 'react-native';
import {Gesture, GestureHandlerRootView} from 'react-native-gesture-handler';
Expand All @@ -7,6 +7,7 @@ import ImageSize from 'react-native-image-size';
import {interpolate, useSharedValue} from 'react-native-reanimated';
import {scheduleOnUI} from 'react-native-worklets';
import ActivityIndicator from '@components/ActivityIndicator';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
Comment thread
sosek108 marked this conversation as resolved.
Resolved
import Button from '@components/Button';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import Icon from '@components/Icon';
Expand Down Expand Up @@ -350,6 +351,15 @@ function AvatarCropModal({imageUri = '', imageName = '', imageType = '', onClose
updateImageOffset(newX, newY);
};

const reasonAttributes = useMemo<SkeletonSpanReasonAttributes>(
() => ({
context: 'AvatarCropModal',
isImageInitialized,
isImageContainerInitialized,
}),
[isImageInitialized, isImageContainerInitialized],
);

return (
<Modal
onClose={() => onClose?.()}
Expand Down Expand Up @@ -382,6 +392,7 @@ function AvatarCropModal({imageUri = '', imageName = '', imageType = '', onClose
<ActivityIndicator
style={[styles.flex1]}
size={CONST.ACTIVITY_INDICATOR_SIZE.LARGE}
reasonAttributes={reasonAttributes}
/>
) : (
<>
Expand Down Expand Up @@ -409,6 +420,7 @@ function AvatarCropModal({imageUri = '', imageName = '', imageType = '', onClose
onPressIn={(e) => scheduleOnUI(sliderOnPress, e.nativeEvent.locationX)}
accessibilityLabel="slider"
role={CONST.ROLE.SLIDER}
sentryLabel={CONST.SENTRY_LABEL.AVATAR_CROP_MODAL.ZOOM_SLIDER}
>
<Slider
sliderValue={translateSlider}
Expand Down
27 changes: 25 additions & 2 deletions src/components/HeaderWithBackButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {useMemo} from 'react';
import {Keyboard, StyleSheet, View} from 'react-native';
import type {SvgProps} from 'react-native-svg';
import ActivityIndicator from '@components/ActivityIndicator';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
Comment thread
sosek108 marked this conversation as resolved.
Resolved
import Avatar from '@components/Avatar';
import AvatarWithDisplayName from '@components/AvatarWithDisplayName';
import Header from '@components/Header';
Expand Down Expand Up @@ -83,6 +84,22 @@ function HeaderWithBackButton({
const [isDownloadButtonActive, temporarilyDisableDownloadButton] = useThrottledButtonState();
const {translate} = useLocalize();

const downloadReasonAttributes = useMemo<SkeletonSpanReasonAttributes>(
() => ({
context: 'HeaderWithBackButton.Download',
isDownloading,
}),
[isDownloading],
);

const rotateReasonAttributes = useMemo<SkeletonSpanReasonAttributes>(
() => ({
context: 'HeaderWithBackButton.Rotate',
isRotating,
}),
[isRotating],
);

const middleContent = useMemo(() => {
if (progressBarPercentage) {
return (
Expand Down Expand Up @@ -280,7 +297,10 @@ function HeaderWithBackButton({
</PressableWithoutFeedback>
</Tooltip>
) : (
<ActivityIndicator style={[styles.touchableButtonImage]} />
<ActivityIndicator
style={[styles.touchableButtonImage]}
reasonAttributes={downloadReasonAttributes}
/>
))}
{shouldShowRotateButton &&
(!isRotating ? (
Expand All @@ -299,7 +319,10 @@ function HeaderWithBackButton({
</PressableWithoutFeedback>
</Tooltip>
) : (
<ActivityIndicator style={[styles.touchableButtonImage]} />
<ActivityIndicator
style={[styles.touchableButtonImage]}
reasonAttributes={rotateReasonAttributes}
/>
))}
{shouldShowPinButton && !!report && <PinButton report={report} />}
</View>
Expand Down
14 changes: 14 additions & 0 deletions src/components/Lightbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {LayoutChangeEvent, StyleProp, ViewStyle} from 'react-native';
import {PixelRatio, StyleSheet, View} from 'react-native';
import {useSharedValue} from 'react-native-reanimated';
import ActivityIndicator from '@components/ActivityIndicator';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
Comment thread
sosek108 marked this conversation as resolved.
Resolved
import AttachmentOfflineIndicator from '@components/AttachmentOfflineIndicator';
import {useAttachmentCarouselPagerActions, useAttachmentCarouselPagerState} from '@components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPagerContext';
import type {Attachment} from '@components/Attachments/types';
Expand Down Expand Up @@ -232,6 +233,18 @@ function Lightbox({attachmentID, isAuthTokenRequired = false, uri, onScaleChange
const isALocalFile = isLocalFile(uri);
const shouldShowOfflineIndicator = isOffline && !isLoading && !isALocalFile;

const reasonAttributes = useMemo<SkeletonSpanReasonAttributes>(
() => ({
context: 'Lightbox',
isImageLoaded,
isLoadingPreviousUri: previousUri !== uri,
Comment thread
sosek108 marked this conversation as resolved.
Resolved
isOffline,
isLoading,
isALocalFile,
}),
[isImageLoaded, previousUri, uri, isOffline, isLoading, isALocalFile],
);

return (
<View
style={[StyleSheet.absoluteFill, style]}
Expand Down Expand Up @@ -301,6 +314,7 @@ function Lightbox({attachmentID, isAuthTokenRequired = false, uri, onScaleChange
<ActivityIndicator
size={CONST.ACTIVITY_INDICATOR_SIZE.LARGE}
style={StyleSheet.absoluteFill}
reasonAttributes={reasonAttributes}
/>
)}
{!isImageLoaded && shouldShowOfflineIndicator && <AttachmentOfflineIndicator />}
Expand Down
11 changes: 9 additions & 2 deletions src/components/LoadingIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import type {ActivityIndicatorProps as RNActivityIndicatorProps, StyleProp, ViewStyle} from 'react-native';
import {StyleSheet, View} from 'react-native';
import useThemeStyles from '@hooks/useThemeStyles';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
import CONST from '@src/CONST';
import ActivityIndicator from './ActivityIndicator';

Expand All @@ -13,15 +14,21 @@ type LoadingIndicatorProps = {

/** Size of the icon */
iconSize?: LoadingIndicatorIconSize;

/** Reason attributes for skeleton span telemetry */
reasonAttributes?: SkeletonSpanReasonAttributes;
};

function LoadingIndicator({style, iconSize}: LoadingIndicatorProps) {
function LoadingIndicator({style, iconSize, reasonAttributes}: LoadingIndicatorProps) {
const styles = useThemeStyles();

return (
<View style={[StyleSheet.absoluteFillObject, styles.fullScreenLoading, styles.w100, style]}>
<View style={styles.w100}>
<ActivityIndicator size={iconSize ?? CONST.ACTIVITY_INDICATOR_SIZE.LARGE} />
<ActivityIndicator
size={iconSize ?? CONST.ACTIVITY_INDICATOR_SIZE.LARGE}
reasonAttributes={reasonAttributes}
/>
</View>
</View>
);
Expand Down
5 changes: 4 additions & 1 deletion src/components/PDFThumbnail/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import React, {useState} from 'react';
import {View} from 'react-native';
import Pdf from 'react-native-pdf';
import LoadingIndicator from '@components/LoadingIndicator';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
Comment thread
sosek108 marked this conversation as resolved.
Resolved
import useThemeStyles from '@hooks/useThemeStyles';
import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL';
import PDFThumbnailError from './PDFThumbnailError';
import type PDFThumbnailProps from './types';

const PDF_THUMBNAIL_REASON_ATTRIBUTES: SkeletonSpanReasonAttributes = {context: 'PDFThumbnail'};

function PDFThumbnail({previewSourceURL, style, isAuthTokenRequired = false, enabled = true, fitPolicy = 0, onPassword, onLoadError, onLoadSuccess}: PDFThumbnailProps) {
const styles = useThemeStyles();
const sizeStyles = [styles.w100, styles.h100];
Expand All @@ -19,7 +22,7 @@ function PDFThumbnail({previewSourceURL, style, isAuthTokenRequired = false, ena
<Pdf
fitPolicy={fitPolicy}
trustAllCerts={false}
renderActivityIndicator={() => <LoadingIndicator />}
renderActivityIndicator={() => <LoadingIndicator reasonAttributes={PDF_THUMBNAIL_REASON_ATTRIBUTES} />}
source={{uri: isAuthTokenRequired ? addEncryptedAuthTokenToURL(previewSourceURL) : previewSourceURL}}
singlePage
style={sizeStyles}
Expand Down
21 changes: 19 additions & 2 deletions src/components/PDFView/index.native.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback, useEffect, useState} from 'react';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import type {StyleProp, ViewStyle} from 'react-native';
import {Linking, View} from 'react-native';
import PDF from 'react-native-pdf';
Expand All @@ -13,6 +13,7 @@ import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import {openTravelDotLink} from '@libs/openTravelDotLink';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
import {getRelativeUrl, isTravelLink} from '@libs/TravelUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -54,6 +55,16 @@ function PDFView({onToggleKeyboard, onLoadComplete, fileName, onPress, isFocused

const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});

const reasonAttributes = useMemo<SkeletonSpanReasonAttributes>(
() => ({
context: 'PDFView',
shouldRequestPassword,
isPasswordInvalid,
shouldAttemptPDFLoad,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these are unrelated to why the loading shows

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right.

But in this case we don't have specific prop to tell why the component did render. While adding these I just thought it would add some context, like "User did something and then loading stuck"

}),
[shouldRequestPassword, isPasswordInvalid, shouldAttemptPDFLoad],
);

useEffect(() => {
onToggleKeyboard?.(isKeyboardShown);
});
Expand Down Expand Up @@ -164,7 +175,12 @@ function PDFView({onToggleKeyboard, onLoadComplete, fileName, onPress, isFocused
<PDF
fitPolicy={0}
trustAllCerts={false}
renderActivityIndicator={() => <LoadingIndicator style={loadingIndicatorStyles} />}
renderActivityIndicator={() => (
<LoadingIndicator
style={loadingIndicatorStyles}
reasonAttributes={reasonAttributes}
/>
)}
source={{uri: sourceURL, cache: true, expiration: 864000}}
style={pdfStyles}
onError={handleFailureToLoadPDF}
Expand Down Expand Up @@ -198,6 +214,7 @@ function PDFView({onToggleKeyboard, onLoadComplete, fileName, onPress, isFocused
accessibilityRole={CONST.ROLE.BUTTON}
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
accessibilityLabel={fileName || translate('attachmentView.unknownFilename')}
sentryLabel={CONST.SENTRY_LABEL.PDF_VIEW.DOCUMENT}
>
{renderPDFView()}
</PressableWithoutFeedback>
Expand Down
16 changes: 14 additions & 2 deletions src/components/PlaidCardFeedIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React, {useEffect, useState} from 'react';
import React, {useEffect, useMemo, useState} from 'react';
import {View} from 'react-native';
import type {StyleProp, ViewStyle} from 'react-native';
import {useCompanyCardBankIcons, useCompanyCardFeedIcons} from '@hooks/useCompanyCardIcons';
import useThemeIllustrations from '@hooks/useThemeIllustrations';
import useThemeStyles from '@hooks/useThemeStyles';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
import variables from '@styles/variables';
import ActivityIndicator from './ActivityIndicator';
import Icon from './Icon';
Expand Down Expand Up @@ -40,6 +41,14 @@ function PlaidCardFeedIcon({plaidUrl, style, isLarge, isSmall, useSkeletonLoader
setLoading(true);
}, [plaidUrl]);

const reasonAttributes = useMemo<SkeletonSpanReasonAttributes>(
() => ({
context: 'PlaidCardFeedIcon',
loading,
}),
Comment thread
sosek108 marked this conversation as resolved.
Resolved
[loading],
);

return (
<View style={[style]}>
{isBrokenImage ? (
Expand All @@ -66,7 +75,10 @@ function PlaidCardFeedIcon({plaidUrl, style, isLarge, isSmall, useSkeletonLoader
)}
{loading && !useSkeletonLoader && (
<View style={[styles.justifyContentCenter, {width: iconWidth, height: iconHeight}]}>
<ActivityIndicator size={isSmall ? 10 : 20} />
<ActivityIndicator
size={isSmall ? 10 : 20}
reasonAttributes={reasonAttributes}
/>
</View>
)}
{!loading && (
Expand Down
16 changes: 14 additions & 2 deletions src/components/TransactionItemRow/ReceiptPreview/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React, {useCallback, useEffect, useRef, useState} from 'react';
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
import ReactDOM from 'react-dom';
import type {LayoutChangeEvent} from 'react-native';
import {StyleSheet, View} from 'react-native';
import Animated, {FadeIn, FadeOut} from 'react-native-reanimated';
import ActivityIndicator from '@components/ActivityIndicator';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
import DistanceEReceipt from '@components/DistanceEReceipt';
import EReceiptWithSizeCalculation from '@components/EReceiptWithSizeCalculation';
import type {ImageOnLoadEvent} from '@components/Image/types';
Expand Down Expand Up @@ -93,6 +94,14 @@ function ReceiptPreview({source, hovered, isEReceipt = false, transactionItem}:
setShouldShow(hovered);
}, [hovered, setShouldShow]);

const reasonAttributes = useMemo<SkeletonSpanReasonAttributes>(
() => ({
context: 'ReceiptPreview',
isLoading,
}),
Comment thread
sosek108 marked this conversation as resolved.
Resolved
[isLoading],
);

if (shouldUseNarrowLayout || !debounceShouldShow || !shouldShow || (!source && !isEReceipt && !isDistanceEReceipt && !isPerDiemEReceipt)) {
return null;
}
Expand All @@ -110,7 +119,10 @@ function ReceiptPreview({source, hovered, isEReceipt = false, transactionItem}:
<View style={[styles.w100]}>
{isLoading && (
<View style={[StyleSheet.absoluteFillObject, styles.justifyContentCenter, styles.alignItemsCenter]}>
<ActivityIndicator size={CONST.ACTIVITY_INDICATOR_SIZE.LARGE} />
<ActivityIndicator
size={CONST.ACTIVITY_INDICATOR_SIZE.LARGE}
reasonAttributes={reasonAttributes}
/>
</View>
)}

Expand Down
Loading