Bluesky app fork with some witchin' additions ๐Ÿ’ซ
0
fork

Configure Feed

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

Revert "[๐Ÿด] Embed backwards compat (#4302)" (#4338)

This reverts commit f868821cfcc87b62a320e5a1e11375fdb973adc1.

authored by

Eric Bailey and committed by
GitHub
de257a11 d93acb25

+45 -4
+1 -3
src/components/dms/MessageItemEmbed.tsx
··· 2 2 import {View} from 'react-native' 3 3 import {AppBskyEmbedRecord} from '@atproto/api' 4 4 5 - import {isNative} from '#/platform/detection' 6 5 import {PostEmbeds} from '#/view/com/util/post-embeds' 7 6 import {atoms as a, useTheme} from '#/alf' 8 7 ··· 14 13 const t = useTheme() 15 14 16 15 return ( 17 - <View 18 - style={[a.my_xs, t.atoms.bg, a.rounded_md, isNative && {flexBasis: 0}]}> 16 + <View style={[a.my_xs, t.atoms.bg, a.rounded_md, {flexBasis: 0}]}> 19 17 <PostEmbeds embed={embed} /> 20 18 </View> 21 19 )
+44 -1
src/screens/Messages/Conversation/MessagesList.tsx
··· 13 13 } from 'react-native-reanimated' 14 14 import {ReanimatedScrollEvent} from 'react-native-reanimated/lib/typescript/reanimated2/hook/commonTypes' 15 15 import {useSafeAreaInsets} from 'react-native-safe-area-context' 16 - import {AppBskyEmbedRecord, RichText} from '@atproto/api' 16 + import {AppBskyEmbedRecord, AppBskyRichtextFacet, RichText} from '@atproto/api' 17 17 18 18 import {shortenLinks, stripInvalidMentions} from '#/lib/strings/rich-text-manip' 19 + import { 20 + convertBskyAppUrlIfNeeded, 21 + isBskyPostUrl, 22 + } from '#/lib/strings/url-helpers' 19 23 import {logger} from '#/logger' 20 24 import {isNative} from '#/platform/detection' 21 25 import {isConvoActive, useConvoActive} from '#/state/messages/convo' ··· 288 292 uri: post.uri, 289 293 cid: post.cid, 290 294 }, 295 + } 296 + 297 + // look for the embed uri in the facets, so we can remove it from the text 298 + const postLinkFacet = rt.facets?.find(facet => { 299 + return facet.features.find(feature => { 300 + if (AppBskyRichtextFacet.isLink(feature)) { 301 + if (isBskyPostUrl(feature.uri)) { 302 + const url = convertBskyAppUrlIfNeeded(feature.uri) 303 + const [_0, _1, _2, rkey] = url.split('/').filter(Boolean) 304 + 305 + // this might have a handle instead of a DID 306 + // so just compare the rkey - not particularly dangerous 307 + return post.uri.endsWith(rkey) 308 + } 309 + } 310 + return false 311 + }) 312 + }) 313 + 314 + if (postLinkFacet) { 315 + // remove the post link from the text 316 + rt.delete( 317 + postLinkFacet.index.byteStart, 318 + postLinkFacet.index.byteEnd, 319 + ) 320 + 321 + // re-trim the text, now that we've removed the post link 322 + // 323 + // if the post link is at the start of the text, we don't want to leave a leading space 324 + // so trim on both sides 325 + if (postLinkFacet.index.byteStart === 0) { 326 + rt = new RichText({text: rt.text.trim()}, {cleanNewlines: true}) 327 + } else { 328 + // otherwise just trim the end 329 + rt = new RichText( 330 + {text: rt.text.trimEnd()}, 331 + {cleanNewlines: true}, 332 + ) 333 + } 291 334 } 292 335 } 293 336 } catch (error) {