Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e048aff
Remove default OnyxKey type argument in Response
OlGierd03 Feb 3, 2026
f16351f
Merge branch '@OlGierd03/replace_default_union_OnyxUpdate_type_fifth_…
OlGierd03 Feb 3, 2026
d7b6fdb
Make functions generic to migrate away from OnyxKey default union type
OlGierd03 Feb 3, 2026
1e3a348
Merge branch 'main' into @OlGierd03/replace_default_union_OnyxUpdate_…
OlGierd03 Feb 4, 2026
1098d42
Replace default OnyxUpdate type
OlGierd03 Feb 4, 2026
98160f6
Replace default OnyxUpdate type
OlGierd03 Feb 4, 2026
173fb28
Replace default OnyxUpdate type - IOU/index.ts
OlGierd03 Feb 4, 2026
f22a3a3
Replace default OnyxUpdate type - IOU/index.ts, IOU/Duplicate.ts
OlGierd03 Feb 4, 2026
55b5905
Replace default OnyxUpdate type
OlGierd03 Feb 4, 2026
d474d2b
Replace default OnyxUpdate type - MergeTransaction.ts
OlGierd03 Feb 4, 2026
e9db068
Replace default OnyxUpdate type
OlGierd03 Feb 4, 2026
a3dd2dc
Replace default OnyxUpdate type
OlGierd03 Feb 4, 2026
386f89b
Replace default OnyxUpdate type
OlGierd03 Feb 4, 2026
d63c5f0
Replace default OnyxUpdate type
OlGierd03 Feb 4, 2026
d48e66e
Remove default OnyxKey type argument in generic functions and types
OlGierd03 Feb 5, 2026
19c0fdc
Create AnyOnyxUpdatesFromServer type to get rid of OnyxKey default union
OlGierd03 Feb 6, 2026
1226fd4
Merge branch 'main' into @OlGierd03/replace_default_union_OnyxUpdate_…
OlGierd03 Feb 9, 2026
516280b
Merge 'main' branch
OlGierd03 Feb 10, 2026
afe6cc9
Replace default OnyxUpdate type - new usages from merged main
OlGierd03 Feb 10, 2026
83cd069
Merge 'main' branch and resolve conflicts
OlGierd03 Feb 12, 2026
fb92345
Provide Onyx keys explicitly to simplify code
OlGierd03 Feb 12, 2026
ff6bb33
Remove OnyxUpdate assertions in updatePolicyIdForReportAndThreads
OlGierd03 Feb 12, 2026
30d7d69
Create OnyxUpdatesFromServerBase to make code dry
OlGierd03 Feb 12, 2026
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
6 changes: 3 additions & 3 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type {OnyxUpdate} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import type CONST from './CONST';
import type {OnboardingAccounting} from './CONST';
Expand All @@ -9,6 +8,7 @@ import type * as FormTypes from './types/form';
import type * as OnyxTypes from './types/onyx';
import type {Attendee, DistanceExpenseType, Participant} from './types/onyx/IOU';
import type Onboarding from './types/onyx/Onboarding';
import type {AnyOnyxUpdate} from './types/onyx/Request';
import type AssertTypesEqual from './types/utils/AssertTypesEqual';
import type DeepValueOf from './types/utils/DeepValueOf';

Expand Down Expand Up @@ -1267,7 +1267,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.NVP_MUTED_PLATFORMS]: Partial<Record<Platform, true>>;
[ONYXKEYS.NVP_PRIORITY_MODE]: ValueOf<typeof CONST.PRIORITY_MODE>;
[ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE]: OnyxTypes.BlockedFromConcierge;
[ONYXKEYS.QUEUE_FLUSHED_DATA]: OnyxUpdate[];
[ONYXKEYS.QUEUE_FLUSHED_DATA]: AnyOnyxUpdate[];

