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

Configure Feed

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

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

authored by

Eric Bailey and committed by
GitHub
f868821c 2bb36948

+4 -45
+3 -1
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' 5 6 import {PostEmbeds} from '#/view/com/util/post-embeds' 6 7 import {atoms as a, useTheme} from '#/alf' 7 8 ··· 13 14 const t = useTheme() 14 15 15 16 return ( 16 - <View style={[a.my_xs, t.atoms.bg, a.rounded_md, {flexBasis: 0}]}> 17 + <View 18 + style={[a.my_xs, t.atoms.bg, a.rounded_md, isNative && {flexBasis: 0}]}> 17 19 <PostEmbeds embed={embed} /> 18 20 </View> 19 21 )
+1 -44
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, AppBskyRichtextFacet, RichText} from '@atproto/api' 16 + import {AppBskyEmbedRecord, 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' 23 19 import {logger} from '#/logger' 24 20 import {isNative} from '#/platform/detection' 25 21 import {isConvoActive, useConvoActive} from '#/state/messages/convo' ··· 292 288 uri: post.uri, 293 289 cid: post.cid, 294 290 }, 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 - } 334 291 } 335 292 } 336 293 } catch (error) {