Replace lande with native language detection (#9974)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: DS Boyce <260543580+ds-boyce@users.noreply.github.com> Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
@@ -268,6 +268,20 @@ export const ComposePost = ({
|
||||
setReplyToLanguages([])
|
||||
}
|
||||
|
||||
/**
|
||||
* Timestamp (ms) of the last honored nudge from language detection.
|
||||
* Used to rate-limit the pulse animation: we ignore back-to-back
|
||||
* nudges that arrive within NUDGE_COOLDOWN_MS. Consumers key an effect
|
||||
* on this value — it only changes when we actually want to re-pulse.
|
||||
*/
|
||||
const [languageNudgeAt, setLanguageNudgeAt] = useState(0)
|
||||
const onLanguageNudge = () => {
|
||||
const now = Date.now()
|
||||
// ignore back-to-back nudges within 10s; only update state (and
|
||||
// therefore re-pulse) once the cooldown has elapsed
|
||||
setLanguageNudgeAt(prev => (now - prev > 10_000 ? now : prev))
|
||||
}
|
||||
|
||||
const [composerState, composerDispatch] = useReducer(
|
||||
composerReducer,
|
||||
{
|
||||
@@ -1146,6 +1160,7 @@ export const ComposePost = ({
|
||||
replyToLanguages={replyToLanguages}
|
||||
currentLanguages={currentLanguages}
|
||||
onAcceptSuggestedLanguage={setAcceptedLanguageSuggestion}
|
||||
onNudge={onLanguageNudge}
|
||||
/>
|
||||
<ComposerPills
|
||||
isReply={!!replyTo}
|
||||
@@ -1169,6 +1184,7 @@ export const ComposePost = ({
|
||||
}}
|
||||
currentLanguages={currentLanguages}
|
||||
onSelectLanguage={onSelectLanguage}
|
||||
languageNudgeAt={languageNudgeAt}
|
||||
openGallery={openGallery}
|
||||
textInputRef={textInputRef}
|
||||
/>
|
||||
@@ -1873,6 +1889,7 @@ function ComposerFooter({
|
||||
onAddPost,
|
||||
currentLanguages,
|
||||
onSelectLanguage,
|
||||
languageNudgeAt,
|
||||
openGallery,
|
||||
textInputRef,
|
||||
}: {
|
||||
@@ -1884,6 +1901,7 @@ function ComposerFooter({
|
||||
onAddPost: () => void
|
||||
currentLanguages: string[]
|
||||
onSelectLanguage?: (language: string) => void
|
||||
languageNudgeAt: number
|
||||
openGallery?: boolean
|
||||
textInputRef: React.RefObject<TextInputRef | null>
|
||||
}) {
|
||||
@@ -2049,6 +2067,7 @@ function ComposerFooter({
|
||||
<PostLanguageSelect
|
||||
currentLanguages={currentLanguages}
|
||||
onSelectLanguage={onSelectLanguage}
|
||||
nudgeAt={languageNudgeAt}
|
||||
/>
|
||||
<CharProgress
|
||||
count={post.shortenedGraphemeLength}
|
||||
|
||||
Reference in New Issue
Block a user