-
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.
Merge pull request #38267 from dukenv0307/fix/37448-incorrect-title-f…
…or-edit-request-message Fix/37448: Incorrect title thread
- Loading branch information
Showing
4 changed files
with
43 additions
and
5 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
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
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,33 @@ | ||
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; | ||
import Onyx from 'react-native-onyx'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type {Report} from '@src/types/onyx'; | ||
import type {EmptyObject} from '@src/types/utils/EmptyObject'; | ||
|
||
let allReports: OnyxCollection<Report>; | ||
Onyx.connect({ | ||
key: ONYXKEYS.COLLECTION.REPORT, | ||
waitForCollectionCallback: true, | ||
callback: (value) => (allReports = value), | ||
}); | ||
|
||
/** | ||
* Get the report given a reportID | ||
*/ | ||
function getReport(reportID: string | undefined): OnyxEntry<Report> | EmptyObject { | ||
if (!allReports) { | ||
return {}; | ||
} | ||
|
||
return allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`] ?? {}; | ||
} | ||
|
||
/** | ||
* Get the report policyID given a reportID. | ||
* We need to define this method in a separate file to avoid cyclic dependency. | ||
*/ | ||
function getReportPolicyID(reportID?: string): string | undefined { | ||
return getReport(reportID)?.policyID; | ||
} | ||
|
||
export default getReportPolicyID; |