// The value of this nvp is a string representation of the date when the block expires, or an empty string if the user is not blocked
[ONYXKEYS.NVP_BLOCKED_FROM_CHAT]: string;
Expand Down Expand Up @@ -1333,7 +1333,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.VERIFY_3DS_SUBSCRIPTION]: string;
[ONYXKEYS.PREFERRED_THEME]: ValueOf<typeof CONST.THEME>;
[ONYXKEYS.MAPBOX_ACCESS_TOKEN]: OnyxTypes.MapboxAccessToken;
[ONYXKEYS.ONYX_UPDATES_FROM_SERVER]: OnyxTypes.OnyxUpdatesFromServer;
[ONYXKEYS.ONYX_UPDATES_FROM_SERVER]: OnyxTypes.AnyOnyxUpdatesFromServer;
[ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT]: number;
[ONYXKEYS.MAX_CANVAS_AREA]: number;
[ONYXKEYS.MAX_CANVAS_HEIGHT]: number;
Expand Down
6 changes: 3 additions & 3 deletions src/libs/API/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ function processRequest<TKey extends OnyxKey>(request: OnyxRequest<TKey>, type:
* All calls to API.write() will be persisted to disk as JSON with the params, successData, and failureData (or finallyData, if included in place of the former two values).
* This is so that if the network is unavailable or the app is closed, we can send the WRITE request later.
*/
function write<TCommand extends WriteCommand>(command: TCommand, apiCommandParameters: ApiRequestCommandParameters[TCommand]): Promise<void | Response>;
function write<TCommand extends WriteCommand>(command: TCommand, apiCommandParameters: ApiRequestCommandParameters[TCommand]): Promise<void | Response<never>>;

function write<TCommand extends WriteCommand, TKey extends OnyxKey>(
command: TCommand,
apiCommandParameters: ApiRequestCommandParameters[TCommand],
onyxData: OnyxData<TKey>,
onyxData?: OnyxData<TKey>,
conflictResolver?: RequestConflictResolver<TKey>,
): Promise<void | Response<TKey>>;

Expand Down Expand Up @@ -255,7 +255,7 @@ function paginate<TRequestType extends typeof CONST.API_REQUEST_TYPE.MAKE_REQUES
apiCommandParameters: ApiRequestCommandParameters[TCommand],
onyxData: OnyxData<TKey>,
config: PaginationConfig,
): Promise<Response | void>;
): Promise<Response<TKey> | void>;
function paginate<TRequestType extends typeof CONST.API_REQUEST_TYPE.READ, TCommand extends CommandOfType<TRequestType>, TKey extends OnyxKey>(
type: TRequestType,
command: TCommand,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Authentication.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Sentry from '@sentry/react-native';
import Onyx from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import type {OnyxEntry, OnyxKey} from 'react-native-onyx';
import CONFIG from '@src/CONFIG';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -56,7 +56,7 @@ Onyx.connectWithoutView({
},
});

