Skip to content

Commit

Permalink
remove withOnyx
Browse files Browse the repository at this point in the history
  • Loading branch information
christianwen committed Oct 10, 2024
1 parent a31b2fe commit 2f17492
Showing 1 changed file with 13 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useIsFocused, useNavigation} from '@react-navigation/native';
import lodashDebounce from 'lodash/debounce';
import type {ForwardedRef, MutableRefObject, RefAttributes, RefObject} from 'react';
import type {ForwardedRef, MutableRefObject, RefObject} from 'react';
import React, {forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState} from 'react';
import type {
LayoutChangeEvent,
Expand All @@ -14,7 +14,7 @@ import type {
import {DeviceEventEmitter, findNodeHandle, InteractionManager, NativeModules, View} from 'react-native';
import {useFocusedInputHandler} from 'react-native-keyboard-controller';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import {useAnimatedRef, useSharedValue} from 'react-native-reanimated';
import type {Emoji} from '@assets/emojis/types';
import type {FileObject} from '@components/AttachmentModal';
Expand Down Expand Up @@ -63,19 +63,7 @@ type SyncSelection = {

type NewlyAddedChars = {startIndex: number; endIndex: number; diff: string};

type ComposerWithSuggestionsOnyxProps = {
/** The modal state */
modal: OnyxEntry<OnyxTypes.Modal>;

/** The preferred skin tone of the user */
preferredSkinTone: number;

/** Whether the input is focused */
editFocused: OnyxEntry<boolean>;
};

type ComposerWithSuggestionsProps = ComposerWithSuggestionsOnyxProps &
Partial<ChildrenProps> & {
type ComposerWithSuggestionsProps = Partial<ChildrenProps> & {
/** Report ID */

Check failure on line 67 in src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Delete `····`
reportID: string;

Check failure on line 68 in src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Replace `········` with `····`

Expand Down Expand Up @@ -142,9 +130,6 @@ type ComposerWithSuggestionsProps = ComposerWithSuggestionsOnyxProps &
/** The ref to the next modal will open */
isNextModalWillOpenRef: MutableRefObject<boolean | null>;

/** Whether the edit is focused */
editFocused: boolean;

/** The last report action */
lastReportAction?: OnyxEntry<OnyxTypes.ReportAction>;

Expand Down Expand Up @@ -204,10 +189,6 @@ const willBlurTextInputOnTapOutside = willBlurTextInputOnTapOutsideFunc();
*/
function ComposerWithSuggestions(
{
// Onyx
modal,
preferredSkinTone = CONST.EMOJI_DEFAULT_SKIN_TONE,

// Props: Report
reportID,
includeChronos,
Expand Down Expand Up @@ -241,7 +222,6 @@ function ComposerWithSuggestions(
// Refs
suggestionsRef,
isNextModalWillOpenRef,
editFocused,

// For testing
children,
Expand All @@ -266,6 +246,15 @@ function ComposerWithSuggestions(
}
return draftComment;
});

const [modal] = useOnyx(ONYXKEYS.MODAL);
const [preferredSkinTone] = useOnyx(ONYXKEYS.PREFERRED_EMOJI_SKIN_TONE, {
selector: EmojiUtils.getPreferredSkinToneIndex,
initialValue: CONST.EMOJI_DEFAULT_SKIN_TONE
});

const [editFocused] = useOnyx(ONYXKEYS.INPUT_FOCUSED);

const commentRef = useRef(value);

const lastTextRef = useRef(value);
Expand Down Expand Up @@ -824,17 +813,6 @@ ComposerWithSuggestions.displayName = 'ComposerWithSuggestions';

const ComposerWithSuggestionsWithRef = forwardRef(ComposerWithSuggestions);

export default withOnyx<ComposerWithSuggestionsProps & RefAttributes<ComposerRef>, ComposerWithSuggestionsOnyxProps>({
modal: {
key: ONYXKEYS.MODAL,
},
preferredSkinTone: {
key: ONYXKEYS.PREFERRED_EMOJI_SKIN_TONE,
selector: EmojiUtils.getPreferredSkinToneIndex,
},
editFocused: {
key: ONYXKEYS.INPUT_FOCUSED,
},
})(memo(ComposerWithSuggestionsWithRef));
export default memo(ComposerWithSuggestionsWithRef);

export type {ComposerWithSuggestionsProps, ComposerRef};

0 comments on commit 2f17492

Please sign in to comment.