Skip to content

Commit

Permalink
Merge pull request #42725 from Expensify/vit-revert42057
Browse files Browse the repository at this point in the history
[CP Staging] Revert "Merge pull request #42057 from margelo/@chrispader/bump-onyx-…

(cherry picked from commit c956751)
  • Loading branch information
Beamanator authored and OSBotify committed May 29, 2024
1 parent 173496f commit 14289e6
Show file tree
Hide file tree
Showing 36 changed files with 105 additions and 120 deletions.
28 changes: 7 additions & 21 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,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.32",
"react-native-pager-view": "6.2.3",
"react-native-pdf": "6.7.3",
"react-native-performance": "^5.1.0",
Expand Down Expand Up @@ -293,7 +293,7 @@
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"type-fest": "^4.10.2",
"typescript": "^5.4.5",
"typescript": "^5.3.2",
"wait-port": "^0.2.9",
"webpack": "^5.76.0",
"webpack-bundle-analyzer": "^4.5.0",
Expand Down
3 changes: 3 additions & 0 deletions src/components/AddressForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as ErrorUtils from '@libs/ErrorUtils';
import type {MaybePhraseKey} from '@libs/Localize';
import Navigation from '@libs/Navigation/Navigation';
import * as ValidationUtils from '@libs/ValidationUtils';
import CONST from '@src/CONST';
import type {Country} from '@src/CONST';
Expand Down Expand Up @@ -148,6 +149,8 @@ function AddressForm({
label={translate('common.addressLine', {lineNumber: 1})}
onValueChange={(data: unknown, key: unknown) => {
onAddressChanged(data, key);
// This enforces the country selector to use the country from address instead of the country from URL
Navigation.setParams({country: undefined});
}}
defaultValue={street1}
renamedInputKeys={{
Expand Down
1 change: 1 addition & 0 deletions src/components/AttachmentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ export default withOnyx<AttachmentModalProps, AttachmentModalOnyxProps>({
const transactionID = parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction?.originalMessage.IOUTransactionID ?? '0' : '0';
return `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`;
},
initWithStoredValues: false,
},
})(memo(AttachmentModal));

Expand Down
6 changes: 3 additions & 3 deletions src/components/AvatarWithDisplayName.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useCallback, useEffect, useRef} from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import useStyleUtils from '@hooks/useStyleUtils';
Expand All @@ -12,7 +12,7 @@ import * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {PersonalDetails, PersonalDetailsList, Policy, Report, ReportActions} from '@src/types/onyx';
import type {PersonalDetails, Policy, Report, ReportActions} from '@src/types/onyx';
import DisplayNames from './DisplayNames';
import MultipleAvatars from './MultipleAvatars';
import ParentNavigationSubtitle from './ParentNavigationSubtitle';
Expand All @@ -25,7 +25,7 @@ type AvatarWithDisplayNamePropsWithOnyx = {
parentReportActions: OnyxEntry<ReportActions>;

/** Personal details of all users */
personalDetails: OnyxEntry<PersonalDetailsList>;
personalDetails: OnyxCollection<PersonalDetails>;
};

type AvatarWithDisplayNameProps = AvatarWithDisplayNamePropsWithOnyx & {
Expand Down
2 changes: 1 addition & 1 deletion src/components/KeyboardAvoidingView/index.ios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import React from 'react';
import {KeyboardAvoidingView as KeyboardAvoidingViewComponent} from 'react-native';
import type {KeyboardAvoidingViewProps} from './types';
import type KeyboardAvoidingViewProps from './types';

function KeyboardAvoidingView(props: KeyboardAvoidingViewProps) {
// eslint-disable-next-line react/jsx-props-no-spreading
Expand Down
2 changes: 1 addition & 1 deletion src/components/KeyboardAvoidingView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import React from 'react';
import {View} from 'react-native';
import type {KeyboardAvoidingViewProps} from './types';
import type KeyboardAvoidingViewProps from './types';

function KeyboardAvoidingView(props: KeyboardAvoidingViewProps) {
const {behavior, contentContainerStyle, enabled, keyboardVerticalOffset, ...rest} = props;
Expand Down
5 changes: 2 additions & 3 deletions src/components/KeyboardAvoidingView/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type {KeyboardAvoidingViewProps} from 'react-native';
import {KeyboardAvoidingViewProps} from 'react-native';

// eslint-disable-next-line import/prefer-default-export
export type {KeyboardAvoidingViewProps};
export default KeyboardAvoidingViewProps;
23 changes: 11 additions & 12 deletions src/languages/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type {OnyxEntry} from 'react-native-onyx';
import type {ReportAction} from '@src/types/onyx';
import type {Unit} from '@src/types/onyx/Policy';
import type en from './en';
Expand Down Expand Up @@ -41,15 +40,15 @@ type LocalTimeParams = {
};

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

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

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

type BeginningOfChatHistoryDomainRoomPartOneParams = {
Expand Down Expand Up @@ -300,10 +299,11 @@ type DistanceRateOperationsParams = {count: number};
type ReimbursementRateParams = {unit: Unit};

export type {
AddressLineParams,
AdminCanceledRequestParams,
AlreadySignedInParams,
ApprovedAmountParams,
AddressLineParams,
AlreadySignedInParams,
UserSplitParams,
BeginningOfChatHistoryAdminRoomPartOneParams,
BeginningOfChatHistoryAnnounceRoomPartOneParams,
BeginningOfChatHistoryAnnounceRoomPartTwo,
Expand All @@ -324,10 +324,8 @@ export type {
FormattedMaxLengthParams,
GoBackMessageParams,
GoToRoomParams,
HeldRequestParams,
InstantSummaryParams,
LocalTimeParams,
LogSizeParams,
LoggedInAsParams,
ManagerApprovedAmountParams,
ManagerApprovedParams,
Expand All @@ -341,13 +339,11 @@ export type {
PaidElsewhereWithAmountParams,
PaidWithExpensifyWithAmountParams,
ParentNavigationSummaryParams,
PaySomeoneParams,
PayerOwesAmountParams,
PayerOwesParams,
PayerPaidAmountParams,
PayerPaidParams,
PayerSettledParams,
ReimbursementRateParams,
RemovedTheRequestParams,
RenamedRoomActionParams,
ReportArchiveReasonsClosedParams,
Expand Down Expand Up @@ -379,9 +375,7 @@ export type {
UntilTimeParams,
UpdatedTheDistanceParams,
UpdatedTheRequestParams,
UsePlusButtonParams,
UserIsAlreadyMemberParams,
UserSplitParams,
ViolationsAutoReportedRejectedExpenseParams,
ViolationsCashExpenseWithNoReceiptParams,
ViolationsConversionSurchargeParams,
Expand All @@ -398,9 +392,14 @@ export type {
ViolationsTaxOutOfPolicyParams,
WaitingOnBankAccountParams,
WalletProgramParams,
UsePlusButtonParams,
WeSentYouMagicSignInLinkParams,
WelcomeEnterMagicCodeParams,
WelcomeNoteParams,
WelcomeToRoomParams,
ZipCodeExampleFormatParams,
LogSizeParams,
HeldRequestParams,
PaySomeoneParams,
ReimbursementRateParams,
};
2 changes: 1 addition & 1 deletion src/libs/EmojiUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ function suggestEmojis(text: string, lang: Locale, limit: number = CONST.AUTO_CO
/**
* Retrieve preferredSkinTone as Number to prevent legacy 'default' String value
*/
const getPreferredSkinToneIndex = (value: OnyxEntry<string | number>): number => {
const getPreferredSkinToneIndex = (value: string | number | null): number => {
if (value !== null && Number.isInteger(Number(value))) {
return Number(value);
}
Expand Down
21 changes: 10 additions & 11 deletions src/libs/ErrorUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import mapValues from 'lodash/mapValues';
import type {OnyxEntry} from 'react-native-onyx';
import CONST from '@src/CONST';
import type {TranslationFlatObject, TranslationPaths} from '@src/languages/types';
import type {ErrorFields, Errors} from '@src/types/onyx/OnyxCommon';
Expand Down Expand Up @@ -62,7 +61,7 @@ type OnyxDataWithErrors = {
errors?: Errors | null;
};

function getLatestErrorMessage<TOnyxData extends OnyxDataWithErrors>(onyxData: OnyxEntry<TOnyxData>): Localize.MaybePhraseKey {
function getLatestErrorMessage<TOnyxData extends OnyxDataWithErrors>(onyxData: TOnyxData | null): Localize.MaybePhraseKey {
const errors = onyxData?.errors ?? {};

if (Object.keys(errors).length === 0) {
Expand All @@ -73,8 +72,8 @@ function getLatestErrorMessage<TOnyxData extends OnyxDataWithErrors>(onyxData: O
return getErrorMessageWithTranslationData(errors[key]);
}

function getLatestErrorMessageField<TOnyxData extends OnyxDataWithErrors>(onyxData: OnyxEntry<TOnyxData>): Errors {
const errors = onyxData?.errors ?? {};
function getLatestErrorMessageField<TOnyxData extends OnyxDataWithErrors>(onyxData: TOnyxData): Errors {
const errors = onyxData.errors ?? {};

if (Object.keys(errors).length === 0) {
return {};
Expand All @@ -89,8 +88,8 @@ type OnyxDataWithErrorFields = {
errorFields?: ErrorFields;
};

function getLatestErrorField<TOnyxData extends OnyxDataWithErrorFields>(onyxData: OnyxEntry<TOnyxData>, fieldName: string): Errors {
const errorsForField = onyxData?.errorFields?.[fieldName] ?? {};
function getLatestErrorField<TOnyxData extends OnyxDataWithErrorFields>(onyxData: TOnyxData, fieldName: string): Errors {
const errorsForField = onyxData.errorFields?.[fieldName] ?? {};

if (Object.keys(errorsForField).length === 0) {
return {};
Expand All @@ -100,8 +99,8 @@ function getLatestErrorField<TOnyxData extends OnyxDataWithErrorFields>(onyxData
return {[key]: getErrorMessageWithTranslationData(errorsForField[key])};
}

function getEarliestErrorField<TOnyxData extends OnyxDataWithErrorFields>(onyxData: OnyxEntry<TOnyxData>, fieldName: string): Errors {
const errorsForField = onyxData?.errorFields?.[fieldName] ?? {};
function getEarliestErrorField<TOnyxData extends OnyxDataWithErrorFields>(onyxData: TOnyxData, fieldName: string): Errors {
const errorsForField = onyxData.errorFields?.[fieldName] ?? {};

if (Object.keys(errorsForField).length === 0) {
return {};
Expand All @@ -114,8 +113,8 @@ function getEarliestErrorField<TOnyxData extends OnyxDataWithErrorFields>(onyxDa
/**
* Method used to get the latest error field for any field
*/
function getLatestErrorFieldForAnyField<TOnyxData extends OnyxDataWithErrorFields>(onyxData: OnyxEntry<TOnyxData>): Errors {
const errorFields = onyxData?.errorFields ?? {};
function getLatestErrorFieldForAnyField<TOnyxData extends OnyxDataWithErrorFields>(onyxData: TOnyxData): Errors {
const errorFields = onyxData.errorFields ?? {};

if (Object.keys(errorFields).length === 0) {
return {};
Expand Down Expand Up @@ -190,9 +189,9 @@ export {
getErrorMessageWithTranslationData,
getErrorsWithTranslationData,
getLatestErrorField,
getLatestErrorFieldForAnyField,
getLatestErrorMessage,
getLatestErrorMessageField,
getLatestErrorFieldForAnyField,
getMicroSecondOnyxError,
getMicroSecondOnyxErrorObject,
isReceiptError,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Onyx.connect({
*/
function getActivePolicies(policies: OnyxCollection<Policy>): Policy[] {
return Object.values(policies ?? {}).filter<Policy>(
(policy): policy is Policy => !!policy && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && !!policy.name && !!policy.id,
(policy): policy is Policy => policy !== null && policy && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && !!policy.name && !!policy.id,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/libs/Pusher/pusher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function bindEventToChannel<EventName extends PusherEventName>(channel: Channel

let data: EventData<EventName>;
try {
data = isObject(eventData) ? eventData : JSON.parse(eventData as string);
data = isObject(eventData) ? eventData : JSON.parse(eventData);
} catch (err) {
Log.alert('[Pusher] Unable to parse single JSON event data from Pusher', {error: err, eventData});
return;
Expand Down
8 changes: 4 additions & 4 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ function getLastVisibleMessage(reportID: string, actionsToMerge: OnyxCollection<
/**
* A helper method to filter out report actions keyed by sequenceNumbers.
*/
function filterOutDeprecatedReportActions(reportActions: OnyxEntry<ReportActions>): ReportAction[] {
function filterOutDeprecatedReportActions(reportActions: ReportActions | null): ReportAction[] {
return Object.entries(reportActions ?? {})
.filter(([key, reportAction]) => !isReportActionDeprecated(reportAction, key))
.map((entry) => entry[1]);
Expand All @@ -656,7 +656,7 @@ function filterOutDeprecatedReportActions(reportActions: OnyxEntry<ReportActions
* to ensure they will always be displayed in the same order (in case multiple actions have the same timestamp).
* This is all handled with getSortedReportActions() which is used by several other methods to keep the code DRY.
*/
function getSortedReportActionsForDisplay(reportActions: OnyxEntry<ReportActions> | ReportAction[], shouldIncludeInvisibleActions = false): ReportAction[] {
function getSortedReportActionsForDisplay(reportActions: ReportActions | null | ReportAction[], shouldIncludeInvisibleActions = false): ReportAction[] {
let filteredReportActions: ReportAction[] = [];
if (!reportActions) {
return [];
Expand All @@ -680,7 +680,7 @@ function getSortedReportActionsForDisplay(reportActions: OnyxEntry<ReportActions
* Additionally, archived #admins and #announce do not have the closed report action so we will return null if none is found.
*
*/
function getLastClosedReportAction(reportActions: OnyxEntry<ReportActions>): OnyxEntry<ReportAction> {
function getLastClosedReportAction(reportActions: ReportActions | null): OnyxEntry<ReportAction> {
// If closed report action is not present, return early
if (!Object.values(reportActions ?? {}).some((action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED)) {
return null;
Expand Down Expand Up @@ -733,7 +733,7 @@ function getLinkedTransactionID(reportActionOrID: string | OnyxEntry<ReportActio
return reportAction.originalMessage?.IOUTransactionID ?? null;
}

function getReportAction(reportID: string, reportActionID: string): ReportAction | null {
function getReportAction(reportID: string, reportActionID: string): OnyxEntry<ReportAction> {
return allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`]?.[reportActionID] ?? null;
}

Expand Down
Loading

0 comments on commit 14289e6

Please sign in to comment.