function Authenticate(parameters: Parameters): Promise<Response | void> {
function Authenticate<TKey extends OnyxKey>(parameters: Parameters): Promise<Response<TKey> | void> {
const commandName = 'Authenticate';

try {
Expand Down
4 changes: 2 additions & 2 deletions src/libs/ErrorUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import mapValues from 'lodash/mapValues';
import type {OnyxEntry} from 'react-native-onyx';
import type {OnyxEntry, OnyxKey} from 'react-native-onyx';
import CONST from '@src/CONST';
import IntlStore from '@src/languages/IntlStore';
import type {TranslationPaths} from '@src/languages/types';
Expand All @@ -11,7 +11,7 @@ import DateUtils from './DateUtils';
// eslint-disable-next-line @typescript-eslint/no-deprecated
import {translate, translateLocal} from './Localize';

function getAuthenticateErrorMessage(response: Response): TranslationPaths {
function getAuthenticateErrorMessage<TKey extends OnyxKey>(response: Response<TKey>): TranslationPaths {
switch (response.jsonCode) {
case CONST.JSON_CODE.UNABLE_TO_RETRY:
return 'session.offlineMessageRetry';
Expand Down
3 changes: 2 additions & 1 deletion src/libs/Network/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type {OnyxKey} from 'react-native-onyx';
import * as ActiveClientManager from '@libs/ActiveClientManager';
import CONST from '@src/CONST';
import type {Request} from '@src/types/onyx';
Expand Down Expand Up @@ -31,7 +32,7 @@ function clearProcessQueueInterval() {
/**
* Perform a queued post request
*/
function post(command: string, data: Record<string, unknown> = {}, type = CONST.NETWORK.METHOD.POST, shouldUseSecure = false): Promise<Response> {
function post<TKey extends OnyxKey>(command: string, data: Record<string, unknown> = {}, type = CONST.NETWORK.METHOD.POST, shouldUseSecure = false): Promise<Response<TKey>> {
return new Promise((resolve, reject) => {
const request: Request<never> = {
command,
Expand Down
27 changes: 17 additions & 10 deletions src/libs/Notification/PushNotification/NotificationType.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {OnyxKey} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import type {OnyxServerUpdate} from '@src/types/onyx/OnyxUpdatesFromServer';
import type {AnyOnyxServerUpdate, OnyxServerUpdate} from '@src/types/onyx/OnyxUpdatesFromServer';

const NotificationType = {
REPORT_ACTION: 'reportAction',
Expand All @@ -10,29 +11,35 @@ const NotificationType = {
type NotificationTypes = ValueOf<typeof NotificationType>;

type NotificationDataMap = {
[NotificationType.REPORT_ACTION]: ReportActionPushNotificationData;
[NotificationType.REPORT_COMMENT]: ReportActionPushNotificationData;
[NotificationType.TRANSACTION]: TransactionPushNotificationData;
[NotificationType.REPORT_ACTION]: AnyPushNotificationData;
[NotificationType.REPORT_COMMENT]: AnyPushNotificationData;
[NotificationType.TRANSACTION]: AnyPushNotificationData;
};

type PushNotificationData = ReportActionPushNotificationData | TransactionPushNotificationData;
/**
* This type was created as a solution during the migration away from the large OnyxKey union and is useful for contexts where the specific Onyx keys are not known ahead of time.
* It should only be used in legacy code where providing exact key types would require major restructuring.
*/
type AnyPushNotificationData = ReportActionPushNotificationData<AnyOnyxServerUpdate> | TransactionPushNotificationData<AnyOnyxServerUpdate>;

type PushNotificationData<TKey extends OnyxKey> = ReportActionPushNotificationData<OnyxServerUpdate<TKey>> | TransactionPushNotificationData<OnyxServerUpdate<TKey>>;

type BasePushNotificationData = {
type BasePushNotificationData<TUpdate extends AnyOnyxServerUpdate> = {
title: string;
subtitle: string;
type: ValueOf<typeof NotificationType>;
onyxData?: OnyxServerUpdate[];
onyxData?: TUpdate[];
lastUpdateID?: number;
previousUpdateID?: number;
hasPendingOnyxUpdates?: boolean;
};

type ReportActionPushNotificationData = BasePushNotificationData & {
type ReportActionPushNotificationData<TUpdate extends AnyOnyxServerUpdate> = BasePushNotificationData<TUpdate> & {
reportID: number;
reportActionID: string;
};

type TransactionPushNotificationData = BasePushNotificationData & {
type TransactionPushNotificationData<TUpdate extends AnyOnyxServerUpdate> = BasePushNotificationData<TUpdate> & {
reportID: number;
transactionID: number;
};
Expand All @@ -42,4 +49,4 @@ type TransactionPushNotificationData = BasePushNotificationData & {
* types of push notifications sent by our API.
*/
export default NotificationType;
export type {NotificationTypes, NotificationDataMap, PushNotificationData, ReportActionPushNotificationData, TransactionPushNotificationData};
export type {NotificationTypes, NotificationDataMap, PushNotificationData, AnyPushNotificationData, ReportActionPushNotificationData, TransactionPushNotificationData};
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import type {JsonObject, JsonValue} from '@ua/react-native-airship';
import pako from 'pako';
import Log from '@libs/Log';
import type {PushNotificationData} from './NotificationType';
import type {AnyPushNotificationData} from './NotificationType';

const GZIP_MAGIC_NUMBER = '\x1f\x8b';

/**
* Parse the payload of a push notification. On Android, some notification payloads are sent as a JSON string rather than an object
*/
export default function parsePushNotificationPayload(payload: JsonValue | undefined): PushNotificationData | undefined {
export default function parsePushNotificationPayload(payload: JsonValue | undefined): AnyPushNotificationData | undefined {
if (payload === undefined) {
return undefined;
}

// No need to parse if it's already an object
if (typeof payload !== 'string') {
return payload as PushNotificationData;
return payload as AnyPushNotificationData;
}

// Gzipped JSON String
Expand All @@ -27,14 +27,14 @@ export default function parsePushNotificationPayload(payload: JsonValue | undefi
const compressed = Uint8Array.from(binaryStringPayload, (x) => x.charCodeAt(0));
const decompressed = pako.inflate(compressed, {to: 'string'});
const jsonObject = JSON.parse(decompressed) as JsonObject;
return jsonObject as PushNotificationData;
return jsonObject as AnyPushNotificationData;
} catch {
Log.hmmm('[PushNotification] Failed to parse the payload as a Gzipped JSON string', payload);
}

// JSON String
try {
return JSON.parse(payload) as JsonObject as PushNotificationData;
return JSON.parse(payload) as JsonObject as AnyPushNotificationData;
} catch {
Log.hmmm(`[PushNotification] Failed to parse the payload as a JSON string`, payload);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {NativeModules} from 'react-native';
import type {OnyxKey} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import applyOnyxUpdatesReliably from '@libs/actions/applyOnyxUpdatesReliably';
import Log from '@libs/Log';
Expand All @@ -12,7 +13,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {OnyxUpdatesFromServer} from '@src/types/onyx';
import PushNotification from '.';
import type {PushNotificationData} from './NotificationType';
import type {AnyPushNotificationData, PushNotificationData} from './NotificationType';

/**
* Manage push notification subscriptions on sign-in/sign-out.
Expand Down Expand Up @@ -53,7 +54,7 @@ Onyx.connectWithoutView({
},
});

function applyOnyxData({reportID, onyxData, lastUpdateID, previousUpdateID, hasPendingOnyxUpdates = false}: PushNotificationData): Promise<void> {
function applyOnyxData<TKey extends OnyxKey>({reportID, onyxData, lastUpdateID, previousUpdateID, hasPendingOnyxUpdates = false}: PushNotificationData<TKey>): Promise<void> {
Log.info(`[PushNotification] Applying onyx data in the ${Visibility.isVisible() ? 'foreground' : 'background'}`, false, {reportID, lastUpdateID});

const logMissingOnyxDataInfo = (isDataMissing: boolean): boolean => {
Expand All @@ -66,7 +67,7 @@ function applyOnyxData({reportID, onyxData, lastUpdateID, previousUpdateID, hasP
return true;
};

let updates: OnyxUpdatesFromServer;
let updates: OnyxUpdatesFromServer<TKey>;
if (hasPendingOnyxUpdates) {
const isDataMissing = !lastUpdateID;
logMissingOnyxDataInfo(isDataMissing);
Expand Down Expand Up @@ -110,7 +111,7 @@ function applyOnyxData({reportID, onyxData, lastUpdateID, previousUpdateID, hasP
.then(() => NativeModules.PushNotificationBridge?.finishBackgroundProcessing());
}

function navigateToReport({reportID}: PushNotificationData): Promise<void> {
function navigateToReport({reportID}: AnyPushNotificationData): Promise<void> {
Log.info('[PushNotification] Navigating to report', false, {reportID});

Navigation.waitForProtectedRoutes().then(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Pusher/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type PusherClass from 'pusher-js/with-encryption';
import type {Channel, ChannelAuthorizerGenerator} from 'pusher-js/with-encryption';
import type {LiteralUnion, ValueOf} from 'type-fest';
import type CONST from '@src/CONST';
import type {OnyxUpdatesFromServer, ReportUserIsTyping} from '@src/types/onyx';
import type {AnyOnyxUpdatesFromServer, ReportUserIsTyping} from '@src/types/onyx';
import type DeepValueOf from '@src/types/utils/DeepValueOf';
import type TYPE from './EventType';

Expand Down Expand Up @@ -41,7 +41,7 @@ type PusherEventMap = {

type EventData<EventName extends string> = {chunk?: string; id?: string; index?: number; final?: boolean} & (EventName extends keyof PusherEventMap
? PusherEventMap[EventName]
: OnyxUpdatesFromServer);
: AnyOnyxUpdatesFromServer);

type EventCallbackError = {type?: ValueOf<typeof CONST.ERROR>; data: {code?: number; message?: string}};

Expand Down
9 changes: 4 additions & 5 deletions src/libs/PusherUtils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type {OnyxKey} from 'react-native-onyx';
import CONFIG from '@src/CONFIG';
import CONST from '@src/CONST';
import type {OnyxUpdatesFromServer} from '@src/types/onyx';
import type {OnyxServerUpdate} from '@src/types/onyx/OnyxUpdatesFromServer';
import type {AnyOnyxUpdatesFromServer, OnyxServerUpdate} from '@src/types/onyx/OnyxUpdatesFromServer';
import Log from './Log';
import NetworkConnection from './NetworkConnection';
import Pusher from './Pusher';
Expand Down Expand Up @@ -35,18 +34,18 @@ function triggerMultiEventHandler<TKey extends OnyxKey>(eventType: string, data:
/**
* Abstraction around subscribing to private user channel events. Handles all logs and errors automatically.
*/
function subscribeToPrivateUserChannelEvent(eventName: string, accountID: string, onEvent: (pushJSON: OnyxUpdatesFromServer | PingPongEvent) => void) {
function subscribeToPrivateUserChannelEvent(eventName: string, accountID: string, onEvent: (pushJSON: AnyOnyxUpdatesFromServer | PingPongEvent) => void) {
const pusherChannelName = getUserChannelName(accountID);

function logPusherEvent(pushJSON: OnyxUpdatesFromServer | PingPongEvent) {
function logPusherEvent(pushJSON: AnyOnyxUpdatesFromServer | PingPongEvent) {
Log.info(`[Report] Handled ${eventName} event sent by Pusher`, false, pushJSON);
}

function onPusherResubscribeToPrivateUserChannel() {
NetworkConnection.triggerReconnectionCallbacks('Pusher re-subscribed to private user channel');
}

function onEventPush(pushJSON: OnyxUpdatesFromServer | PingPongEvent) {
function onEventPush(pushJSON: AnyOnyxUpdatesFromServer | PingPongEvent) {
logPusherEvent(pushJSON);
onEvent(pushJSON);
}
Expand Down
4 changes: 2 additions & 2 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import {fastMerge, Str} from 'expensify-common';
import clone from 'lodash/clone';
import isEmpty from 'lodash/isEmpty';
import type {NullishDeep, OnyxCollection, OnyxEntry, OnyxUpdate} from 'react-native-onyx';
import type {NullishDeep, OnyxCollection, OnyxEntry, OnyxKey, OnyxUpdate} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleContextProvider';
Expand Down Expand Up @@ -77,7 +77,7 @@
}

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 80 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand All @@ -89,7 +89,7 @@
});

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 92 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -98,13 +98,13 @@
});

let isNetworkOffline = false;
Onyx.connect({

Check warning on line 101 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NETWORK,
callback: (val) => (isNetworkOffline = val?.isOffline ?? false),
});

let deprecatedCurrentUserAccountID: number | undefined;
Onyx.connect({

Check warning on line 107 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, value is undefined
Expand Down Expand Up @@ -1396,7 +1396,7 @@
/**
* @returns The latest report action in the `onyxData` or `null` if one couldn't be found
*/
function getLatestReportActionFromOnyxData(onyxData: OnyxUpdate[] | null): NonNullable<OnyxEntry<ReportAction>> | null {
function getLatestReportActionFromOnyxData<TKey extends OnyxKey>(onyxData: Array<OnyxUpdate<TKey>> | null): NonNullable<OnyxEntry<ReportAction>> | null {
const reportActionUpdate = onyxData?.find((onyxUpdate) => onyxUpdate.key.startsWith(ONYXKEYS.COLLECTION.REPORT_ACTIONS));

if (!reportActionUpdate) {
Expand Down
7 changes: 6 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@
};

let conciergeReportIDOnyxConnect: OnyxEntry<string>;
Onyx.connect({

Check warning on line 1015 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.CONCIERGE_REPORT_ID,
callback: (value) => {
conciergeReportIDOnyxConnect = value;
Expand All @@ -1020,7 +1020,7 @@
});

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({

Check warning on line 1023 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, val is undefined
Expand All @@ -1038,7 +1038,7 @@
let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
let allPersonalDetailLogins: string[];
let currentUserPersonalDetails: OnyxEntry<PersonalDetails>;
Onyx.connect({

Check warning on line 1041 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
if (currentUserAccountID) {
Expand All @@ -1050,7 +1050,7 @@
});

let allReportsDraft: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 1053 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_DRAFT,
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
Expand All @@ -1059,7 +1059,7 @@
let allPolicies: OnyxCollection<Policy>;
let hasPolicies: boolean;
let policiesArray: Policy[] = [];
Onyx.connect({

Check warning on line 1062 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1070,7 +1070,7 @@
});

let allPolicyDrafts: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 1073 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY_DRAFTS,
waitForCollectionCallback: true,
callback: (value) => (allPolicyDrafts = value),
Expand Down Expand Up @@ -10764,7 +10764,11 @@
* @param lastVisibleActionCreated Last visible action created of the child report
* @param type The type of action in the child report
*/
function getOptimisticDataForParentReportAction(report: Report | undefined, lastVisibleActionCreated: string, type: string): Array<OnyxUpdate | null> {
function getOptimisticDataForParentReportAction(
report: Report | undefined,
lastVisibleActionCreated: string,
type: string,
): Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS> | null> {
if (!report || isEmptyObject(report)) {
return [];
}
Expand Down Expand Up @@ -13256,4 +13260,5 @@
PrepareOnboardingOnyxDataParams,
SelfDMParameters,
OptimisticReportAction,
OptimisticAnnounceChat,
};
15 changes: 10 additions & 5 deletions src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ function getPolicyParamsForOpenOrReconnect(): Promise<PolicyParamsForOpenOrRecon
});
}

type OnyxDataForOpenOrReconnectKeys =
| typeof ONYXKEYS.COLLECTION.REPORT
| typeof ONYXKEYS.IS_LOADING_REPORT_DATA
| typeof ONYXKEYS.HAS_LOADED_APP
| typeof ONYXKEYS.IS_LOADING_APP
| typeof ONYXKEYS.LAST_FULL_RECONNECT_TIME;

/**
* Returns the Onyx data that is used for both the OpenApp and ReconnectApp API commands.
*/
Expand All @@ -299,9 +306,7 @@ function getOnyxDataForOpenOrReconnect(
isFullReconnect = false,
shouldKeepPublicRooms = false,
allReportsWithDraftComments?: Record<string, string | undefined>,
): OnyxData<
typeof ONYXKEYS.COLLECTION.REPORT | typeof ONYXKEYS.IS_LOADING_REPORT_DATA | typeof ONYXKEYS.HAS_LOADED_APP | typeof ONYXKEYS.IS_LOADING_APP | typeof ONYXKEYS.LAST_FULL_RECONNECT_TIME
> {
): OnyxData<OnyxDataForOpenOrReconnectKeys> {
const result: OnyxData<
| typeof ONYXKEYS.IS_LOADING_REPORT_DATA
| typeof ONYXKEYS.HAS_LOADED_APP
Expand Down Expand Up @@ -494,7 +499,7 @@ function reconnectApp(updateIDFrom: OnyxEntry<number> = 0) {
* because it will follow patterns that are not recommended so we can be sure we're not putting the app in a unusable
* state because of race conditions between reconnectApp and other pusher updates being applied at the same time.
*/
function finalReconnectAppAfterActivatingReliableUpdates(): Promise<void | OnyxTypes.Response> {
function finalReconnectAppAfterActivatingReliableUpdates(): Promise<void | OnyxTypes.Response<OnyxDataForOpenOrReconnectKeys>> {
console.debug(`[OnyxUpdates] Executing last reconnect app with promise`);
return getPolicyParamsForOpenOrReconnect().then((policyParams) => {
const params: ReconnectAppParams = {...policyParams};
Expand All @@ -513,7 +518,7 @@ function finalReconnectAppAfterActivatingReliableUpdates(): Promise<void | OnyxT
* @param [updateIDFrom] the ID of the Onyx update that we want to start fetching from
* @param [updateIDTo] the ID of the Onyx update that we want to fetch up to
*/
function getMissingOnyxUpdates(updateIDFrom = 0, updateIDTo: number | string = 0): Promise<void | OnyxTypes.Response> {
function getMissingOnyxUpdates(updateIDFrom = 0, updateIDTo: number | string = 0): Promise<void | OnyxTypes.Response<OnyxDataForOpenOrReconnectKeys>> {
console.debug(`[OnyxUpdates] Fetching missing updates updateIDFrom: ${updateIDFrom} and updateIDTo: ${updateIDTo}`);

const parameters: GetMissingOnyxMessagesParams = {
Expand Down
Loading
Loading