Repository navigation
[No QA] Add reasonAttributes to ActivityIndicator in image-loading contexts #82927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0be257b
3ee6ca1
3f9fe17
e0ecf77
7828568
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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'; | ||
|
|
@@ -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'; | ||
|
|
@@ -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, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like these are unrelated to why the loading shows
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
| }); | ||
|
|
@@ -164,7 +175,12 @@ function PDFView({onToggleKeyboard, onLoadComplete, fileName, onPress, isFocused | |
| 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} | ||
|
|
@@ -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> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.