Skip to content
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

fix: group chat avatar disappears after adding other members and creating the group #56597

Merged
merged 1 commit into from
Feb 10, 2025
Merged
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
9 changes: 5 additions & 4 deletions src/pages/NewChatConfirmPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Participant} from '@src/types/onyx/IOU';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';

function navigateBack() {
Navigation.goBack(ROUTES.NEW_CHAT);
Expand All @@ -38,7 +39,7 @@ function NewChatConfirmPage() {
const {translate} = useLocalize();
const styles = useThemeStyles();
const personalData = useCurrentUserPersonalDetails();
const [newGroupDraft] = useOnyx(ONYXKEYS.NEW_GROUP_CHAT_DRAFT);
const [newGroupDraft, newGroupDraftMetaData] = useOnyx(ONYXKEYS.NEW_GROUP_CHAT_DRAFT);
const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);

const selectedOptions = useMemo((): Participant[] => {
Expand Down Expand Up @@ -101,7 +102,7 @@ function NewChatConfirmPage() {
const stashedLocalAvatarImage = newGroupDraft?.avatarUri;

useEffect(() => {
if (!stashedLocalAvatarImage) {
if (!stashedLocalAvatarImage || isLoadingOnyxValue(newGroupDraftMetaData)) {
return;
}

Expand All @@ -118,9 +119,9 @@ function NewChatConfirmPage() {
// To handle this, we re-read the avatar image file from disk whenever the component re-mounts.
readFileAsync(stashedLocalAvatarImage, newGroupDraft?.avatarFileName ?? '', onSuccess, onFailure, newGroupDraft?.avatarFileType ?? '');

// we only need to run this when the component re-mounted
// we only need to run this when the component re-mounted and when the onyx is loaded completely
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor change:

// we only need to run this when the component re-mounted and when onyx is loaded completely

// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, []);
}, [newGroupDraftMetaData]);

return (
<ScreenWrapper testID={NewChatConfirmPage.displayName}>
Expand Down
Loading