-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use getNonEmptyStringOnyxID instead of getNonEmptyStringReportID
- Loading branch information
1 parent
590070f
commit ee611e6
Showing
5 changed files
with
14 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import {useMemo} from 'react'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID'; | ||
import PaginationUtils from '@libs/PaginationUtils'; | ||
import * as ReportActionsUtils from '@libs/ReportActionsUtils'; | ||
Check failure on line 5 in src/hooks/usePaginatedReportActions.ts GitHub Actions / Changed files ESLint check
|
||
import * as ReportUtils from '@libs/ReportUtils'; | ||
Check failure on line 6 in src/hooks/usePaginatedReportActions.ts GitHub Actions / Changed files ESLint check
|
||
|
@@ -9,7 +10,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; | |
* Get the longest continuous chunk of reportActions including the linked reportAction. If not linking to a specific action, returns the continuous chunk of newest reportActions. | ||
*/ | ||
function usePaginatedReportActions(reportID?: string, reportActionID?: string) { | ||
const nonEmptyStringReportID = ReportUtils.getNonEmptyStringReportID(reportID); | ||
const nonEmptyStringReportID = getNonEmptyStringOnyxID(reportID); | ||
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${nonEmptyStringReportID}`); | ||
const canUserPerformWriteAction = ReportUtils.canUserPerformWriteAction(report); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** Make sure the id is not an empty string as it can break an onyx key */ | ||
export default function getNonEmptyStringOnyxID(onyxID: string | undefined): string | undefined { | ||
// The onyx ID is used inside the onyx key. If it's an empty string, onyx will return | ||
// a collection instead of an individual item, which is not an expected behaviour. | ||
return onyxID !== '' ? onyxID : undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ import usePolicy from '@hooks/usePolicy'; | |
import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
import useTheme from '@hooks/useTheme'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import * as OptionsListUtils from '@libs/OptionsListUtils'; | ||
Check failure on line 30 in src/pages/home/HeaderView.tsx GitHub Actions / Changed files ESLint check
|
||
import Parser from '@libs/Parser'; | ||
|
@@ -71,9 +72,7 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto | |
const route = useRoute(); | ||
const [isDeleteTaskConfirmModalVisible, setIsDeleteTaskConfirmModalVisible] = React.useState(false); | ||
const [invoiceReceiverPolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.invoiceReceiver && 'policyID' in report.invoiceReceiver ? report.invoiceReceiver.policyID : undefined}`); | ||
const [parentReport] = useOnyx( | ||
`${ONYXKEYS.COLLECTION.REPORT}${ReportUtils.getNonEmptyStringReportID(report?.parentReportID) ?? ReportUtils.getNonEmptyStringReportID(report?.reportID)}`, | ||
); | ||
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(report?.parentReportID) ?? getNonEmptyStringOnyxID(report?.reportID)}`); | ||
const policy = usePolicy(report?.policyID); | ||
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters