grain.social is a photo sharing platform built on atproto.

feat: update gallery state to require item, itemCreatedAt, and itemPosition; modify related functions to utilize new properties

Changed files
+26 -7
__generated__
types
social
grain
photo
lexicons
social
grain
photo
src
+8
__generated__/lexicons.ts
··· 3783 3783 }, 3784 3784 galleryState: { 3785 3785 type: 'object', 3786 + required: ['item', 'itemCreatedAt', 'itemPosition'], 3786 3787 description: 3787 3788 "Metadata about the photo's relationship with the subject content. Only has meaningful content when photo is attached to a gallery.", 3788 3789 properties: { 3789 3790 item: { 3790 3791 type: 'string', 3791 3792 format: 'at-uri', 3793 + }, 3794 + itemCreatedAt: { 3795 + type: 'string', 3796 + format: 'datetime', 3797 + }, 3798 + itemPosition: { 3799 + type: 'integer', 3792 3800 }, 3793 3801 }, 3794 3802 },
+3 -1
__generated__/types/social/grain/photo/defs.ts
··· 71 71 /** Metadata about the photo's relationship with the subject content. Only has meaningful content when photo is attached to a gallery. */ 72 72 export interface GalleryState { 73 73 $type?: 'social.grain.photo.defs#galleryState' 74 - item?: string 74 + item: string 75 + itemCreatedAt: string 76 + itemPosition: number 75 77 } 76 78 77 79 const hashGalleryState = 'galleryState'
+4 -1
lexicons/social/grain/photo/defs.json
··· 56 56 }, 57 57 "galleryState": { 58 58 "type": "object", 59 + "required": ["item", "itemCreatedAt", "itemPosition"], 59 60 "description": "Metadata about the photo's relationship with the subject content. Only has meaningful content when photo is attached to a gallery.", 60 61 "properties": { 61 - "item": { "type": "string", "format": "at-uri" } 62 + "item": { "type": "string", "format": "at-uri" }, 63 + "itemCreatedAt": { "type": "string", "format": "datetime" }, 64 + "itemPosition": { "type": "integer" } 62 65 } 63 66 } 64 67 }
+3 -3
src/lib/gallery.ts
··· 25 25 import { photoToView } from "./photo.ts"; 26 26 27 27 type PhotoWithMeta = WithBffMeta<Photo> & { 28 - galleryItemUri?: string; 28 + item?: WithBffMeta<GalleryItem>; 29 29 exif?: WithBffMeta<PhotoExif>; 30 30 }; 31 31 ··· 90 90 // Attach the galleryItem uri as itemUri 91 91 galleryPhotosMap.get(galleryUri)?.push({ 92 92 ...photo, 93 - galleryItemUri: item.uri, 93 + item, 94 94 }); 95 95 } 96 96 } ··· 252 252 }, 253 253 ): Un$Typed<PhotoView> | undefined { 254 254 if (isPhoto(item)) { 255 - return photoToView(did, item, item.exif, item.galleryItemUri); 255 + return photoToView(did, item, item.exif, item.item); 256 256 } 257 257 return undefined; 258 258 }
+8 -2
src/lib/photo.ts
··· 40 40 did: string, 41 41 photo: WithBffMeta<Photo>, 42 42 exif?: WithBffMeta<PhotoExif>, 43 - galleryItemUri?: string, 43 + item?: WithBffMeta<GalleryItem>, 44 44 ): $Typed<PhotoView> { 45 45 return { 46 46 $type: "social.grain.photo.defs#photoView", ··· 51 51 alt: photo.alt, 52 52 aspectRatio: photo.aspectRatio, 53 53 exif: exif ? exifToView(exif) : undefined, 54 - gallery: galleryItemUri ? { item: galleryItemUri } : undefined, 54 + gallery: item 55 + ? { 56 + item: item.uri, 57 + itemPosition: item.position, 58 + itemCreatedAt: item.createdAt, 59 + } 60 + : undefined, 55 61 }; 56 62 } 57 63