Avoid unnecessary color collection when syncing outdated photos
This commit is contained in:
parent
e7e8174093
commit
379228cc03
@ -72,8 +72,8 @@ export default function PhotoSyncButton({
|
||||
) {
|
||||
setIsSyncing(true);
|
||||
(onlySyncColorData
|
||||
? storeColorDataForPhotoAction
|
||||
: syncPhotoAction)(photo.id)
|
||||
? storeColorDataForPhotoAction(photo.id)
|
||||
: syncPhotoAction(photo.id, { updateMode }))
|
||||
.then(() => {
|
||||
onSyncComplete?.();
|
||||
if (shouldToast) {
|
||||
|
||||
@ -491,7 +491,15 @@ export const getExifDataAction = async (
|
||||
// - strip GPS data if necessary
|
||||
// - update blur data (or destroy if blur is disabled)
|
||||
// - generate AI text data, if enabled, and auto-generated fields are empty
|
||||
export const syncPhotoAction = async (photoId: string, isBatch?: boolean) =>
|
||||
export const syncPhotoAction = async (
|
||||
photoId: string, {
|
||||
isBatch,
|
||||
updateMode,
|
||||
}: {
|
||||
isBatch?: boolean,
|
||||
updateMode?: boolean,
|
||||
} = {},
|
||||
) =>
|
||||
runAuthenticatedAdminServerAction(async () => {
|
||||
const photo = await getPhoto(photoId ?? '', true);
|
||||
|
||||
@ -505,6 +513,12 @@ export const syncPhotoAction = async (photoId: string, isBatch?: boolean) =>
|
||||
includeInitialPhotoFields: false,
|
||||
generateBlurData: BLUR_ENABLED,
|
||||
generateResizedImage: AI_CONTENT_GENERATION_ENABLED,
|
||||
// If in update mode, only update color fields if necessary
|
||||
updateColorFields: !(
|
||||
updateMode &&
|
||||
photo.colorData !== undefined &&
|
||||
photo.colorSort !== undefined
|
||||
),
|
||||
});
|
||||
|
||||
let urlToDelete: string | undefined;
|
||||
@ -575,7 +589,7 @@ export const syncPhotosAction = async (photosToSync: {
|
||||
for (const { photoId, onlySyncColorData } of photosToSync) {
|
||||
await (onlySyncColorData
|
||||
? storeColorDataForPhotoAction(photoId)
|
||||
: syncPhotoAction(photoId, true));
|
||||
: syncPhotoAction(photoId, { isBatch: true }));
|
||||
}
|
||||
revalidateAllKeysAndPaths();
|
||||
});
|
||||
|
||||
@ -34,11 +34,16 @@ const IMAGE_WIDTH_DEFAULT = 200;
|
||||
const IMAGE_QUALITY_DEFAULT = 80;
|
||||
|
||||
export const extractImageDataFromBlobPath = async (
|
||||
blobPath: string,
|
||||
options: {
|
||||
blobPath: string, {
|
||||
includeInitialPhotoFields,
|
||||
generateBlurData,
|
||||
generateResizedImage,
|
||||
updateColorFields = true,
|
||||
}: {
|
||||
includeInitialPhotoFields?: boolean
|
||||
generateBlurData?: boolean
|
||||
generateResizedImage?: boolean
|
||||
updateColorFields?: boolean
|
||||
} = {},
|
||||
): Promise<{
|
||||
blobId?: string
|
||||
@ -48,12 +53,6 @@ export const extractImageDataFromBlobPath = async (
|
||||
fileBytes?: ArrayBuffer
|
||||
error?: string
|
||||
}> => {
|
||||
const {
|
||||
includeInitialPhotoFields,
|
||||
generateBlurData,
|
||||
generateResizedImage,
|
||||
} = options;
|
||||
|
||||
const url = decodeURIComponent(blobPath);
|
||||
|
||||
const {
|
||||
@ -119,7 +118,9 @@ export const extractImageDataFromBlobPath = async (
|
||||
|
||||
if (error) { console.log(error); }
|
||||
|
||||
const colorFields = await getColorFieldsForPhotoForm(url);
|
||||
const colorFields = updateColorFields
|
||||
? await getColorFieldsForPhotoForm(url)
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
blobId,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user