mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-17 09:48:42 +00:00
[Glitch] Update to latest eslint-plugin-react-hooks
Port 9addad8ce5 to glitch-soc
Co-authored-by: diondiondion <mail@diondiondion.com>
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -55,6 +55,8 @@ const getFrequentlyUsedLanguages = createSelector(
|
||||
.toArray(),
|
||||
);
|
||||
|
||||
const isTextLongEnoughForGuess = (text: string) => text.length > 20;
|
||||
|
||||
const LanguageDropdownMenu: React.FC<{
|
||||
value: string;
|
||||
guess?: string;
|
||||
@@ -375,14 +377,27 @@ export const LanguageDropdown: React.FC = () => {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (text.length > 20) {
|
||||
if (isTextLongEnoughForGuess(text)) {
|
||||
debouncedGuess(text, setGuess);
|
||||
} else {
|
||||
debouncedGuess.cancel();
|
||||
setGuess('');
|
||||
}
|
||||
}, [text, setGuess]);
|
||||
|
||||
// Keeping track of the previous render's text length here
|
||||
// to be able to reset the guess when the text length drops
|
||||
// below the threshold needed to make a guess
|
||||
const [wasLongText, setWasLongText] = useState(() =>
|
||||
isTextLongEnoughForGuess(text),
|
||||
);
|
||||
if (wasLongText !== isTextLongEnoughForGuess(text)) {
|
||||
setWasLongText(isTextLongEnoughForGuess(text));
|
||||
|
||||
if (wasLongText) {
|
||||
setGuess('');
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div ref={targetRef}>
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user