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

Onyx Bump 2.0.48: null -> undefined changes #20

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
2867f5e
update to Onyx 2.0.43
chrispader May 31, 2024
cb0711e
fix: report related null chnages
chrispader May 31, 2024
1fde464
migrate more tests
chrispader May 31, 2024
903b841
migrate more components
chrispader May 31, 2024
74e120c
migrate more components
chrispader May 31, 2024
e35b748
migrate more files
chrispader May 31, 2024
cfb7b2d
migrate more files
chrispader May 31, 2024
0778946
fix: migrate more files
chrispader May 31, 2024
8c5ff84
fix: tests
chrispader May 31, 2024
d0d896b
Merge branch 'main' into @chrispader/onyx-2-0-43-null-undefined-changes
chrispader May 31, 2024
2bd8bdf
update to onyx 2.0.44
chrispader May 31, 2024
7072973
Merge branch '@chrispader/after-revert-bump-onyx-to-2-0-42' into @chr…
chrispader May 31, 2024
58819b4
Merge branch '@chrispader/after-revert-bump-onyx-to-2-0-42' into @chr…
chrispader Jun 3, 2024
1d4e462
fix: Onyx.connect callback types
chrispader Jun 4, 2024
7b71d22
fix: remaining TS errors
chrispader Jun 4, 2024
475efac
fix: more TS errors
chrispader Jun 4, 2024
8890183
fix: login not working
chrispader Jun 4, 2024
3bc14fe
Merge branch '@chrispader/after-revert-bump-onyx-to-2-0-42' into @chr…
chrispader Jun 5, 2024
cc278f4
fix: login
chrispader Jun 5, 2024
a00b9b0
set credentials to null by default
chrispader Jun 5, 2024
2d26f6d
fix: cannot login issue
chrispader Jun 5, 2024
3bfae91
Merge branch '@chrispader/after-revert-bump-onyx-to-2-0-42' into @chr…
chrispader Jun 5, 2024
923133c
fix: initial network load
chrispader Jun 5, 2024
224ed07
add OnyxInputOrEntry type
chrispader Jun 5, 2024
41824e5
add to index
chrispader Jun 5, 2024
8ba588f
fix: IOU
chrispader Jun 5, 2024
dd7e9dd
fix: remaining IOU issues
chrispader Jun 5, 2024
11c8e94
rename type
chrispader Jun 5, 2024
3105b2e
fix: minor issues
chrispader Jun 5, 2024
e8d60aa
fix: initial hasTriedFocusMode
chrispader Jun 5, 2024
72f1cdd
fix: PushNotification
chrispader Jun 5, 2024
0bde2bf
fix: PersonalDetailsUtils
chrispader Jun 5, 2024
38bf703
fix: User
chrispader Jun 5, 2024
f13c27e
fix: ReportScreen null values
chrispader Jun 5, 2024
a93bafd
fix: ReportActionCompose
chrispader Jun 5, 2024
ad4186a
fix: props
chrispader Jun 5, 2024
3d8e6f6
remove unnecessary null coallescing
chrispader Jun 5, 2024
e6bcbe6
fix: OptionsListUtils
chrispader Jun 5, 2024
57ae961
fix: RemoveEMptyActionDrafts
chrispader Jun 5, 2024
afce282
fix: null values
chrispader Jun 5, 2024
38f0931
fix: FlagCommentPage
chrispader Jun 5, 2024
a90bfa2
fix: lastReportAction
chrispader Jun 5, 2024
7a44c68
fix: BaseReportActionContextMenu
chrispader Jun 5, 2024
263dd3c
fix: MoneyRequestView
chrispader Jun 5, 2024
7afdf8f
ReportUtils
chrispader Jun 5, 2024
007402a
fix: remaining files
chrispader Jun 5, 2024
8ec33e8
fix: remaining TS errors
chrispader Jun 5, 2024
f2bb29c
rename SignInPage components (these were my edits originally)
chrispader Jun 6, 2024
eedb10b
Merge branch '@chrispader/after-revert-bump-onyx-to-2-0-42' into @chr…
chrispader Jun 6, 2024
5ad5b93
fix: imports
chrispader Jun 6, 2024
d3d0e91
Merge branch '@chrispader/after-revert-bump-onyx-to-2-0-42' into @chr…
chrispader Jun 7, 2024
d931437
fix: Member.ts
chrispader Jun 7, 2024
2e70512
update to onyx 2.0.47
chrispader Jun 7, 2024
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
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"react-native-linear-gradient": "^2.8.1",
"react-native-localize": "^2.2.6",
"react-native-modal": "^13.0.0",
"react-native-onyx": "2.0.41",
"react-native-onyx": "2.0.47",
"react-native-pager-view": "6.2.3",
"react-native-pdf": "6.7.3",
"react-native-performance": "^5.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/AvatarWithDisplayName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type AvatarWithDisplayNameProps = AvatarWithDisplayNamePropsWithOnyx & {
report: OnyxEntry<Report>;

/** The policy which the user has access to and which the report is tied to */
policy?: OnyxEntry<Policy>;
policy?: OnyxEntry<Policy> | null;

/** The size of the avatar */
size?: ValueOf<typeof CONST.AVATAR_SIZE>;
Expand Down
2 changes: 1 addition & 1 deletion src/components/HeaderWithBackButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function HeaderWithBackButton({
onCloseButtonPress = () => Navigation.dismissModal(),
onDownloadButtonPress = () => {},
onThreeDotsButtonPress = () => {},
report = null,
report,
policy,
policyAvatar,
shouldShowReportAvatarWithDisplay = false,
Expand Down
2 changes: 1 addition & 1 deletion src/components/HeaderWithBackButton/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type HeaderWithBackButtonProps = Partial<ChildrenProps> & {
report?: OnyxEntry<Report>;

/** The report's policy, if we're showing the details for a report and need info about it for AvatarWithDisplay */
policy?: OnyxEntry<Policy>;
policy?: OnyxEntry<Policy> | null;

/** Single execution function to prevent concurrent navigation actions */
singleExecution?: <T extends unknown[]>(action: Action<T>) => Action<T>;
Expand Down
2 changes: 1 addition & 1 deletion src/components/KYCWall/BaseKYCWall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function KYCWall({

transferBalanceButtonRef.current = targetElement;

const isExpenseReport = ReportUtils.isExpenseReport(iouReport ?? null);
const isExpenseReport = ReportUtils.isExpenseReport(iouReport);
const paymentCardList = fundList ?? {};

// Check to see if user has a valid payment method on file and display the add payment popover if they don't
Expand Down
12 changes: 6 additions & 6 deletions src/components/LHNOptionsList/LHNOptionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ function LHNOptionsList({
*/
const renderItem = useCallback(
({item: reportID}: RenderItemProps): ReactElement => {
const itemFullReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`] ?? null;
const itemReportActions = reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] ?? null;
const itemParentReportActions = reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${itemFullReport?.parentReportID}`] ?? null;
const itemParentReportAction = itemParentReportActions?.[itemFullReport?.parentReportActionID ?? ''] ?? null;
const itemPolicy = policy?.[`${ONYXKEYS.COLLECTION.POLICY}${itemFullReport?.policyID}`] ?? null;
const itemFullReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
const itemReportActions = reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`];
const itemParentReportActions = reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${itemFullReport?.parentReportID}`];
const itemParentReportAction = itemParentReportActions?.[itemFullReport?.parentReportActionID ?? ''];
const itemPolicy = policy?.[`${ONYXKEYS.COLLECTION.POLICY}${itemFullReport?.policyID}`];
const transactionID = itemParentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? itemParentReportAction.originalMessage.IOUTransactionID ?? '' : '';
const itemTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? null;
const itemTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
const hasDraftComment = DraftCommentUtils.isValidDraftComment(draftComments?.[`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`]);
const sortedReportActions = ReportActionsUtils.getSortedReportActionsForDisplay(itemReportActions);
const lastReportAction = sortedReportActions[0];
Expand Down
2 changes: 1 addition & 1 deletion src/components/LHNOptionsList/OptionRowLHN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
const formattedDate = DateUtils.getStatusUntilDate(statusClearAfterDate);
const statusContent = formattedDate ? `${statusText ? `${statusText} ` : ''}(${formattedDate})` : statusText;
const report = ReportUtils.getReport(optionItem.reportID ?? '');
const isStatusVisible = !!emojiCode && ReportUtils.isOneOnOneChat(!isEmptyObject(report) ? report : null);
const isStatusVisible = !!emojiCode && ReportUtils.isOneOnOneChat(!isEmptyObject(report) ? report : undefined);

const isGroupChat = ReportUtils.isGroupChat(optionItem) || ReportUtils.isDeprecatedGroupDM(optionItem);

Expand Down
2 changes: 1 addition & 1 deletion src/components/LHNOptionsList/OptionRowLHNData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function OptionRowLHNData({

const optionItemRef = useRef<OptionData>();

const shouldDisplayViolations = canUseViolations && ReportUtils.shouldDisplayTransactionThreadViolations(fullReport, transactionViolations, parentReportAction ?? null);
const shouldDisplayViolations = canUseViolations && ReportUtils.shouldDisplayTransactionThreadViolations(fullReport, transactionViolations, parentReportAction);

const optionItem = useMemo(() => {
// Note: ideally we'd have this as a dependent selector in onyx!
Expand Down
2 changes: 1 addition & 1 deletion src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type MoneyReportHeaderProps = {
report: OnyxTypes.Report;

/** The policy tied to the expense report */
policy: OnyxEntry<OnyxTypes.Policy>;
policy: OnyxEntry<OnyxTypes.Policy> | null;

/** Array of report actions for the report */
reportActions: OnyxTypes.ReportAction[];
Expand Down
14 changes: 7 additions & 7 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps &
selectedParticipants: Participant[];

/** Payee of the expense with login */
payeePersonalDetails?: OnyxEntry<OnyxTypes.PersonalDetails>;
payeePersonalDetails?: OnyxEntry<OnyxTypes.PersonalDetails> | null;

/** Should the list be read only, and not editable? */
isReadOnly?: boolean;
Expand Down Expand Up @@ -184,7 +184,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps &
type MoneyRequestConfirmationListItem = Participant | ReportUtils.OptionData;

function MoneyRequestConfirmationList({
transaction = null,
transaction,
onSendMoney,
onConfirm,
iouType = CONST.IOU.TYPE.SUBMIT,
Expand Down Expand Up @@ -709,7 +709,7 @@ function MoneyRequestConfirmationList({
if (selectedParticipants.length === 0) {
return;
}
if (!isEditingSplitBill && isMerchantRequired && (isMerchantEmpty || (shouldDisplayFieldError && TransactionUtils.isMerchantMissing(transaction ?? null)))) {
if (!isEditingSplitBill && isMerchantRequired && (isMerchantEmpty || (shouldDisplayFieldError && TransactionUtils.isMerchantMissing(transaction)))) {
setFormError('iou.error.invalidMerchant');
return;
}
Expand Down Expand Up @@ -739,7 +739,7 @@ function MoneyRequestConfirmationList({
return;
}

if (isEditingSplitBill && TransactionUtils.areRequiredFieldsEmpty(transaction ?? null)) {
if (isEditingSplitBill && TransactionUtils.areRequiredFieldsEmpty(transaction)) {
setDidConfirmSplit(true);
setFormError('iou.error.genericSmartscanFailureMessage');
return;
Expand Down Expand Up @@ -861,8 +861,8 @@ function MoneyRequestConfirmationList({
style={[styles.moneyRequestMenuItem, styles.mt2]}
titleStyle={styles.moneyRequestConfirmationAmount}
disabled={didConfirm}
brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction ?? null) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
errorText={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction ?? null) ? translate('common.error.enterAmount') : ''}
brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
errorText={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction) ? translate('common.error.enterAmount') : ''}
/>
),
shouldShow: shouldShowSmartScanFields,
Expand Down Expand Up @@ -1096,7 +1096,7 @@ function MoneyRequestConfirmationList({
isThumbnail,
fileExtension,
isLocalFile,
} = receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction ?? null, receiptPath, receiptFilename) : ({} as ReceiptUtils.ThumbnailAndImageURI);
} = receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction, receiptPath, receiptFilename) : ({} as ReceiptUtils.ThumbnailAndImageURI);

const resolvedThumbnail = isLocalFile ? receiptThumbnail : tryResolveUrlFromApiRoot(receiptThumbnail ?? '');
const resolvedReceiptImage = isLocalFile ? receiptImage : tryResolveUrlFromApiRoot(receiptImage ?? '');
Expand Down
4 changes: 2 additions & 2 deletions src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ type MoneyRequestHeaderProps = {
report: Report;

/** The policy which the report is tied to */
policy: OnyxEntry<Policy>;
policy: OnyxEntry<Policy> | null;

/** The report action the transaction is tied to from the parent report */
parentReportAction: OnyxEntry<ReportAction>;
parentReportAction: OnyxEntry<ReportAction> | null;

/** Whether we should display the header as in narrow layout */
shouldUseNarrowLayout?: boolean;
Expand Down
6 changes: 3 additions & 3 deletions src/components/ShowContextMenuContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ type ShowContextMenuContextProps = {

const ShowContextMenuContext = createContext<ShowContextMenuContextProps>({
anchor: null,
report: null,
action: null,
transactionThreadReport: null,
report: undefined,
action: undefined,
transactionThreadReport: undefined,
checkIfContextMenuActive: () => {},
});

Expand Down
8 changes: 4 additions & 4 deletions src/languages/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {OnyxEntry} from 'react-native-onyx';

Check failure on line 1 in src/languages/types.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

'OnyxEntry' is defined but never used
import type {ReportAction} from '@src/types/onyx';
import type {OnyxInputOrEntry, ReportAction} from '@src/types/onyx';
import type {Unit} from '@src/types/onyx/Policy';
import type en from './en';

Expand Down Expand Up @@ -41,15 +41,15 @@
};

type EditActionParams = {
action: OnyxEntry<ReportAction>;
action: OnyxInputOrEntry<ReportAction>;
};

type DeleteActionParams = {
action: OnyxEntry<ReportAction>;
action: OnyxInputOrEntry<ReportAction>;
};

type DeleteConfirmationParams = {
action: OnyxEntry<ReportAction>;
action: OnyxInputOrEntry<ReportAction>;
};

type BeginningOfChatHistoryDomainRoomPartOneParams = {
Expand Down
14 changes: 7 additions & 7 deletions src/libs/DistanceRequestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {LocaleContextProps} from '@components/LocaleContextProvider';
import type {RateAndUnit} from '@src/CONST';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {LastSelectedDistanceRates, Report} from '@src/types/onyx';
import type {LastSelectedDistanceRates, OnyxInputOrEntry, Report} from '@src/types/onyx';
import type {Unit} from '@src/types/onyx/Policy';
import type Policy from '@src/types/onyx/Policy';
import type {EmptyObject} from '@src/types/utils/EmptyObject';
Expand Down Expand Up @@ -39,7 +39,7 @@ Onyx.connect({
const METERS_TO_KM = 0.001; // 1 kilometer is 1000 meters
const METERS_TO_MILES = 0.000621371; // There are approximately 0.000621371 miles in a meter

function getMileageRates(policy: OnyxEntry<Policy>, includeDisabledRates = false): Record<string, MileageRate> {
function getMileageRates(policy: OnyxInputOrEntry<Policy>, includeDisabledRates = false): Record<string, MileageRate> {
const mileageRates: Record<string, MileageRate> = {};

if (!policy || !policy?.customUnits) {
Expand Down Expand Up @@ -78,14 +78,14 @@ function getMileageRates(policy: OnyxEntry<Policy>, includeDisabledRates = false
* @returns [currency] - The currency associated with the rate.
* @returns [unit] - The unit of measurement for the distance.
*/
function getDefaultMileageRate(policy: OnyxEntry<Policy> | EmptyObject): MileageRate | null {
function getDefaultMileageRate(policy: OnyxInputOrEntry<Policy> | EmptyObject): MileageRate | undefined {
if (isEmptyObject(policy) || !policy?.customUnits) {
return null;
return undefined;
}

const distanceUnit = PolicyUtils.getCustomUnit(policy);
if (!distanceUnit?.rates) {
return null;
return;
}
const mileageRates = getMileageRates(policy);

Expand Down Expand Up @@ -252,8 +252,8 @@ function convertToDistanceInMeters(distance: number, unit: Unit): number {
* Returns custom unit rate ID for the distance transaction
*/
function getCustomUnitRateID(reportID: string) {
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`] ?? null;
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`] ?? null;
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`];
const policy = PolicyUtils.getPolicy(report?.policyID ?? parentReport?.policyID ?? '');
let customUnitRateID: string = CONST.CUSTOM_UNITS.FAKE_P2P_ID;

Expand Down
5 changes: 2 additions & 3 deletions src/libs/IOUUtils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type {OnyxEntry} from 'react-native-onyx';
import type {IOUAction, IOUType} from '@src/CONST';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import type {Report, Transaction} from '@src/types/onyx';
import type {OnyxInputOrEntry, Report, Transaction} from '@src/types/onyx';
import type {IOURequestType} from './actions/IOU';
import * as CurrencyUtils from './CurrencyUtils';
import Navigation from './Navigation/Navigation';
Expand Down Expand Up @@ -60,7 +59,7 @@ function calculateAmount(numberOfParticipants: number, total: number, currency:
* @param isDeleting - whether the user is deleting the expense
* @param isUpdating - whether the user is updating the expense
*/
function updateIOUOwnerAndTotal<TReport extends OnyxEntry<Report>>(
function updateIOUOwnerAndTotal<TReport extends OnyxInputOrEntry<Report>>(
iouReport: TReport,
actorAccountID: number,
amount: number,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Onyx.connect({

Onyx.connect({
key: ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT,
callback: (value: OnyxEntry<number>) => {
callback: (value) => {
lastUpdateIDAppliedToClient = value;
},
});
Expand Down
10 changes: 5 additions & 5 deletions src/libs/Network/NetworkStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type Credentials from '@src/types/onyx/Credentials';

let credentials: Credentials | null = null;
let authToken: string | null = null;
let credentials: Credentials | null | undefined;
let authToken: string | null | undefined;
let authTokenType: ValueOf<typeof CONST.AUTH_TOKEN_TYPES> | null;
let currentUserEmail: string | null = null;
let offline = false;
Expand Down Expand Up @@ -62,7 +62,7 @@ Onyx.connect({
Onyx.connect({
key: ONYXKEYS.CREDENTIALS,
callback: (val) => {
credentials = val;
credentials = val ?? null;
checkRequiredData();
},
});
Expand All @@ -86,15 +86,15 @@ Onyx.connect({
});

function getCredentials(): Credentials | null {
return credentials;
return credentials ?? null;
}

function isOffline(): boolean {
return offline;
}

function getAuthToken(): string | null {
return authToken;
return authToken ?? null;
}

function isSupportRequest(command: string): boolean {
Expand Down
Loading
Loading