Add global delete photo tag action
This commit is contained in:
parent
52fe191d98
commit
3c913c273f
2
src/cache/index.ts
vendored
2
src/cache/index.ts
vendored
@ -19,7 +19,7 @@ import { Camera, createCameraKey } from '@/camera';
|
||||
|
||||
const TAG_PHOTOS = 'photos';
|
||||
const TAG_PHOTOS_COUNT = `${TAG_PHOTOS}-count`;
|
||||
const TAG_PHOTOS_DATE_RANGE = `${TAG_PHOTOS}-date-range`;;
|
||||
const TAG_PHOTOS_DATE_RANGE = `${TAG_PHOTOS}-date-range`;
|
||||
const TAG_TAGS = 'tags';
|
||||
const TAG_CAMERAS = 'cameras';
|
||||
const TAG_BLOB = 'blob';
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
import {
|
||||
sqlDeletePhoto,
|
||||
sqlInsertPhoto,
|
||||
sqlDeletePhotoTagGlobally,
|
||||
sqlUpdatePhoto,
|
||||
} from '@/services/postgres';
|
||||
import { convertFormDataToPhoto } from './form';
|
||||
@ -62,6 +63,14 @@ export async function deletePhotoAction(formData: FormData) {
|
||||
revalidatePhotosTag();
|
||||
};
|
||||
|
||||
export async function deletePhotoTagGloballyAction(formData: FormData) {
|
||||
const tag = formData.get('tag') as string;
|
||||
|
||||
await sqlDeletePhotoTagGlobally(tag);
|
||||
|
||||
revalidatePhotosTag();
|
||||
}
|
||||
|
||||
export async function deleteBlobPhotoAction(formData: FormData) {
|
||||
await deleteBlobPhoto(formData.get('url') as string);
|
||||
|
||||
|
||||
@ -132,7 +132,7 @@ export const sqlUpdatePhoto = (photo: PhotoDbInsert) =>
|
||||
WHERE id=${photo.id}
|
||||
`;
|
||||
|
||||
export const sqlRemovePhotoTag = (tag: string) =>
|
||||
export const sqlDeletePhotoTagGlobally = (tag: string) =>
|
||||
sql`
|
||||
UPDATE photos
|
||||
SET tags=array_remove(tags, ${tag})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user