fix: stale closure on albumName, remove unused items destructure, remove dead importSharedUploadAll

This commit is contained in:
Varun
2026-04-03 20:22:56 +05:30
parent 06536e2699
commit a640fe6555
2 changed files with 10 additions and 13 deletions
+1 -10
View File
@@ -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);
};
+9 -3
View File
@@ -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 });