Update upload action types
This commit is contained in:
parent
5704597a4f
commit
6ec4bfbfe8
@ -106,7 +106,7 @@ const addUpload = async ({
|
|||||||
hidden?: string
|
hidden?: string
|
||||||
takenAtLocal: string
|
takenAtLocal: string
|
||||||
takenAtNaiveLocal: string
|
takenAtNaiveLocal: string
|
||||||
onStreamUpdate: (
|
onStreamUpdate?: (
|
||||||
statusMessage: string,
|
statusMessage: string,
|
||||||
status?: UrlAddStatus['status'],
|
status?: UrlAddStatus['status'],
|
||||||
) => void
|
) => void
|
||||||
@ -125,7 +125,7 @@ const addUpload = async ({
|
|||||||
|
|
||||||
if (formDataFromExif) {
|
if (formDataFromExif) {
|
||||||
if (AI_TEXT_GENERATION_ENABLED) {
|
if (AI_TEXT_GENERATION_ENABLED) {
|
||||||
onStreamUpdate('Generating AI text');
|
onStreamUpdate?.('Generating AI text');
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -154,7 +154,7 @@ const addUpload = async ({
|
|||||||
takenAtNaive: formDataFromExif.takenAtNaive || takenAtNaiveLocal,
|
takenAtNaive: formDataFromExif.takenAtNaive || takenAtNaiveLocal,
|
||||||
};
|
};
|
||||||
|
|
||||||
onStreamUpdate('Transferring to photo storage');
|
onStreamUpdate?.('Transferring to photo storage');
|
||||||
|
|
||||||
const updatedUrl = await convertUploadToPhoto({
|
const updatedUrl = await convertUploadToPhoto({
|
||||||
urlOrigin: url,
|
urlOrigin: url,
|
||||||
@ -163,18 +163,23 @@ const addUpload = async ({
|
|||||||
});
|
});
|
||||||
if (updatedUrl) {
|
if (updatedUrl) {
|
||||||
const subheadFinal = 'Adding to database';
|
const subheadFinal = 'Adding to database';
|
||||||
onStreamUpdate(subheadFinal);
|
onStreamUpdate?.(subheadFinal);
|
||||||
const photo =
|
const photo =
|
||||||
await convertFormDataToPhotoDbInsertAndLookupRecipeTitle(form);
|
await convertFormDataToPhotoDbInsertAndLookupRecipeTitle(form);
|
||||||
photo.url = updatedUrl;
|
photo.url = updatedUrl;
|
||||||
await insertPhoto(photo);
|
await insertPhoto(photo);
|
||||||
onFinish?.(url);
|
onFinish?.(url);
|
||||||
// Re-submit with updated url
|
// Re-submit with updated url
|
||||||
onStreamUpdate(subheadFinal, 'added');
|
onStreamUpdate?.(subheadFinal, 'added');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const addUploadAction = async (args: Parameters<typeof addUpload>[0]) =>
|
||||||
|
runAuthenticatedAdminServerAction(async () => {
|
||||||
|
await addUpload(args);
|
||||||
|
});
|
||||||
|
|
||||||
export const addUploadsAction = async ({
|
export const addUploadsAction = async ({
|
||||||
uploadUrls,
|
uploadUrls,
|
||||||
uploadTitles,
|
uploadTitles,
|
||||||
@ -184,7 +189,10 @@ export const addUploadsAction = async ({
|
|||||||
hidden,
|
hidden,
|
||||||
takenAtLocal,
|
takenAtLocal,
|
||||||
takenAtNaiveLocal,
|
takenAtNaiveLocal,
|
||||||
}: Parameters<typeof addUpload>[0] & {
|
}: Omit<
|
||||||
|
Parameters<typeof addUpload>[0],
|
||||||
|
'url' | 'onStreamUpdate' | 'onFinish'
|
||||||
|
> & {
|
||||||
uploadUrls: string[]
|
uploadUrls: string[]
|
||||||
uploadTitles: string[]
|
uploadTitles: string[]
|
||||||
shouldRevalidateAllKeysAndPaths?: boolean
|
shouldRevalidateAllKeysAndPaths?: boolean
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user