diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 55956fa08a10a..5284dd99c27a2 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -26,6 +26,7 @@ import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; import type { Beta, + NewGroupChatDraft, OnyxInputOrEntry, PersonalDetails, PersonalDetailsList, @@ -1000,6 +1001,12 @@ Onyx.connect({ callback: (value) => (activePolicyID = value), }); +let newGroupChatDraft: OnyxEntry; +Onyx.connect({ + key: ONYXKEYS.NEW_GROUP_CHAT_DRAFT, + callback: (value) => (newGroupChatDraft = value), +}); + function getCurrentUserAvatar(): AvatarSource | undefined { return currentUserPersonalDetails?.avatar; } @@ -9472,6 +9479,10 @@ function isTestTransactionReport(report: OnyxEntry): boolean { return isSelectedManagerMcTest(persionalDetails?.login); } +function getGroupChatDraft() { + return newGroupChatDraft; +} + export { addDomainToShortMention, completeShortMention, @@ -9824,6 +9835,7 @@ export { populateOptimisticReportFormula, getTitleReportField, getReportFieldsByPolicyID, + getGroupChatDraft, }; export type { diff --git a/src/pages/GroupChatNameEditPage.tsx b/src/pages/GroupChatNameEditPage.tsx index a67f1fd0f3e2f..7ab33a8e38ba1 100644 --- a/src/pages/GroupChatNameEditPage.tsx +++ b/src/pages/GroupChatNameEditPage.tsx @@ -12,7 +12,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {NewChatNavigatorParamList} from '@libs/Navigation/types'; -import {getGroupChatName} from '@libs/ReportUtils'; +import {getGroupChatDraft, getGroupChatName} from '@libs/ReportUtils'; import {setGroupDraft, updateChatName} from '@userActions/Report'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -31,7 +31,7 @@ function GroupChatNameEditPage({report}: GroupChatNameEditPageProps) { // In this case its better to use empty string as the reportID if there is no reportID const reportID = report?.reportID; const isUpdatingExistingReport = !!reportID; - const [groupChatDraft] = useOnyx(ONYXKEYS.NEW_GROUP_CHAT_DRAFT); + const [groupChatDraft] = useOnyx(ONYXKEYS.NEW_GROUP_CHAT_DRAFT, {initialValue: getGroupChatDraft()}); const styles = useThemeStyles(); const {translate} = useLocalize();