Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | 92x 92x 91x 91x 91x 91x 91x 91x | import {
AddPhotoToGalleryReq,
GetGalleryEditInfoReq,
GetGalleryReq,
MovePhotoReq,
RemovePhotoFromGalleryReq,
UpdatePhotoCaptionReq,
} from "proto/galleries_pb";
import client from "./client";
/**
* Get a gallery by ID
*/
export async function getGallery(galleryId: number) {
const req = new GetGalleryReq();
req.setGalleryId(galleryId);
const response = await client.galleries.getGallery(req);
return response.toObject();
}
/**
* Get edit info for a gallery (only available to gallery owner)
*/
export async function getGalleryEditInfo(galleryId: number) {
const req = new GetGalleryEditInfoReq();
req.setGalleryId(galleryId);
const response = await client.galleries.getGalleryEditInfo(req);
return response.toObject();
}
/**
* Add a photo to a gallery
*/
export async function addPhotoToGallery(
galleryId: number,
uploadKey: string,
caption?: string,
) {
const req = new AddPhotoToGalleryReq();
req.setGalleryId(galleryId);
req.setUploadKey(uploadKey);
Iif (caption) {
req.setCaption(caption);
}
const response = await client.galleries.addPhotoToGallery(req);
return response.toObject();
}
/**
* Remove a photo from a gallery
*/
export async function removePhotoFromGallery(
galleryId: number,
itemId: number,
) {
const req = new RemovePhotoFromGalleryReq();
req.setGalleryId(galleryId);
req.setItemId(itemId);
const response = await client.galleries.removePhotoFromGallery(req);
return response.toObject();
}
/**
* Move a photo to a new position in the gallery
* @param afterItemId - ID of the photo to place after, or 0 to move to first position
*/
export async function movePhoto(
galleryId: number,
itemId: number,
afterItemId: number,
) {
const req = new MovePhotoReq();
req.setGalleryId(galleryId);
req.setItemId(itemId);
req.setAfterItemId(afterItemId);
const response = await client.galleries.movePhoto(req);
return response.toObject();
}
/**
* Update the caption of a photo
*/
export async function updatePhotoCaption(
galleryId: number,
itemId: number,
caption: string,
) {
const req = new UpdatePhotoCaptionReq();
req.setGalleryId(galleryId);
req.setItemId(itemId);
req.setCaption(caption);
const response = await client.galleries.updatePhotoCaption(req);
return response.toObject();
}
|