Repository navigation
Resolve admins room for task reports in #admins room for call scheduling #86434
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ import {getLatestError} from '@libs/ErrorUtils'; | |
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types'; | ||
| import type {ScheduleCallParamList} from '@libs/Navigation/types'; | ||
| import {isAdminRoom, isTaskReport} from '@libs/ReportUtils'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ROUTES from '@src/ROUTES'; | ||
|
|
@@ -55,17 +56,24 @@ function ScheduleCallPage() { | |
| const [scheduleCallDraft] = useOnyx(`${ONYXKEYS.SCHEDULE_CALL_DRAFT}`); | ||
| const reportID = route.params?.reportID; | ||
|
|
||
| const [adminReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, { | ||
| const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`); | ||
| const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`); | ||
|
|
||
| // Task reports in #admins room have chatType as policyAdmins, | ||
| // So for a task report, we need to send the real #admins room i.e., the parent report. | ||
| const adminsRoomReportID = isTaskReport(report) && parentReport?.reportID && isAdminRoom(parentReport) ? parentReport.reportID : reportID; | ||
|
|
||
| const [adminReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${adminsRoomReportID}`, { | ||
| selector: adminReportNameValuePairsSelector, | ||
| }); | ||
| const calendlySchedule = adminReportNameValuePairs?.calendlySchedule; | ||
|
|
||
| useEffect(() => { | ||
| if (!reportID) { | ||
| if (!adminsRoomReportID) { | ||
| return; | ||
| } | ||
| getGuideCallAvailabilitySchedule(reportID); | ||
| }, [reportID]); | ||
| getGuideCallAvailabilitySchedule(adminsRoomReportID); | ||
| }, [adminsRoomReportID]); | ||
|
|
||
| // Clear selected time when user comes back to the selection screen | ||
| useFocusEffect( | ||
|
|
@@ -76,7 +84,7 @@ function ScheduleCallPage() { | |
|
|
||
| useEffect(() => { | ||
| return () => { | ||
| sendScheduleCallNudge(session?.accountID ?? CONST.DEFAULT_NUMBER_ID, reportID); | ||
| sendScheduleCallNudge(session?.accountID ?? CONST.DEFAULT_NUMBER_ID, adminsRoomReportID); | ||
| }; | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, []); | ||
|
Comment on lines
86
to
90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The cleanup effect is intentionally frozen with Useful? React with 👍 / 👎.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MonilBhavsar is this still relevant?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's an edge case. I would like to leave it as its unless we see real issue. |
||
|
|
@@ -224,7 +232,7 @@ function ScheduleCallPage() { | |
| accountID: timeSlot.guideAccountID, | ||
| email: timeSlot.guideEmail, | ||
| }, | ||
| reportID, | ||
| reportID: adminsRoomReportID, | ||
| }); | ||
| Navigation.navigate(ROUTES.SCHEDULE_CALL_CONFIRMATION.getRoute(reportID)); | ||
| }} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ PERF-11 (docs)
The two new
useOnyxsubscriptions forreportandparentReportsubscribe to entireReportobjects without selectors. Report objects can be large with many fields, but this component only needstypeandparentReportIDfromreport, andchatTypeandreportIDfromparentReport. Any change to unrelated fields on these reports (e.g.,lastVisibleActionCreated,stateNum, etc.) will trigger unnecessary re-renders of this component.Add selectors to narrow the subscriptions to only the fields needed:
This ensures
deepEqualruns on a tiny object (2 fields) rather than the full Report, and the component only re-renders when the fields it actually uses change.Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah this violates functions call for TS error, so going to leave it as it is