fix: stale closure on albumName, remove unused items destructure, remove dead importSharedUploadAll
This commit is contained in:
@@ -1,15 +1,6 @@
|
||||
import { IMPORT_SHARED_PATH, IMPORT_SHARED_UPLOAD_ALL_PATH } from "@/config/routes";
|
||||
import { IMPORT_SHARED_PATH } from "@/config/routes";
|
||||
import API from "@/lib/api";
|
||||
|
||||
export const importShared = async (link: string) => {
|
||||
return API.post(IMPORT_SHARED_PATH, { link });
|
||||
};
|
||||
|
||||
export const importSharedUploadAll = async (params: {
|
||||
origin: string;
|
||||
key: string;
|
||||
assets: object[];
|
||||
albumOptions: object;
|
||||
}) => {
|
||||
return API.post(IMPORT_SHARED_UPLOAD_ALL_PATH, params);
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { FormEvent, useEffect, useState } from "react";
|
||||
import React, { FormEvent, useEffect, useRef, useState } from "react";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import PageLayout from "@/components/layouts/PageLayout";
|
||||
import Header from "@/components/shared/Header";
|
||||
@@ -168,6 +168,12 @@ export default function ImportSharedPage() {
|
||||
const [activeJobId, setActiveJobId] = useState<string | null>(null);
|
||||
const [jobProgress, setJobProgress] = useState<{ uploaded: number; skipped: number; failed: number; total: number } | null>(null);
|
||||
|
||||
const albumNameRef = useRef(albumNameInput);
|
||||
|
||||
useEffect(() => {
|
||||
albumNameRef.current = albumNameInput;
|
||||
}, [albumNameInput]);
|
||||
|
||||
useEffect(() => {
|
||||
if (importAllDialogOpen) {
|
||||
listAlbums().then(setExistingAlbums).catch(console.error);
|
||||
@@ -189,7 +195,7 @@ export default function ImportSharedPage() {
|
||||
|
||||
const interval = setInterval(async () => {
|
||||
try {
|
||||
const { job, items } = await getImportJob(activeJobId);
|
||||
const { job } = await getImportJob(activeJobId);
|
||||
setJobProgress({
|
||||
uploaded: job.uploadedCount,
|
||||
skipped: job.skippedCount,
|
||||
@@ -222,7 +228,7 @@ export default function ImportSharedPage() {
|
||||
}
|
||||
|
||||
if (importData.albumId && uploadedCount > 0) {
|
||||
message = `${message} Added to album "${albumNameInput || "selected album"}".`;
|
||||
message = `${message} Added to album "${albumNameRef.current || "selected album"}".`;
|
||||
}
|
||||
|
||||
setUploadBanner({ type: bannerType, message });
|
||||
|
||||
Reference in New Issue
Block a user