From 82da9aff085ead893ccfdd4cb8e54f804bc5e638 Mon Sep 17 00:00:00 2001 From: truph01 Date: Mon, 16 Dec 2024 15:10:12 +0700 Subject: [PATCH 1/4] fix: Skeleton is displayed when create offline Room in focus mode and switch --- src/libs/actions/Report.ts | 14 ++++++++++++++ src/pages/home/ReportScreen.tsx | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 7baf66adc5c5..7b2fd6022462 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2354,6 +2354,13 @@ function addPolicyReport(policyReport: ReportUtils.OptimisticChatReport) { key: ONYXKEYS.FORMS.NEW_ROOM_FORM, value: {isLoading: true}, }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${policyReport.reportID}`, + value: { + isOptimisticReport: true, + }, + }, ]; const successData: OnyxUpdate[] = [ { @@ -2386,6 +2393,13 @@ function addPolicyReport(policyReport: ReportUtils.OptimisticChatReport) { key: ONYXKEYS.FORMS.NEW_ROOM_FORM, value: {isLoading: false}, }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${policyReport.reportID}`, + value: { + isOptimisticReport: false, + }, + }, ]; const failureData: OnyxUpdate[] = [ { diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 47315b604f0b..1f3fc4d9bafd 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -384,7 +384,7 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro !isCurrentReportLoadedFromOnyx || // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing (deleteTransactionNavigateBackUrl && ReportUtils.getReportIDFromLink(deleteTransactionNavigateBackUrl) === report?.reportID) || - isLoading; + ((!ReportUtils.isUserCreatedPolicyRoom(report) || !reportMetadata.isOptimisticReport) && isLoading); const isLinkedActionBecomesDeleted = prevIsLinkedActionDeleted !== undefined && !prevIsLinkedActionDeleted && isLinkedActionDeleted; From 259e66c0d9198083a0331444a13d80ab8f252efc Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 17 Dec 2024 11:26:18 +0700 Subject: [PATCH 2/4] fix: set isOptimisticReport to false in failureData --- src/libs/actions/Report.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 7b2fd6022462..ae15db65eb7e 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2416,6 +2416,13 @@ function addPolicyReport(policyReport: ReportUtils.OptimisticChatReport) { key: ONYXKEYS.FORMS.NEW_ROOM_FORM, value: {isLoading: false}, }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${policyReport.reportID}`, + value: { + isOptimisticReport: false, + }, + }, ]; const parameters: AddWorkspaceRoomParams = { From 912c32848bb8cdc3fa5a635af1590ef19dea703e Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 17 Dec 2024 15:30:03 +0700 Subject: [PATCH 3/4] fix: remove duplicate logic --- src/libs/actions/Report.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index ae15db65eb7e..4641323e9d7c 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2393,13 +2393,6 @@ function addPolicyReport(policyReport: ReportUtils.OptimisticChatReport) { key: ONYXKEYS.FORMS.NEW_ROOM_FORM, value: {isLoading: false}, }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${policyReport.reportID}`, - value: { - isOptimisticReport: false, - }, - }, ]; const failureData: OnyxUpdate[] = [ { From 3974cc7b50cbdcc65ee75d389a11dc33cb125131 Mon Sep 17 00:00:00 2001 From: truph01 Date: Mon, 23 Dec 2024 16:56:55 +0700 Subject: [PATCH 4/4] fix: apply the fix to all report type --- src/pages/home/ReportScreen.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 1f3fc4d9bafd..28672a473af3 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -384,7 +384,7 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro !isCurrentReportLoadedFromOnyx || // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing (deleteTransactionNavigateBackUrl && ReportUtils.getReportIDFromLink(deleteTransactionNavigateBackUrl) === report?.reportID) || - ((!ReportUtils.isUserCreatedPolicyRoom(report) || !reportMetadata.isOptimisticReport) && isLoading); + (!reportMetadata.isOptimisticReport && isLoading); const isLinkedActionBecomesDeleted = prevIsLinkedActionDeleted !== undefined && !prevIsLinkedActionDeleted && isLinkedActionDeleted;