diff --git a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx index e31c6097501e..d6d0489f7676 100644 --- a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx +++ b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx @@ -1,7 +1,6 @@ import React, {useCallback, useMemo, useState} from 'react'; import {View} from 'react-native'; -import Onyx, {withOnyx} from 'react-native-onyx'; -import type {OnyxEntry} from 'react-native-onyx'; +import Onyx, {useOnyx} from 'react-native-onyx'; import type {SvgProps} from 'react-native-svg'; import ClientSideLoggingToolMenu from '@components/ClientSideLoggingToolMenu'; import ConfirmModal from '@components/ConfirmModal'; @@ -39,14 +38,7 @@ type BaseMenuItem = { action: () => void | Promise; }; -type TroubleshootPageOnyxProps = { - shouldStoreLogs: OnyxEntry; - shouldMaskOnyxState: boolean; -}; - -type TroubleshootPageProps = TroubleshootPageOnyxProps; - -function TroubleshootPage({shouldStoreLogs, shouldMaskOnyxState}: TroubleshootPageProps) { +function TroubleshootPage() { const {translate} = useLocalize(); const styles = useThemeStyles(); const {isProduction} = useEnvironment(); @@ -55,6 +47,9 @@ function TroubleshootPage({shouldStoreLogs, shouldMaskOnyxState}: TroubleshootPa const {shouldUseNarrowLayout} = useResponsiveLayout(); const illustrationStyle = getLightbulbIllustrationStyle(); + const [shouldStoreLogs] = useOnyx(ONYXKEYS.SHOULD_STORE_LOGS); + const [shouldMaskOnyxState = true] = useOnyx(ONYXKEYS.SHOULD_MASK_ONYX_STATE); + const exportOnyxState = useCallback(() => { ExportOnyxState.readFromOnyxDatabase().then((value: Record) => { const dataToShare = ExportOnyxState.maskOnyxState(value, shouldMaskOnyxState); @@ -177,12 +172,4 @@ function TroubleshootPage({shouldStoreLogs, shouldMaskOnyxState}: TroubleshootPa TroubleshootPage.displayName = 'TroubleshootPage'; -export default withOnyx({ - shouldStoreLogs: { - key: ONYXKEYS.SHOULD_STORE_LOGS, - }, - shouldMaskOnyxState: { - key: ONYXKEYS.SHOULD_MASK_ONYX_STATE, - selector: (shouldMaskOnyxState) => shouldMaskOnyxState ?? true, - }, -})(TroubleshootPage); +export default TroubleshootPage; diff --git a/src/pages/workspace/WorkspacesListPage.tsx b/src/pages/workspace/WorkspacesListPage.tsx index 0f944306ea6a..435c62bbe73d 100755 --- a/src/pages/workspace/WorkspacesListPage.tsx +++ b/src/pages/workspace/WorkspacesListPage.tsx @@ -1,7 +1,6 @@ import React, {useCallback, useMemo, useState} from 'react'; import {FlatList, View} from 'react-native'; -import {useOnyx, withOnyx} from 'react-native-onyx'; -import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import Button from '@components/Button'; import ConfirmModal from '@components/ConfirmModal'; @@ -38,7 +37,7 @@ import * as Session from '@userActions/Session'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type {Policy as PolicyType, ReimbursementAccount, Report, Session as SessionType} from '@src/types/onyx'; +import type {Policy as PolicyType} from '@src/types/onyx'; import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import WorkspacesListRow from './WorkspacesListRow'; @@ -67,22 +66,6 @@ type ChatType = { type ChatPolicyType = Record; -type WorkspaceListPageOnyxProps = { - /** The list of this user's policies */ - policies: OnyxCollection; - - /** Bank account attached to free plan */ - reimbursementAccount: OnyxEntry; - - /** All reports shared with the user (coming from Onyx) */ - reports: OnyxCollection; - - /** Session info for the currently logged in user. */ - session: OnyxEntry; -}; - -type WorkspaceListPageProps = WorkspaceListPageOnyxProps; - const workspaceFeatures: FeatureListItem[] = [ { icon: Illustrations.MoneyReceipts, @@ -117,13 +100,17 @@ function dismissWorkspaceError(policyID: string, pendingAction: OnyxCommon.Pendi const stickyHeaderIndices = [0]; -function WorkspacesListPage({policies, reimbursementAccount, reports, session}: WorkspaceListPageProps) { +function WorkspacesListPage() { const theme = useTheme(); const styles = useThemeStyles(); const {translate} = useLocalize(); const {isOffline} = useNetwork(); const {shouldUseNarrowLayout, isMediumScreenWidth} = useResponsiveLayout(); const [allConnectionSyncProgresses] = useOnyx(ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS); + const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY); + const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); + const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT); + const [session] = useOnyx(ONYXKEYS.SESSION); const {activeWorkspaceID, setActiveWorkspaceID} = useActiveWorkspace(); @@ -313,7 +300,7 @@ function WorkspacesListPage({policies, reimbursementAccount, reports, session}: } return Object.values(policies) - .filter((policy): policy is PolicyType => PolicyUtils.shouldShowPolicy(policy, !!isOffline, session?.email)) + .filter((policy): policy is PolicyType => PolicyUtils.shouldShowPolicy(policy, isOffline, session?.email)) .map((policy): WorkspaceItem => { if (policy?.isJoinRequestPending && policy?.policyDetailsForNonMembers) { const policyInfo = Object.values(policy.policyDetailsForNonMembers)[0]; @@ -454,18 +441,4 @@ function WorkspacesListPage({policies, reimbursementAccount, reports, session}: WorkspacesListPage.displayName = 'WorkspacesListPage'; -export default withOnyx({ - policies: { - key: ONYXKEYS.COLLECTION.POLICY, - }, - // @ts-expect-error: ONYXKEYS.REIMBURSEMENT_ACCOUNT is conflicting with ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM - reimbursementAccount: { - key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, - }, - reports: { - key: ONYXKEYS.COLLECTION.REPORT, - }, - session: { - key: ONYXKEYS.SESSION, - }, -})(WorkspacesListPage); +export default WorkspacesListPage;