WIP PWA for Grain
0
fork

Configure Feed

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

fix: delete gallery items and photos when deleting gallery

Previously only the gallery record was deleted, leaving orphaned
gallery items and photos. Now deletes all associated records.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+55 -5
+15 -5
src/services/grain-api.js
··· 231 231 socialGrainGalleryItemViaGallery(first: 50, sortBy: [{ field: position, direction: ASC }]) { 232 232 edges { 233 233 node { 234 + uri 234 235 itemResolved { 235 236 ... on SocialGrainPhoto { 236 237 uri ··· 273 274 274 275 const profile = galleryNode.socialGrainActorProfileByDid; 275 276 276 - const photos = galleryNode.socialGrainGalleryItemViaGallery?.edges 277 - ?.map(edge => edge.node?.itemResolved) 278 - ?.filter(Boolean) 279 - ?.map(photo => ({ 277 + const galleryItems = galleryNode.socialGrainGalleryItemViaGallery?.edges 278 + ?.map(edge => edge.node) 279 + ?.filter(Boolean) || []; 280 + 281 + const photos = galleryItems 282 + .map(item => item.itemResolved) 283 + .filter(Boolean) 284 + .map(photo => ({ 280 285 uri: photo.uri, 281 286 url: photo.photo?.url || '', 282 287 alt: photo.alt || '', 283 288 aspectRatio: photo.aspectRatio 284 289 ? photo.aspectRatio.width / photo.aspectRatio.height 285 290 : 1 286 - })) || []; 291 + })); 292 + 293 + const galleryItemUris = galleryItems.map(item => item.uri).filter(Boolean); 294 + const photoUris = photos.map(p => p.uri).filter(Boolean); 287 295 288 296 const comments = galleryNode.socialGrainCommentViaSubject?.edges?.map(edge => ({ 289 297 text: edge.node.text, ··· 300 308 displayName: profile?.displayName || '', 301 309 avatarUrl: profile?.avatar?.url || '', 302 310 photos, 311 + galleryItemUris, 312 + photoUris, 303 313 favoriteCount: galleryNode.socialGrainFavoriteViaSubject?.totalCount || 0, 304 314 commentCount: galleryNode.socialGrainCommentViaSubject?.totalCount || 0, 305 315 comments