Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

add rich text facets to description (#4619)

authored by

Hailey and committed by
GitHub
51fca956 ed940c63

+48 -21
+12 -5
src/screens/StarterPack/StarterPackScreen.tsx
··· 7 7 AppBskyGraphStarterpack, 8 8 AtUri, 9 9 ModerationOpts, 10 + RichText as RichTextAPI, 10 11 } from '@atproto/api' 11 12 import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' 12 13 import {msg, Trans} from '@lingui/macro' ··· 52 53 import * as Menu from '#/components/Menu' 53 54 import * as Prompt from '#/components/Prompt' 54 55 import {ReportDialog, useReportDialogControl} from '#/components/ReportDialog' 56 + import {RichText} from '#/components/RichText' 55 57 import {FeedsList} from '#/components/StarterPack/Main/FeedsList' 56 58 import {ProfilesList} from '#/components/StarterPack/Main/ProfilesList' 57 59 import {QrCodeDialog} from '#/components/StarterPack/QrCodeDialog' ··· 280 282 return null 281 283 } 282 284 285 + const richText = record.description 286 + ? new RichTextAPI({ 287 + text: record.description, 288 + facets: record.descriptionFacets, 289 + }) 290 + : undefined 291 + 283 292 return ( 284 293 <> 285 294 <ProfileSubpageHeader ··· 324 333 /> 325 334 </View> 326 335 </ProfileSubpageHeader> 327 - {record.description || joinedAllTimeCount >= 25 ? ( 336 + {richText || joinedAllTimeCount >= 25 ? ( 328 337 <View style={[a.px_lg, a.pt_md, a.pb_sm, a.gap_md]}> 329 - {record.description ? ( 330 - <Text style={[a.text_md, a.leading_snug]}> 331 - {record.description} 332 - </Text> 338 + {richText ? ( 339 + <RichText value={richText} style={[a.text_md, a.leading_snug]} /> 333 340 ) : null} 334 341 {joinedAllTimeCount >= 25 ? ( 335 342 <View style={[a.flex_row, a.align_center, a.gap_sm]}>
-2
src/screens/StarterPack/Wizard/index.tsx
··· 245 245 editStarterPack({ 246 246 name: state.name?.trim() || getDefaultName(), 247 247 description: state.description?.trim(), 248 - descriptionFacets: [], 249 248 profiles: state.profiles, 250 249 feeds: state.feeds, 251 250 currentStarterPack: currentStarterPack, ··· 255 254 createStarterPack({ 256 255 name: state.name?.trim() || getDefaultName(), 257 256 description: state.description?.trim(), 258 - descriptionFacets: [], 259 257 profiles: state.profiles, 260 258 feeds: state.feeds, 261 259 })
+36 -14
src/state/queries/starter-packs.ts
··· 4 4 AppBskyGraphDefs, 5 5 AppBskyGraphGetStarterPack, 6 6 AppBskyGraphStarterpack, 7 + AppBskyRichtextFacet, 7 8 AtUri, 8 9 BskyAgent, 10 + RichText, 9 11 } from '@atproto/api' 10 12 import {StarterPackView} from '@atproto/api/dist/client/types/app/bsky/graph/defs' 11 13 import { ··· 80 82 interface UseCreateStarterPackMutationParams { 81 83 name: string 82 84 description?: string 83 - descriptionFacets: [] 84 85 profiles: AppBskyActorDefs.ProfileViewBasic[] 85 86 feeds?: AppBskyFeedDefs.GeneratorView[] 86 87 } ··· 100 101 Error, 101 102 UseCreateStarterPackMutationParams 102 103 >({ 103 - mutationFn: async params => { 104 + mutationFn: async ({name, description, feeds, profiles}) => { 105 + let descriptionFacets: AppBskyRichtextFacet.Main[] | undefined 106 + if (description) { 107 + const rt = new RichText({text: description}) 108 + await rt.detectFacets(agent) 109 + descriptionFacets = rt.facets 110 + } 111 + 104 112 let listRes 105 - listRes = await createStarterPackList({...params, agent}) 113 + listRes = await createStarterPackList({ 114 + name, 115 + description, 116 + profiles, 117 + descriptionFacets, 118 + agent, 119 + }) 120 + 106 121 return await agent.app.bsky.graph.starterpack.create( 107 122 { 108 123 repo: agent.session?.did, 109 124 }, 110 125 { 111 - ...params, 126 + name, 127 + description, 128 + descriptionFacets, 112 129 list: listRes?.uri, 130 + feeds, 113 131 createdAt: new Date().toISOString(), 114 132 }, 115 133 ) ··· 148 166 currentListItems: AppBskyGraphDefs.ListItemView[] 149 167 } 150 168 >({ 151 - mutationFn: async params => { 152 - const { 153 - name, 154 - description, 155 - descriptionFacets, 156 - feeds, 157 - profiles, 158 - currentStarterPack, 159 - currentListItems, 160 - } = params 169 + mutationFn: async ({ 170 + name, 171 + description, 172 + feeds, 173 + profiles, 174 + currentStarterPack, 175 + currentListItems, 176 + }) => { 177 + let descriptionFacets: AppBskyRichtextFacet.Main[] | undefined 178 + if (description) { 179 + const rt = new RichText({text: description}) 180 + await rt.detectFacets(agent) 181 + descriptionFacets = rt.facets 182 + } 161 183 162 184 if (!AppBskyGraphStarterpack.isRecord(currentStarterPack.record)) { 163 185 throw new Error('Invalid starter pack')