@@ -41,11 +41,6 @@ import {
4141 ThreadComposer ,
4242} from "./ThreadComposer" ;
4343import { ThreadFeed } from "./ThreadFeed" ;
44- import {
45- initialThreadEndFollowState ,
46- reduceThreadEndFollowState ,
47- threadEndFollowEnabled ,
48- } from "./thread-end-follow-state" ;
4944import type { ThreadContentPresentation } from "./threadContentPresentation" ;
5045
5146export interface ThreadDetailScreenProps {
@@ -189,10 +184,7 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
189184 const lastScrolledAnchorMessageIdRef = useRef < MessageId | null > ( null ) ;
190185 const [ composerExpanded , setComposerExpanded ] = useState ( false ) ;
191186 const [ anchorMessageId , setAnchorMessageId ] = useState < MessageId | null > ( null ) ;
192- const [ endFollowState , setEndFollowState ] = useState ( ( ) =>
193- initialThreadEndFollowState ( selectedThreadKey ) ,
194- ) ;
195- const endFollowEnabled = threadEndFollowEnabled ( endFollowState , selectedThreadKey ) ;
187+ const [ endFollowEnabled , setEndFollowEnabled ] = useState ( true ) ;
196188 const composerBottomInset = composerExpanded ? 0 : Math . max ( insets . bottom , 12 ) ;
197189 const contentPresentationKind = props . contentPresentation . kind ;
198190 // The raw sync status enters "synchronizing" on every full fetch, cached or
@@ -251,6 +243,7 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
251243 useEffect ( ( ) => {
252244 setAnchorMessageId ( null ) ;
253245 lastScrolledAnchorMessageIdRef . current = null ;
246+ setEndFollowEnabled ( true ) ;
254247 freeze . set ( false ) ;
255248 } , [ freeze , selectedThreadKey ] ) ;
256249
@@ -322,31 +315,12 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
322315 composerEditorRef . current ?. blur ( ) ;
323316 } , [ ] ) ;
324317
325- const handleEndFollowEnabledChange = useCallback (
326- ( enabled : boolean ) => {
327- setEndFollowState ( ( current ) =>
328- reduceThreadEndFollowState ( current , {
329- type : "observed" ,
330- threadKey : selectedThreadKey ,
331- enabled,
332- } ) ,
333- ) ;
334- } ,
335- [ selectedThreadKey ] ,
336- ) ;
337-
338318 const handleScrollToEnd = useCallback ( ( ) => {
339- setEndFollowState ( ( current ) =>
340- reduceThreadEndFollowState ( current , {
341- type : "scrollToEnd" ,
342- threadKey : selectedThreadKey ,
343- } ) ,
344- ) ;
345319 void Haptics . selectionAsync ( ) ;
346320 void scrollMessageToEnd ( { animated : true , closeKeyboard : false } ) . catch ( ( ) => {
347321 freeze . set ( false ) ;
348322 } ) ;
349- } , [ freeze , scrollMessageToEnd , selectedThreadKey ] ) ;
323+ } , [ freeze , scrollMessageToEnd ] ) ;
350324
351325 const showScrollToEndButton = contentPresentationKind === "ready" && ! endFollowEnabled ;
352326
@@ -410,8 +384,7 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
410384 layoutVariant = { layoutVariant }
411385 usesAutomaticContentInsets = { props . usesAutomaticContentInsets }
412386 onHeaderMaterialVisibilityChange = { props . onHeaderMaterialVisibilityChange }
413- endFollowEnabled = { endFollowEnabled }
414- onEndFollowEnabledChange = { handleEndFollowEnabledChange }
387+ onEndFollowEnabledChange = { setEndFollowEnabled }
415388 skills = { selectedProviderSkills }
416389 loadEarlier = { props . loadEarlier ?? null }
417390 />
0 commit comments