kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Remove Immutable.js from "autosuggest-account-input"
rodzic
2127bd52ce
commit
aac4798034
|
@ -1,5 +1,4 @@
|
||||||
import { throttle } from 'es-toolkit';
|
import { throttle } from 'es-toolkit';
|
||||||
import { OrderedSet as ImmutableOrderedSet } from 'immutable';
|
|
||||||
import { useState, useRef, useCallback, useEffect } from 'react';
|
import { useState, useRef, useCallback, useEffect } from 'react';
|
||||||
|
|
||||||
import { accountSearch } from 'soapbox/actions/accounts.ts';
|
import { accountSearch } from 'soapbox/actions/accounts.ts';
|
||||||
|
@ -32,7 +31,7 @@ const AutosuggestAccountInput: React.FC<IAutosuggestAccountInput> = ({
|
||||||
...rest
|
...rest
|
||||||
}) => {
|
}) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const [accountIds, setAccountIds] = useState(ImmutableOrderedSet<string>());
|
const [accountIds, setAccountIds] = useState(new Set<string>());
|
||||||
const controller = useRef(new AbortController());
|
const controller = useRef(new AbortController());
|
||||||
|
|
||||||
const refreshCancelToken = () => {
|
const refreshCancelToken = () => {
|
||||||
|
@ -41,7 +40,7 @@ const AutosuggestAccountInput: React.FC<IAutosuggestAccountInput> = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearResults = () => {
|
const clearResults = () => {
|
||||||
setAccountIds(ImmutableOrderedSet());
|
setAccountIds(new Set<string>());
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAccountSearch = useCallback(throttle((q) => {
|
const handleAccountSearch = useCallback(throttle((q) => {
|
||||||
|
@ -50,7 +49,7 @@ const AutosuggestAccountInput: React.FC<IAutosuggestAccountInput> = ({
|
||||||
dispatch(accountSearch(params, controller.current.signal))
|
dispatch(accountSearch(params, controller.current.signal))
|
||||||
.then((accounts: { id: string }[]) => {
|
.then((accounts: { id: string }[]) => {
|
||||||
const accountIds = accounts.map(account => account.id);
|
const accountIds = accounts.map(account => account.id);
|
||||||
setAccountIds(ImmutableOrderedSet(accountIds));
|
setAccountIds(new Set<string>(accountIds));
|
||||||
})
|
})
|
||||||
.catch(noOp);
|
.catch(noOp);
|
||||||
}, 900, { edges: ['leading', 'trailing'] }), [limit]);
|
}, 900, { edges: ['leading', 'trailing'] }), [limit]);
|
||||||
|
@ -83,7 +82,7 @@ const AutosuggestAccountInput: React.FC<IAutosuggestAccountInput> = ({
|
||||||
<AutosuggestInput
|
<AutosuggestInput
|
||||||
value={value}
|
value={value}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
suggestions={accountIds.toList()}
|
suggestions={Array.from(accountIds)}
|
||||||
onSuggestionsFetchRequested={noOp}
|
onSuggestionsFetchRequested={noOp}
|
||||||
onSuggestionsClearRequested={noOp}
|
onSuggestionsClearRequested={noOp}
|
||||||
onSuggestionSelected={handleSelected}
|
onSuggestionSelected={handleSelected}
|
||||||
|
|
Ładowanie…
Reference in New Issue