Bluesky app fork with some witchin' additions 💫

feat: use OP's language as recommendation when replying (#8832)

* feat: use OP's language as recommendation when replying

* fix: address nits

authored by

Elijah Seed-Arita and committed by
GitHub
5ca66546 4e0be91c

+31 -4
+1
src/screens/PostThread/components/ThreadItemAnchor.tsx
··· 254 254 author: post.author, 255 255 embed: post.embed, 256 256 moderation, 257 + langs: record.langs, 257 258 }, 258 259 onPostSuccess: onPostSuccess, 259 260 })
+1
src/screens/PostThread/components/ThreadItemPost.tsx
··· 234 234 author: post.author, 235 235 embed: post.embed, 236 236 moderation, 237 + langs: post.record.langs, 237 238 }, 238 239 onPostSuccess: onPostSuccess, 239 240 })
+1
src/screens/PostThread/components/ThreadItemTreePost.tsx
··· 298 298 author: post.author, 299 299 embed: post.embed, 300 300 moderation, 301 + langs: post.record.langs, 301 302 }, 302 303 onPostSuccess: onPostSuccess, 303 304 })
+1
src/screens/PostThread/index.tsx
··· 91 91 author: post.author, 92 92 embed: post.embed, 93 93 moderation: anchor.moderation, 94 + langs: post.record.langs, 94 95 }, 95 96 onPostSuccess: optimisticOnPostReply, 96 97 })
+1
src/screens/VideoFeed/index.tsx
··· 753 753 text: record?.text || '', 754 754 author: post.author, 755 755 embed: post.embed, 756 + langs: record?.langs, 756 757 }, 757 758 }) 758 759 }, [openComposer, post, record])
+1
src/state/shell/composer/index.tsx
··· 20 20 uri: string 21 21 cid: string 22 22 text: string 23 + langs?: string[] 23 24 author: AppBskyActorDefs.ProfileViewBasic 24 25 embed?: AppBskyFeedDefs.PostView['embed'] 25 26 moderation?: ModerationDecision
+5 -1
src/view/com/composer/Composer.tsx
··· 621 621 622 622 const footer = ( 623 623 <> 624 - <SuggestedLanguage text={activePost.richtext.text} /> 624 + <SuggestedLanguage 625 + text={activePost.richtext.text} 626 + // NOTE(@elijaharita): currently just choosing the first language if any exists 627 + replyToLanguage={replyTo?.langs?.[0]} 628 + /> 625 629 <ComposerPills 626 630 isReply={!!replyTo} 627 631 post={activePost}
+16 -3
src/view/com/composer/select-language/SuggestedLanguage.tsx
··· 19 19 const onIdle = globalThis.requestIdleCallback || (cb => setTimeout(cb, 1)) 20 20 const cancelIdle = globalThis.cancelIdleCallback || clearTimeout 21 21 22 - export function SuggestedLanguage({text}: {text: string}) { 22 + export function SuggestedLanguage({ 23 + text, 24 + replyToLanguage, 25 + }: { 26 + text: string 27 + replyToLanguage?: string 28 + }) { 23 29 const [suggestedLanguage, setSuggestedLanguage] = useState< 24 30 string | undefined 25 - >() 31 + >(text.length === 0 ? replyToLanguage : undefined) 26 32 const langPrefs = useLanguagePrefs() 27 33 const setLangPrefs = useLanguagePrefsApi() 28 34 const t = useTheme() 29 35 const {_} = useLingui() 30 36 31 37 useEffect(() => { 38 + // For replies, suggest the language of the post being replied to if no text 39 + // has been typed yet 40 + if (replyToLanguage && text.length === 0) { 41 + setSuggestedLanguage(replyToLanguage) 42 + return 43 + } 44 + 32 45 const textTrimmed = text.trim() 33 46 34 47 // Don't run the language model on small posts, the results are likely ··· 43 56 }) 44 57 45 58 return () => cancelIdle(idle) 46 - }, [text]) 59 + }, [text, replyToLanguage]) 47 60 48 61 if ( 49 62 suggestedLanguage &&
+1
src/view/com/post-thread/PostThread.tsx
··· 420 420 author: thread.post.author, 421 421 embed: thread.post.embed, 422 422 moderation: threadModerationCache.get(thread), 423 + langs: thread.record.langs, 423 424 }, 424 425 onPost: onPostReply, 425 426 })
+1
src/view/com/post-thread/PostThreadItem.tsx
··· 299 299 author: post.author, 300 300 embed: post.embed, 301 301 moderation, 302 + langs: record.langs, 302 303 }, 303 304 onPost: onPostReply, 304 305 onPostSuccess: onPostSuccess,
+1
src/view/com/post/Post.tsx
··· 131 131 author: post.author, 132 132 embed: post.embed, 133 133 moderation, 134 + langs: record.langs, 134 135 }, 135 136 }) 136 137 }, [openComposer, post, record, moderation])
+1
src/view/com/posts/PostFeedItem.tsx
··· 193 193 author: post.author, 194 194 embed: post.embed, 195 195 moderation, 196 + langs: record.langs, 196 197 }, 197 198 }) 198 199 }