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
4 changes: 2 additions & 2 deletions __mocks__/react-native-onyx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/* eslint-disable rulesdir/prefer-onyx-connect-in-libs */
import type {ConnectOptions, OnyxKey} from 'react-native-onyx';
import Onyx, {withOnyx} from 'react-native-onyx';
import Onyx, {useOnyx, withOnyx} from 'react-native-onyx';

let connectCallbackDelay = 0;
function addDelayToConnectCallback(delay: number) {
Expand Down Expand Up @@ -40,4 +40,4 @@ const reactNativeOnyxMock: ReactNativeOnyxMock = {
};

export default reactNativeOnyxMock;
export {withOnyx};
export {withOnyx, useOnyx};
63 changes: 0 additions & 63 deletions src/pages/home/sidebar/ProfileAvatarWithIndicator.js

This file was deleted.

37 changes: 37 additions & 0 deletions src/pages/home/sidebar/ProfileAvatarWithIndicator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';
import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import AvatarWithIndicator from '@components/AvatarWithIndicator';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useThemeStyles from '@hooks/useThemeStyles';
import * as UserUtils from '@libs/UserUtils';
import ONYXKEYS from '@src/ONYXKEYS';

type ProfileAvatarWithIndicatorProps = {
/** Whether the avatar is selected */
isSelected?: boolean;
};

function ProfileAvatarWithIndicator({isSelected = false}: ProfileAvatarWithIndicatorProps) {
const styles = useThemeStyles();
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const [isLoadingOnyxValue] = useOnyx(ONYXKEYS.IS_LOADING_APP);
const isLoading = isLoadingOnyxValue ?? true;
Comment on lines +19 to +20
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.

Note: This piece of code mimics the old behavior (withOnyx + default value assigment to isLoading prop).


return (
<OfflineWithFeedback pendingAction={currentUserPersonalDetails.pendingFields?.avatar}>
<View style={[isSelected && styles.selectedAvatarBorder]}>
<AvatarWithIndicator
source={UserUtils.getAvatar(currentUserPersonalDetails.avatar, currentUserPersonalDetails.accountID)}
fallbackIcon={currentUserPersonalDetails.fallbackIcon}
isLoading={isLoading && !currentUserPersonalDetails.avatar}
/>
</View>
</OfflineWithFeedback>
);
}

ProfileAvatarWithIndicator.displayName = 'ProfileAvatarWithIndicator';

export default ProfileAvatarWithIndicator;