@@ -35,6 +35,7 @@ import {
3535
3636import type { JSX } from 'react'
3737import { VerificationBadge } from 'components/verification/Badge'
38+ import { RecordWithSnapshots } from './snapshots/RecordWithSnapshots'
3839
3940export function RecordCard ( props : {
4041 uri : string
@@ -73,29 +74,50 @@ export function RecordCard(props: {
7374 }
7475 if ( parsed . collection === CollectionId . ProfileStatus ) {
7576 return (
76- < BaseRecordCard
77- uri = { uri }
78- renderRecord = { ( record ) => {
79- console . log ( record )
80- return (
81- < >
82- < RepoCard did = { parsed . did } />
83- < ProfileStatusCard
84- value = { record . value as unknown as AppBskyActorStatus . Main }
85- authorDid = { parsed . did }
86- />
87- </ >
88- )
89- } }
90- />
77+ < RecordWithSnapshots uri = { uri } className = "pl-0" >
78+ { ( selectedSnapshot ) => (
79+ < BaseRecordCard
80+ uri = { uri }
81+ fallbackRecord = {
82+ selectedSnapshot
83+ ? ( selectedSnapshot as unknown as ToolsOzoneModerationDefs . RecordViewDetail )
84+ : undefined
85+ }
86+ renderRecord = { ( record ) => {
87+ const value = selectedSnapshot
88+ ? ( selectedSnapshot . value as unknown as AppBskyActorStatus . Main )
89+ : ( record . value as unknown as AppBskyActorStatus . Main )
90+
91+ return (
92+ < >
93+ < RepoCard did = { parsed . did } />
94+ < ProfileStatusCard value = { value } authorDid = { parsed . did } />
95+ </ >
96+ )
97+ } }
98+ />
99+ ) }
100+ </ RecordWithSnapshots >
91101 )
92102 }
93103 if ( parsed ?. collection === CollectionId . Profile ) {
94104 return (
95- < BaseRecordCard
96- uri = { uri }
97- renderRecord = { ( record ) => < RepoCard did = { parsed . did } /> }
98- />
105+ < RecordWithSnapshots uri = { uri } >
106+ { ( selectedSnapshot ) => {
107+ const snapshotProfile = selectedSnapshot ?. ozoneValue ?. handle
108+ ? ( selectedSnapshot . ozoneValue as unknown as AppBskyActorDefs . ProfileViewDetailed )
109+ : undefined
110+ if ( snapshotProfile ) {
111+ return < RepoCardView did = { parsed . did } profile = { snapshotProfile } />
112+ }
113+ return (
114+ < BaseRecordCard
115+ uri = { uri }
116+ renderRecord = { ( _record ) => < RepoCard did = { parsed . did } /> }
117+ />
118+ )
119+ } }
120+ </ RecordWithSnapshots >
99121 )
100122 }
101123 return (
@@ -134,13 +156,43 @@ function PostCard({
134156 return post
135157 } ,
136158 } )
159+
137160 if ( error ) {
138161 // Temp fallback for taken-down posts, re: TODO above
139162 return (
140- < BaseRecordCard
141- uri = { uri }
142- renderRecord = { ( record ) => < GenericRecordCard { ...{ record } } /> }
143- />
163+ < RecordWithSnapshots uri = { uri } >
164+ { ( selectedSnapshot ) => {
165+ if ( selectedSnapshot ?. ozoneValue ?. thread ?. post ) {
166+ return (
167+ < PostAsCard
168+ dense
169+ showLabels = { showLabels }
170+ parent = { selectedSnapshot . ozoneValue . thread . parent }
171+ item = { { post : selectedSnapshot . ozoneValue . thread . post } }
172+ isAuthorTakendown = { isAuthorTakendown }
173+ isAuthorDeactivated = { isAuthorDeactivated }
174+ controls = { [ 'like' , 'repost' , 'workspace' ] }
175+ />
176+ )
177+ }
178+ if ( selectedSnapshot ?. value ) {
179+ return (
180+ < GenericRecordCard
181+ record = {
182+ selectedSnapshot . value as unknown as ToolsOzoneModerationDefs . RecordViewDetail
183+ }
184+ />
185+ )
186+ }
187+ return (
188+ < LoadingFailedDense
189+ className = "text-gray-600 mb-2"
190+ error = { error }
191+ noPadding
192+ />
193+ )
194+ } }
195+ </ RecordWithSnapshots >
144196 )
145197 }
146198
@@ -192,27 +244,49 @@ function PostCard({
192244 if ( ! data || ! AppBskyFeedDefs . isThreadViewPost ( data . thread ) ) {
193245 return null
194246 }
247+
248+ const thread = data . thread
249+
195250 return (
196- < PostAsCard
197- dense
198- showLabels = { showLabels }
199- parent = { data . thread . parent }
200- item = { { post : data . thread . post } }
201- isAuthorTakendown = { isAuthorTakendown }
202- isAuthorDeactivated = { isAuthorDeactivated }
203- controls = { [ 'like' , 'repost' , 'workspace' ] }
204- />
251+ < RecordWithSnapshots uri = { uri } >
252+ { ( selectedSnapshot ) => {
253+ // If a snapshot is selected, modify the post data to show the snapshot
254+ const postItem = selectedSnapshot
255+ ? {
256+ post : {
257+ ...thread . post ,
258+ cid : selectedSnapshot . cid ,
259+ record : selectedSnapshot . value ,
260+ } ,
261+ }
262+ : { post : thread . post }
263+
264+ return (
265+ < PostAsCard
266+ dense
267+ showLabels = { showLabels }
268+ parent = { thread . parent }
269+ item = { postItem }
270+ isAuthorTakendown = { isAuthorTakendown }
271+ isAuthorDeactivated = { isAuthorDeactivated }
272+ controls = { [ 'like' , 'repost' , 'workspace' ] }
273+ />
274+ )
275+ } }
276+ </ RecordWithSnapshots >
205277 )
206278}
207279
208280function BaseRecordCard ( {
209281 uri,
210282 renderRecord,
283+ fallbackRecord,
211284} : {
212285 uri : string
213286 renderRecord : (
214287 record : ToolsOzoneModerationDefs . RecordViewDetail ,
215288 ) => JSX . Element
289+ fallbackRecord ?: ToolsOzoneModerationDefs . RecordViewDetail
216290} ) {
217291 const labelerAgent = useLabelerAgent ( )
218292
@@ -227,11 +301,15 @@ function BaseRecordCard({
227301 } ,
228302 } )
229303 if ( error ) {
304+ // If we have a fallback record (e.g., from snapshot), use it instead of showing error
305+ if ( fallbackRecord ) {
306+ return renderRecord ( fallbackRecord )
307+ }
230308 return (
231309 < LoadingFailedDense
232310 className = "text-gray-600 mb-2"
233- noPadding
234311 error = { error }
312+ noPadding
235313 />
236314 )
237315 }
@@ -363,12 +441,25 @@ export function RepoCard(props: { did: string }) {
363441 const { data : { repo, profile } = { } , error } = useRepoAndProfile ( { did } )
364442
365443 if ( error ) {
444+ const profileUri = `at://${ did } /app.bsky.actor.profile/self`
366445 return (
367- < LoadingFailedDense
368- className = "text-gray-600 mb-2"
369- noPadding
370- error = { error }
371- />
446+ < RecordWithSnapshots uri = { profileUri } >
447+ { ( selectedSnapshot ) => {
448+ const snapshotProfile = selectedSnapshot ?. ozoneValue ?. handle
449+ ? ( selectedSnapshot . ozoneValue as unknown as AppBskyActorDefs . ProfileViewDetailed )
450+ : undefined
451+ if ( snapshotProfile ) {
452+ return < RepoCardView did = { did } profile = { snapshotProfile } />
453+ }
454+ return (
455+ < LoadingFailedDense
456+ className = "text-gray-600 mb-2"
457+ noPadding
458+ error = { error }
459+ />
460+ )
461+ } }
462+ </ RecordWithSnapshots >
372463 )
373464 }
374465 if ( ! repo ) {
@@ -417,9 +508,9 @@ export const RepoCardView = ({
417508 < span className = "font-bold" > { profile . displayName } </ span >
418509 < span
419510 className = "ml-1 text-gray-500 dark:text-gray-50"
420- title = { `@${ repo ?. handle || did } ` }
511+ title = { `@${ repo ?. handle || profile . handle || did } ` }
421512 >
422- @{ repo ?. handle || did }
513+ @{ repo ?. handle || profile . handle || did }
423514 </ span >
424515 < VerificationBadge
425516 className = "ml-0.5"
0 commit comments