Skip to content

Commit

Permalink
move isLoadingPrivateNotes key to reportMetadata_
Browse files Browse the repository at this point in the history
  • Loading branch information
TMisiukiewicz committed Nov 18, 2024
1 parent d5e7a5a commit 2ff38ff
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 15 deletions.
1 change: 0 additions & 1 deletion src/libs/DebugUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ const REPORT_BOOLEAN_PROPERTIES: Array<keyof Report> = [
'isWaitingOnBankAccount',
'isCancelledIOU',
'isHidden',
'isLoadingPrivateNotes',
] satisfies Array<keyof Report>;

const REPORT_DATE_PROPERTIES: Array<keyof Report> = ['lastVisibleActionCreated', 'lastReadTime', 'lastMentionedTime', 'lastVisibleActionLastModified'] satisfies Array<keyof Report>;
Expand Down
6 changes: 3 additions & 3 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3440,7 +3440,7 @@ function getReportPrivateNote(reportID: string | undefined) {
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`,
value: {
isLoadingPrivateNotes: true,
},
Expand All @@ -3450,7 +3450,7 @@ function getReportPrivateNote(reportID: string | undefined) {
const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`,
value: {
isLoadingPrivateNotes: false,
},
Expand All @@ -3460,7 +3460,7 @@ function getReportPrivateNote(reportID: string | undefined) {
const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`,
value: {
isLoadingPrivateNotes: false,
},
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const CASES = {

type CaseID = ValueOf<typeof CASES>;

function ReportDetailsPage({policies, report, route}: ReportDetailsPageProps) {
function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDetailsPageProps) {
const {translate} = useLocalize();
const {isOffline} = useNetwork();
const styles = useThemeStyles();
Expand Down Expand Up @@ -183,7 +183,7 @@ function ReportDetailsPage({policies, report, route}: ReportDetailsPageProps) {
// 1. HeaderView
return CASES.DEFAULT;
}, [isInvoiceReport, isMoneyRequestReport, isSingleTransactionView]);
const isPrivateNotesFetchTriggered = report?.isLoadingPrivateNotes !== undefined;
const isPrivateNotesFetchTriggered = reportMetadata?.isLoadingPrivateNotes !== undefined;

const requestParentReportAction = useMemo(() => {
// 2. MoneyReport case
Expand Down
6 changes: 3 additions & 3 deletions src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ export default function (pageTitle: TranslationPaths) {
const {translate} = useLocalize();
const {isOffline} = useNetwork();
const [session] = useOnyx(ONYXKEYS.SESSION);
const {route, report} = props;
const {route, report, reportMetadata} = props;
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`);
const accountID = ('accountID' in route.params && route.params.accountID) || '';
const isPrivateNotesFetchTriggered = report?.isLoadingPrivateNotes !== undefined;
const isPrivateNotesFetchTriggered = reportMetadata?.isLoadingPrivateNotes !== undefined;
const prevIsOffline = usePrevious(isOffline);
const isReconnecting = prevIsOffline && !isOffline;
const isOtherUserNote = !!accountID && Number(session?.accountID) !== Number(accountID);
const isPrivateNotesFetchFinished = isPrivateNotesFetchTriggered && !report.isLoadingPrivateNotes;
const isPrivateNotesFetchFinished = isPrivateNotesFetchTriggered && !reportMetadata.isLoadingPrivateNotes;
const isPrivateNotesUndefined = accountID ? report?.privateNotes?.[Number(accountID)]?.note === undefined : isEmptyObject(report?.privateNotes);

useEffect(() => {
Expand Down
2 changes: 0 additions & 2 deletions src/types/form/DebugReportForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const INPUT_IDS = {
HAS_OUTSTANDING_CHILD_REQUEST: 'hasOutstandingChildRequest',
HAS_OUTSTANDING_CHILD_TASK: 'hasOutstandingChildTask',
IS_CANCELLED_IOU: 'isCancelledIOU',
IS_LOADING_PRIVATE_NOTES: 'isLoadingPrivateNotes',
IS_OWN_POLICY_EXPENSE_CHAT: 'isOwnPolicyExpenseChat',
IS_PINNED: 'isPinned',
IS_WAITING_ON_BANK_ACCOUNT: 'isWaitingOnBankAccount',
Expand Down Expand Up @@ -60,7 +59,6 @@ type DebugReportForm = Form<
[INPUT_IDS.HAS_OUTSTANDING_CHILD_REQUEST]: boolean;
[INPUT_IDS.HAS_OUTSTANDING_CHILD_TASK]: boolean;
[INPUT_IDS.IS_CANCELLED_IOU]: boolean;
[INPUT_IDS.IS_LOADING_PRIVATE_NOTES]: boolean;
[INPUT_IDS.IS_OWN_POLICY_EXPENSE_CHAT]: boolean;
[INPUT_IDS.IS_PINNED]: boolean;
[INPUT_IDS.IS_WAITING_ON_BANK_ACCOUNT]: boolean;
Expand Down
3 changes: 0 additions & 3 deletions src/types/onyx/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,6 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback<
/** Collection of participant private notes, indexed by their accountID */
privateNotes?: Record<number, Note>;

/** Whether participants private notes are being currently loaded */
isLoadingPrivateNotes?: boolean;

/** Pending members of the report */
pendingChatMembers?: PendingChatMember[];

Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/ReportMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ type ReportMetadata = {

/** The time when user last visited the report */
lastVisitTime?: string;

/** Whether participants private notes are being currently loaded */
isLoadingPrivateNotes?: boolean;
};

export default ReportMetadata;
1 change: 0 additions & 1 deletion src/types/utils/whitelistedReportKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ type WhitelistedReport = OnyxCommon.OnyxValueWithOfflineFeedback<
nonReimbursableTotal: unknown;
isHidden: unknown;
privateNotes: unknown;
isLoadingPrivateNotes: unknown;
pendingChatMembers: unknown;
transactionThreadReportID: unknown;
fieldList: unknown;
Expand Down

0 comments on commit 2ff38ff

Please sign in to comment.