Skip to content

Commit 205c7fd

Browse files
committed
revert(mobile): drop follow-state review changes
1 parent dd36d0d commit 205c7fd

4 files changed

Lines changed: 9 additions & 99 deletions

File tree

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ import {
4141
ThreadComposer,
4242
} from "./ThreadComposer";
4343
import { ThreadFeed } from "./ThreadFeed";
44-
import {
45-
initialThreadEndFollowState,
46-
reduceThreadEndFollowState,
47-
threadEndFollowEnabled,
48-
} from "./thread-end-follow-state";
4944
import type { ThreadContentPresentation } from "./threadContentPresentation";
5045

5146
export 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
/>

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ export interface ThreadFeedProps {
148148
readonly layoutVariant?: LayoutVariant;
149149
readonly usesAutomaticContentInsets?: boolean;
150150
readonly onHeaderMaterialVisibilityChange?: (visible: boolean) => void;
151-
readonly endFollowEnabled: boolean;
152-
readonly onEndFollowEnabledChange: (enabled: boolean) => void;
151+
readonly onEndFollowEnabledChange?: (enabled: boolean) => void;
153152
readonly skills?: ReadonlyArray<SelectableMarkdownSkill>;
154153
/** Non-null when older turns exist beyond the loaded window. */
155154
readonly loadEarlier?: {
@@ -1327,9 +1326,8 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
13271326
// yanked users off history they were reading every time a stream chunk grew
13281327
// a row. Follow breaks when the user scrolls up and away, and re-arms only
13291328
// when the list actually returns to the end (or on send / thread switch).
1330-
const endFollowEnabled = props.endFollowEnabled;
1331-
const endFollowEnabledRef = useRef(endFollowEnabled);
1332-
endFollowEnabledRef.current = endFollowEnabled;
1329+
const [endFollowEnabled, setEndFollowEnabled] = useState(true);
1330+
const endFollowEnabledRef = useRef(true);
13331331
// A "user scroll session" spans from drag start through the end of its
13341332
// momentum; only motion inside a session can break follow, so MVCP
13351333
// compensations and programmatic scrolls never strand a follower.
@@ -1340,7 +1338,8 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
13401338
return;
13411339
}
13421340
endFollowEnabledRef.current = enabled;
1343-
props.onEndFollowEnabledChange(enabled);
1341+
setEndFollowEnabled(enabled);
1342+
props.onEndFollowEnabledChange?.(enabled);
13441343
},
13451344
[props.onEndFollowEnabledChange],
13461345
);

‎apps/mobile/src/features/threads/thread-end-follow-state.test.ts‎

Lines changed: 0 additions & 32 deletions
This file was deleted.

‎apps/mobile/src/features/threads/thread-end-follow-state.ts‎

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)