Skip to content

Commit dbc4765

Browse files
committed
fix(mobile): images in video item
1 parent 210b327 commit dbc4765

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

apps/mobile/src/components/ui/image/Image.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export type ImageProps = Omit<ExpoImageProps, "source"> & {
2727
export const Image = forwardRef<ExpoImage, ImageProps>(
2828
({ proxy, source, blurhash, aspectRatio, ...rest }, ref) => {
2929
const safeSource: ImageProps["source"] = useMemo(() => {
30-
return source
30+
return source?.uri
3131
? {
3232
...source,
3333
headers: {
@@ -66,6 +66,10 @@ export const Image = forwardRef<ExpoImage, ImageProps>(
6666
[isError, rest],
6767
)
6868

69+
if (!source?.uri) {
70+
return null
71+
}
72+
6973
return (
7074
<ExpoImage
7175
source={isError ? safeSource : proxiesSafeSource}

apps/mobile/src/modules/entry-list/templates/EntrySocialItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export function EntrySocialItem({ entryId }: { entryId: string }) {
118118
<Galeria.Image index={index}>
119119
<Image
120120
proxy={{
121-
height: 80,
121+
width: fullWidth ? 400 : 200,
122122
}}
123123
source={{ uri: image.url }}
124124
blurhash={image.blurhash}

apps/mobile/src/modules/entry-list/templates/EntryVideoItem.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import { transformVideoUrl } from "@follow/utils"
22
import { Linking } from "react-native"
33

44
import { useGeneralSettingKey } from "@/src/atoms/settings/general"
5-
import { MediaCarousel } from "@/src/components/ui/carousel/MediaCarousel"
5+
import { Image } from "@/src/components/ui/image/Image"
66
import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable"
77
import { openLink } from "@/src/lib/native"
88
import { toast } from "@/src/lib/toast"
99
import { useEntry } from "@/src/store/entry/hooks"
1010
import { unreadSyncService } from "@/src/store/unread/store"
1111

1212
import { VideoContextMenu } from "../../context-menu/video"
13+
import { EntryGridFooter } from "../../entry-content/EntryGridFooter"
1314

1415
export function EntryVideoItem({ id }: { id: string }) {
1516
const item = useEntry(id)
@@ -19,12 +20,10 @@ export function EntryVideoItem({ id }: { id: string }) {
1920
return null
2021
}
2122

22-
const firstMedia = item.media.slice(0, 1)
23-
2423
return (
2524
<VideoContextMenu entryId={id}>
2625
<ItemPressable
27-
className="m-1 overflow-hidden rounded-md"
26+
className="m-1"
2827
onPress={() => {
2928
unreadSyncService.markEntryAsRead(id)
3029
if (!item.url) {
@@ -34,13 +33,15 @@ export function EntryVideoItem({ id }: { id: string }) {
3433
openVideo(item.url, needOpenVideoInApp)
3534
}}
3635
>
37-
<MediaCarousel
38-
entryId={id}
39-
media={firstMedia}
36+
<Image
37+
source={{ uri: item.media[0]?.url || "" }}
4038
aspectRatio={16 / 9}
41-
// AccessoryProps={{ id }}
42-
noPreview={true}
39+
className="w-full rounded-lg"
40+
proxy={{
41+
width: 200,
42+
}}
4343
/>
44+
<EntryGridFooter entryId={id} />
4445
</ItemPressable>
4546
</VideoContextMenu>
4647
)

packages/utils/src/headers.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ export const createBuildSafeHeaders =
3535
}
3636

3737
try {
38-
const urlObj = new URL(url)
38+
if (url) {
39+
const urlObj = new URL(url)
3940

40-
headers.Referer = urlObj.origin
41-
headers.Origin = urlObj.origin
41+
headers.Referer = urlObj.origin
42+
headers.Origin = urlObj.origin
43+
}
4244
} catch (error) {
43-
console.warn(error)
45+
console.warn(`Url parsing error: ${error}, url: ${url}.`)
4446
}
4547

4648
return headers

0 commit comments

Comments
 (0)