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
8 changes: 8 additions & 0 deletions src/components/Search/SearchAutocompleteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {getReportOrDraftReport} from '@libs/ReportUtils';
import {buildSearchQueryJSON, buildUserReadableQueryString, getQueryWithoutFilters, shouldHighlight} from '@libs/SearchQueryUtils';
import StringUtils from '@libs/StringUtils';
import {cancelSpan, endSpan, getSpan} from '@libs/telemetry/activeSpans';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {CardFeeds, CardList, PersonalDetailsList, Policy, Report} from '@src/types/onyx';
Expand Down Expand Up @@ -437,12 +438,19 @@ function SearchAutocompleteList({

const isLoading = !isRecentSearchesDataLoaded || !areOptionsInitialized;

const reasonAttributes: SkeletonSpanReasonAttributes = {
context: 'SearchAutocompleteList',
isRecentSearchesDataLoaded,
areOptionsInitialized,
};

if (isLoading) {
return (
<OptionsListSkeletonView
fixedNumItems={4}
shouldStyleAsTable
speed={CONST.TIMING.SKELETON_ANIMATION_SPEED}
reasonAttributes={reasonAttributes}
/>
);
}
Expand Down
15 changes: 14 additions & 1 deletion src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import useScrollEnabled from '@hooks/useScrollEnabled';
import useSingleExecution from '@hooks/useSingleExecution';
import {focusedItemRef} from '@hooks/useSyncFocus/useSyncFocusImplementation';
import useThemeStyles from '@hooks/useThemeStyles';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
import CONST from '@src/CONST';
import getEmptyArray from '@src/types/utils/getEmptyArray';
import Footer from './components/Footer';
Expand Down Expand Up @@ -367,7 +368,19 @@ function BaseSelectionList<TItem extends ListItem>({

const renderListEmptyContent = () => {
if (shouldShowLoadingPlaceholder) {
return customLoadingPlaceholder ?? <OptionsListSkeletonView shouldStyleAsTable={shouldUseUserSkeletonView} />;
const reasonAttributes: SkeletonSpanReasonAttributes = {
context: 'BaseSelectionList',
Copy link
Contributor

Choose a reason for hiding this comment

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

This is generic, but context is supposed to identify where this is rendered. Because this is a shared component, every caller will now emit the same value, so Sentry still won’t identify which actual screen is stuck. Is that expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From one perspective you're right and this is the right way to do it. From the second point of view this would drastically enlarge the PR and at some point half of the application would have to pass this attribute.

I vote for not doing this as the golden mean between readability (we have these params everywhere) and sanity (we don't overwhelm the codebase with params needed only for observability). We can always change this later if we see problem with this exact component. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@youssef-lr would you like to comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think we can keep it as BaseSelectionList

shouldShowLoadingPlaceholder,
shouldUseUserSkeletonView,
};
return (
customLoadingPlaceholder ?? (
<OptionsListSkeletonView
shouldStyleAsTable={shouldUseUserSkeletonView}
reasonAttributes={reasonAttributes}
/>
)
);
}
if (shouldShowListEmptyContent) {
return listEmptyContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import useSingleExecution from '@hooks/useSingleExecution';
import {focusedItemRef} from '@hooks/useSyncFocus/useSyncFocusImplementation';
import useThemeStyles from '@hooks/useThemeStyles';
import Log from '@libs/Log';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
import CONST from '@src/CONST';
import type {FlattenedItem, ListItem, SelectionListWithSectionsProps} from './types';

Expand Down Expand Up @@ -282,7 +283,11 @@ function BaseSelectionListWithSections<TItem extends ListItem>({

const renderListEmptyContent = () => {
if (shouldShowLoadingPlaceholder) {
return <OptionsListSkeletonView />;
const reasonAttributes: SkeletonSpanReasonAttributes = {
context: 'BaseSelectionListWithSections',
shouldShowLoadingPlaceholder,
};
return <OptionsListSkeletonView reasonAttributes={reasonAttributes} />;
}
if (shouldShowListEmptyContent) {
return listEmptyContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {focusedItemRef} from '@hooks/useSyncFocus/useSyncFocusImplementation';
import useThemeStyles from '@hooks/useThemeStyles';
import getSectionsWithIndexOffset from '@libs/getSectionsWithIndexOffset';
import Log from '@libs/Log';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
Expand Down Expand Up @@ -717,11 +718,17 @@ function BaseSelectionListWithSections<TItem extends ListItem>({

const renderListEmptyContent = () => {
if (shouldShowLoadingPlaceholder) {
const reasonAttributes: SkeletonSpanReasonAttributes = {
context: 'BaseSelectionListWithSections',
shouldShowLoadingPlaceholder,
shouldUseUserSkeletonView,
};
return (
<LoadingPlaceholderComponent
fixedNumItems={fixedNumItemsForLoader}
shouldStyleAsTable={shouldUseUserSkeletonView}
speed={loaderSpeed}
reasonAttributes={reasonAttributes}
/>
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/SelectionListWithSections/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {ValueOf} from 'type-fest';
import type {SearchRouterItem} from '@components/Search/SearchAutocompleteList';
import type {SearchColumnType, SearchGroupBy, SearchQueryJSON} from '@components/Search/types';
import type {ForwardedFSClassProps} from '@libs/Fullstory/types';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
import type {BrickRoad} from '@libs/WorkspacesSettingsUtils';
import type UnreportedExpenseListItem from '@pages/UnreportedExpenseListItem';
// eslint-disable-next-line no-restricted-imports
Expand Down Expand Up @@ -811,6 +812,7 @@ type LoadingPlaceholderComponentProps = {
shouldStyleAsTable?: boolean;
fixedNumItems?: number;
speed?: number;
reasonAttributes?: SkeletonSpanReasonAttributes;
};

type SectionWithIndexOffset<TItem extends ListItem> = Section<TItem> & {
Expand Down
14 changes: 12 additions & 2 deletions src/pages/inbox/sidebar/SidebarLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import {setSidebarLoaded} from '@libs/actions/App';
import Navigation from '@libs/Navigation/Navigation';
import {cancelSpan} from '@libs/telemetry/activeSpans';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
import * as ReportActionContextMenu from '@pages/inbox/report/ContextMenu/ReportActionContextMenu';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -76,6 +77,12 @@ function SidebarLinks({insets, optionListItems, priorityMode = CONST.PRIORITY_MO

const viewMode = priorityMode === CONST.PRIORITY_MODE.GSD ? CONST.OPTION_MODE.COMPACT : CONST.OPTION_MODE.DEFAULT;

const sidebarSkeletonReasonAttributes: SkeletonSpanReasonAttributes = {
context: 'SidebarLinks',
isLoadingReportData,
optionListItemsCount: optionListItems?.length,
};

// eslint-disable-next-line react-hooks/exhaustive-deps
const contentContainerStyles = useMemo(() => StyleSheet.flatten([styles.pt2, {paddingBottom: StyleUtils.getSafeAreaMargins(insets).marginBottom}]), [insets]);

Expand All @@ -91,9 +98,12 @@ function SidebarLinks({insets, optionListItems, priorityMode = CONST.PRIORITY_MO
optionMode={viewMode}
onFirstItemRendered={setSidebarLoaded}
/>
{!!isLoadingReportData && optionListItems?.length === 0 && (
{isLoadingReportData && optionListItems?.length === 0 && (
<View style={[StyleSheet.absoluteFillObject, styles.appBG, styles.mt3]}>
<OptionsListSkeletonView shouldAnimate />
<OptionsListSkeletonView
shouldAnimate
reasonAttributes={sidebarSkeletonReasonAttributes}
/>
</View>
)}
</View>
Expand Down
Loading