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

Bump Onyx to 2.0.41 #42057

Merged
merged 28 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5fda1d1
Fix typings across the project
fabioh8010 Apr 17, 2024
bf0fca1
Merge branch 'main' into feature/useOnyx-undefined-value
fabioh8010 Apr 19, 2024
3500732
Bump TS version to match Onyx's one
fabioh8010 Apr 19, 2024
90b78a6
Typing fixes
fabioh8010 Apr 19, 2024
a097e87
Merge branch 'main' into feature/useOnyx-undefined-value
fabioh8010 Apr 25, 2024
6d3d918
lint fix
fabioh8010 Apr 25, 2024
9b1e2b2
Merge branch 'main' into feature/useOnyx-undefined-value
fabioh8010 May 7, 2024
d64780f
bump onyx
chrispader May 13, 2024
657be97
fix: country not updated in address form
chrispader May 13, 2024
307b300
fix: improve naming and casting of variables
chrispader May 13, 2024
9325262
set strict version
chrispader May 13, 2024
408e0b0
fix: IOUTest types
chrispader May 13, 2024
883e3e1
fix: more type errors
chrispader May 13, 2024
f2d293b
fix: personal details list typings
chrispader May 13, 2024
10e3ab0
update onyx
chrispader May 13, 2024
692c071
fix: more ts errors
chrispader May 13, 2024
d722f27
fix: more ts issues
chrispader May 13, 2024
874dc1d
Merge branch 'main' into @chrispader/bump-onyx-to-2-0-40
chrispader May 13, 2024
6029747
Merge branch 'main' into feature/useOnyx-undefined-value
chrispader May 13, 2024
67ca37e
Merge branch 'feature/useOnyx-undefined-value' into @chrispader/bump-…
chrispader May 13, 2024
f5d18d8
Update src/hooks/useReportIDs.tsx
chrispader May 13, 2024
b92ee2b
Merge branch 'main' into @chrispader/bump-onyx-to-2-0-40
chrispader May 14, 2024
bf80d0a
Merge branch '@chrispader/bump-onyx-to-2-0-40' of github.com:margelo/…
chrispader May 14, 2024
dad7a76
Merge branch 'main' into @chrispader/bump-onyx-to-2-0-40
chrispader May 14, 2024
bcc3f96
revert invalid change
chrispader May 14, 2024
789b646
Merge branch 'main' into @chrispader/bump-onyx-to-2-0-40
chrispader May 17, 2024
b0b7859
fix: remove initWithStoredValues setting from AttachmentModal
chrispader May 20, 2024
e7e73c8
fix: keyboard shortcuts in selection lists
chrispader May 22, 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
15 changes: 8 additions & 7 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 @@ -152,7 +152,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.32",
"react-native-onyx": "2.0.41",
"react-native-pager-view": "6.2.3",
"react-native-pdf": "6.7.3",
"react-native-performance": "^5.1.0",
Expand Down Expand Up @@ -290,7 +290,7 @@
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"type-fest": "^4.10.2",
"typescript": "^5.3.2",
"typescript": "^5.4.5",
"wait-port": "^0.2.9",
"webpack": "^5.76.0",
"webpack-bundle-analyzer": "^4.5.0",
Expand Down
3 changes: 0 additions & 3 deletions src/components/AddressForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ 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 @@ -149,8 +148,6 @@ 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: 0 additions & 1 deletion src/components/AttachmentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,6 @@ 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 {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import type {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, Policy, Report, ReportActions} from '@src/types/onyx';
import type {PersonalDetails, PersonalDetailsList, 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: OnyxCollection<PersonalDetails>;
personalDetails: OnyxEntry<PersonalDetailsList>;
};

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: 3 additions & 2 deletions src/components/KeyboardAvoidingView/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {KeyboardAvoidingViewProps} from 'react-native';
import type {KeyboardAvoidingViewProps} from 'react-native';

export default KeyboardAvoidingViewProps;
// eslint-disable-next-line import/prefer-default-export
export type {KeyboardAvoidingViewProps};
13 changes: 12 additions & 1 deletion src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Log from '@libs/Log';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import arraysEqual from '@src/utils/arraysEqual';
import type {BaseSelectionListProps, ButtonOrCheckBoxRoles, FlattenedSectionsReturn, ListItem, SectionListDataType, SectionWithIndexOffset, SelectionListHandle} from './types';

function BaseSelectionList<TItem extends ListItem>(
Expand Down Expand Up @@ -228,11 +229,21 @@ function BaseSelectionList<TItem extends ListItem>(
[flattenedSections.allOptions],
);

const [disabledIndexes, setDisabledIndexes] = useState(flattenedSections.disabledOptionsIndexes);
useEffect(() => {
if (arraysEqual(disabledIndexes, flattenedSections.disabledOptionsIndexes)) {
return;
}

setDisabledIndexes(flattenedSections.disabledOptionsIndexes);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [flattenedSections.disabledOptionsIndexes]);

// If `initiallyFocusedOptionKey` is not passed, we fall back to `-1`, to avoid showing the highlight on the first member
const [focusedIndex, setFocusedIndex] = useArrowKeyFocusManager({
initialFocusedIndex: flattenedSections.allOptions.findIndex((option) => option.keyForList === initiallyFocusedOptionKey),
maxIndex: Math.min(flattenedSections.allOptions.length - 1, CONST.MAX_SELECTION_LIST_PAGE_LENGTH * currentPage - 1),
disabledIndexes: flattenedSections.disabledOptionsIndexes,
disabledIndexes,
isActive: true,
onFocusedIndexChange: (index: number) => {
scrollToIndex(index, true);
Expand Down
23 changes: 12 additions & 11 deletions src/languages/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
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 @@ -40,15 +41,15 @@ type LocalTimeParams = {
};

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

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

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

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

export type {
AdminCanceledRequestParams,
ApprovedAmountParams,
AddressLineParams,
AdminCanceledRequestParams,
AlreadySignedInParams,
UserSplitParams,
ApprovedAmountParams,
BeginningOfChatHistoryAdminRoomPartOneParams,
BeginningOfChatHistoryAnnounceRoomPartOneParams,
BeginningOfChatHistoryAnnounceRoomPartTwo,
Expand All @@ -324,8 +324,10 @@ export type {
FormattedMaxLengthParams,
GoBackMessageParams,
GoToRoomParams,
HeldRequestParams,
InstantSummaryParams,
LocalTimeParams,
LogSizeParams,
LoggedInAsParams,
ManagerApprovedAmountParams,
ManagerApprovedParams,
Expand All @@ -339,11 +341,13 @@ export type {
PaidElsewhereWithAmountParams,
PaidWithExpensifyWithAmountParams,
ParentNavigationSummaryParams,
PaySomeoneParams,
PayerOwesAmountParams,
PayerOwesParams,
PayerPaidAmountParams,
PayerPaidParams,
PayerSettledParams,
ReimbursementRateParams,
RemovedTheRequestParams,
RenamedRoomActionParams,
ReportArchiveReasonsClosedParams,
Expand Down Expand Up @@ -375,7 +379,9 @@ export type {
UntilTimeParams,
UpdatedTheDistanceParams,
UpdatedTheRequestParams,
UsePlusButtonParams,
UserIsAlreadyMemberParams,
UserSplitParams,
ViolationsAutoReportedRejectedExpenseParams,
ViolationsCashExpenseWithNoReceiptParams,
ViolationsConversionSurchargeParams,
Expand All @@ -392,14 +398,9 @@ 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 @@ -431,7 +431,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: string | number | null): number => {
const getPreferredSkinToneIndex = (value: OnyxEntry<string | number>): number => {
if (value !== null && Number.isInteger(Number(value))) {
return Number(value);
}
Expand Down
21 changes: 11 additions & 10 deletions src/libs/ErrorUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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 @@ -61,7 +62,7 @@ type OnyxDataWithErrors = {
errors?: Errors | null;
};

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

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

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

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

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

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

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

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

if (Object.keys(errorFields).length === 0) {
return {};
Expand Down Expand Up @@ -189,9 +190,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 !== null && policy && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && !!policy.name && !!policy.id,
(policy): policy is Policy => !!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 @@ -166,7 +166,7 @@ function bindEventToChannel<EventName extends PusherEventName>(channel: Channel

let data;
try {
data = isObject(eventData) ? eventData : JSON.parse(eventData);
data = isObject(eventData) ? eventData : JSON.parse(eventData as string);
} 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: ReportActions | null): ReportAction[] {
function filterOutDeprecatedReportActions(reportActions: OnyxEntry<ReportActions>): ReportAction[] {
return Object.entries(reportActions ?? {})
.filter(([key, reportAction]) => !isReportActionDeprecated(reportAction, key))
.map((entry) => entry[1]);
Expand All @@ -656,7 +656,7 @@ function filterOutDeprecatedReportActions(reportActions: ReportActions | null):
* 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: ReportActions | null | ReportAction[], shouldIncludeInvisibleActions = false): ReportAction[] {
function getSortedReportActionsForDisplay(reportActions: OnyxEntry<ReportActions> | ReportAction[], shouldIncludeInvisibleActions = false): ReportAction[] {
let filteredReportActions: ReportAction[] = [];
if (!reportActions) {
return [];
Expand All @@ -680,7 +680,7 @@ function getSortedReportActionsForDisplay(reportActions: ReportActions | null |
* Additionally, archived #admins and #announce do not have the closed report action so we will return null if none is found.
*
*/
function getLastClosedReportAction(reportActions: ReportActions | null): OnyxEntry<ReportAction> {
function getLastClosedReportAction(reportActions: OnyxEntry<ReportActions>): 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): OnyxEntry<ReportAction> {
function getReportAction(reportID: string, reportActionID: string): ReportAction | null {
return allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`]?.[reportActionID] ?? null;
}

Expand Down
Loading
Loading