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

refactor: move isLoadingPrivateNotes key to reportMetadata_ #52693

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
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
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
Loading