Skip to content

Commit

Permalink
fix: add code test
Browse files Browse the repository at this point in the history
  • Loading branch information
huult committed Aug 11, 2024
1 parent 93dc1c9 commit 14f0fb1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/pages/NewChatPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import isEmpty from 'lodash/isEmpty';
import reject from 'lodash/reject';
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
import {Alert} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import Button from '@components/Button';
import KeyboardAvoidingView from '@components/KeyboardAvoidingView';
Expand Down Expand Up @@ -236,18 +237,25 @@ function NewChatPage({isGroupChat}: NewChatPageProps) {
* @param option
*/
function toggleOption(option: ListItem & Partial<OptionData>) {
Alert.alert('Test 01');
const isOptionInList = !!option.isSelected;

let newSelectedOptions;

if (isOptionInList) {
Alert.alert('Test 02');
newSelectedOptions = reject(selectedOptions, (selectedOption) => selectedOption.login === option.login);
} else {
Alert.alert('Test 03');
newSelectedOptions = [...selectedOptions, {...option, isSelected: true, selected: true, reportID: option.reportID ?? '-1'}];
}

Alert.alert('Test 04');

selectionListRef?.current?.clearInputAfterSelect?.();

Alert.alert('Test 05');

setSelectedOptions(newSelectedOptions);
}

Expand Down

0 comments on commit 14f0fb1

Please sign in to comment.