The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 04:15 UTC
fix(mobile): image viewer no longer flashes the chat between swipes on Android (#20898)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
vivek committed
Oct 19, 2026 at 00:45 UTC
b9a31ac6fad0d44e673e1e3e4f228bd0d80f3f12
1 file changed
+11
-10
apps/mobile/src/components/MediaImagePreview.tsx
+11
-10
@@ -1,4 +1,4 @@
1
-import { createContext, useContext, useState, useMemo } from "react";
1
+import { createContext, useContext, useState } from "react";
2
import { Pressable, View } from "react-native";
3
import ImageViewing from "react-native-image-viewing";
4
import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -17,15 +17,16 @@ type MediaImagePreviewProps = {
17
18
const ImagePreviewContext = createContext<MediaImagePreviewProps | null>(null);
19
20
-function ImagePreviewHeader() {
20
+function ImagePreviewHeader(header: { readonly imageIndex: number }) {
21
const props = useContext(ImagePreviewContext)!;
22
+ const source = props.source.gallery?.[header.imageIndex] ?? props.source;
23
const insets = useSafeAreaInsets();
23
- const mediaActions = useMediaActions(props.source.actionsSource, props.onRequestClose);
24
+ const mediaActions = useMediaActions(source.actionsSource, props.onRequestClose);
25
return (
26
<View className="bg-black/70" style={{ paddingTop: insets.top }}>
27
<View className="flex-row items-center gap-2 px-3">
28
<AppText className="flex-1 text-base text-white" numberOfLines={2}>
28
- {props.source.name ?? "Image"}
29
+ {source.name ?? "Image"}
30
</AppText>
31
<MediaActionsMenu media={mediaActions} inModal />
32
<Pressable
@@ -44,20 +45,20 @@ function ImagePreviewHeader() {
45
46
export function MediaImagePreview(props: MediaImagePreviewProps) {
47
const gallery = props.source.gallery ?? [props.source];
47
- const [index, setIndex] = useState(() =>
48
+ // react-native-image-viewing keys its whole Modal by imageIndex, so changing it remounts the
49
+ // viewer and replays the Android fade over the screen behind. Keep the opening index; the
50
+ // header follows paging through the index the library passes it.
51
+ const [initialIndex] = useState(() =>
52
Math.max(
53
0,
54
gallery.findIndex((item) => item.uri === props.source.uri),
55
),
56
);
53
- const selected = gallery[index] ?? props.source;
54
- const context = useMemo(() => ({ ...props, source: selected }), [props, selected]);
57
return (
56
- <ImagePreviewContext value={context}>
58
+ <ImagePreviewContext value={props}>
59
<ImageViewing
60
images={gallery.map((item) => ({ uri: item.uri }))}
59
- imageIndex={index}
60
- onImageIndexChange={setIndex}
61
+ imageIndex={initialIndex}
62
visible
63
presentationStyle="fullScreen"
64
onRequestClose={props.onRequestClose}