()
| 125 | }; |
| 126 | |
| 127 | const ManageWallets: React.FC = () => { |
| 128 | const { colors, closeImage, dark } = useTheme(); |
| 129 | const { wallets: persistedWallets, setWalletsWithNewOrder, txMetadata } = useStorage(); |
| 130 | const initialWalletsRef = useRef<TWallet[]>(deepCopyWallets(persistedWallets)); |
| 131 | const { navigate, setOptions, goBack } = useExtendedNavigation(); |
| 132 | const { direction } = useLocale(); |
| 133 | const [state, dispatch] = useReducer(reducer, initialState); |
| 134 | const bounceAnim = useBounceAnimation(state.searchQuery); |
| 135 | const stylesHook = { |
| 136 | noResultsText: { |
| 137 | color: colors.foregroundColor, |
| 138 | writingDirection: direction, |
| 139 | }, |
| 140 | clearSearchButton: { |
| 141 | backgroundColor: colors.buttonBackgroundColor, |
| 142 | }, |
| 143 | }; |
| 144 | const [noResultsOpacity] = useState(new Animated.Value(0)); |
| 145 | |
| 146 | const [dragging, setDragging] = useState(false); |
| 147 | const searchTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null); |
| 148 | const debouncedSearch = useCallback((text: string) => { |
| 149 | if (searchTimerRef.current) clearTimeout(searchTimerRef.current); |
| 150 | if (text.length === 0) { |
| 151 | dispatch({ type: SET_SEARCH_QUERY, payload: '' }); |
| 152 | return; |
| 153 | } |
| 154 | searchTimerRef.current = setTimeout(() => { |
| 155 | startTransition(() => { |
| 156 | dispatch({ type: SET_SEARCH_QUERY, payload: text }); |
| 157 | }); |
| 158 | }, 300); |
| 159 | }, []); |
| 160 | |
| 161 | useEffect(() => { |
| 162 | return () => { |
| 163 | if (searchTimerRef.current) clearTimeout(searchTimerRef.current); |
| 164 | }; |
| 165 | }, []); |
| 166 | |
| 167 | const getFilteredWalletsData = useCallback((search: string, walletsSource: TWallet[], metadataSource: TTXMetadata): Item[] => { |
| 168 | if (search) { |
| 169 | const lowerQuery = search.toLowerCase(); |
| 170 | |
| 171 | const walletsWithMatches = new Map< |
| 172 | string, |
| 173 | { |
| 174 | wallet: TWallet; |
| 175 | transactions: TransactionItem[]; |
| 176 | addresses: AddressItem[]; |
| 177 | } |
| 178 | >(); |
| 179 | |
| 180 | const walletIdSet = new Set(walletsSource.map(wallet => wallet.getID())); |
| 181 | |
| 182 | const matchingTxids = Object.entries(metadataSource).filter( |
| 183 | ([_, metadata]) => metadata.memo && metadata.memo.toLowerCase().includes(lowerQuery), |
| 184 | ); |
nothing calls this directly
no test coverage detected