Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'feature/video-downloads' of https://github.com/m-doescode/bsky-fork

+31 -11
+31 -11
src/components/PostControls/PostMenu/PostMenuItems.tsx
··· 8 8 import * as Clipboard from 'expo-clipboard' 9 9 import { 10 10 type AppBskyEmbedExternal, 11 + type AppBskyEmbedRecordWithMedia, 11 12 type AppBskyEmbedVideo, 12 13 type AppBskyFeedDefs, 13 14 AppBskyFeedPost, ··· 362 363 }) 363 364 } 364 365 366 + const videoEmbed: AppBskyEmbedVideo.View | undefined = useMemo(() => { 367 + if (post.embed?.$type === 'app.bsky.embed.video#view') 368 + return post.embed as AppBskyEmbedVideo.View 369 + if (post.embed?.$type === 'app.bsky.embed.recordWithMedia#view') { 370 + const embed = post.embed as AppBskyEmbedRecordWithMedia.View | undefined 371 + if (embed?.media.$type === 'app.bsky.embed.video#view') 372 + return embed?.media as AppBskyEmbedVideo.View 373 + } 374 + return undefined 375 + }, [post]) 376 + 377 + const gifEmbed: AppBskyEmbedExternal.View | undefined = useMemo(() => { 378 + if (post.embed?.$type === 'app.bsky.embed.external#view') 379 + return post.embed as AppBskyEmbedExternal.View 380 + if (post.embed?.$type === 'app.bsky.embed.recordWithMedia#view') { 381 + const embed = post.embed as AppBskyEmbedRecordWithMedia.View | undefined 382 + if (embed?.media.$type === 'app.bsky.embed.external#view') 383 + return embed?.media as AppBskyEmbedExternal.View 384 + } 385 + return undefined 386 + }, [post]) 387 + 365 388 const onPressDownloadVideo = async () => { 366 - if (post.embed?.$type !== 'app.bsky.embed.video#view') return 367 - const video = post.embed as AppBskyEmbedVideo.View 389 + if (!videoEmbed) return 368 390 const did = post.author.did 369 - const cid = video.cid 391 + const cid = videoEmbed.cid 370 392 if (!did.startsWith('did:')) return 371 393 const pdsUrl = await resolvePdsServiceUrl(did as `did:${string}`) 372 394 const uri = `${pdsUrl}/xrpc/com.atproto.sync.getBlob?did=${did}&cid=${cid}` ··· 382 404 } 383 405 384 406 const onPressDownloadGif = async () => { 385 - if (post.embed?.$type !== 'app.bsky.embed.external#view') return 386 - const media = post.embed as AppBskyEmbedExternal.View 407 + if (!gifEmbed) return 387 408 388 409 Toast.show('Downloading GIF...', 'download') 389 410 390 411 let success 391 - if (isWeb) success = await downloadVideoWeb({uri: media.external.uri}) 392 - else success = await saveVideoToMediaLibrary({uri: media.external.uri}) 412 + if (isWeb) success = await downloadVideoWeb({uri: gifEmbed.external.uri}) 413 + else success = await saveVideoToMediaLibrary({uri: gifEmbed.external.uri}) 393 414 394 415 if (success) Toast.show('GIF downloaded', 'check') 395 416 else Toast.show('Failed to download GIF', 'xmark') 396 417 } 397 418 398 419 const isEmbedGif = () => { 399 - if (post.embed?.$type !== 'app.bsky.embed.external#view') return false 400 - const embed = post.embed as AppBskyEmbedExternal.View 420 + if (!gifEmbed) return false 401 421 // Janky workaround by checking if the domain is tenor.com 402 - const url = new URL(embed.external.uri) 422 + const url = new URL(gifEmbed.external.uri) 403 423 return url.host === 'media.tenor.com' 404 424 } 405 425 ··· 484 504 </> 485 505 )} 486 506 487 - {post.embed?.$type === 'app.bsky.embed.video#view' && ( 507 + {videoEmbed && ( 488 508 <> 489 509 <Menu.Group> 490 510 <Menu.Item