@gallop.software/studio 0.1.107 → 0.1.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -358,7 +358,20 @@ function ProgressModal({
358
358
  " before stopping."
359
359
  ] }) : isComplete ? /* @__PURE__ */ jsxs(Fragment, { children: [
360
360
  /* @__PURE__ */ jsxs("p", { css: styles.message, children: [
361
- progress.isScan ? /* @__PURE__ */ jsxs(Fragment, { children: [
361
+ progress.isMove ? /* @__PURE__ */ jsxs(Fragment, { children: [
362
+ "Moved ",
363
+ progress.processed,
364
+ " file",
365
+ progress.processed !== 1 ? "s" : "",
366
+ ".",
367
+ progress.errors !== void 0 && progress.errors > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
368
+ " ",
369
+ progress.errors,
370
+ " error",
371
+ progress.errors !== 1 ? "s" : "",
372
+ " occurred."
373
+ ] }) : null
374
+ ] }) : progress.isScan ? /* @__PURE__ */ jsxs(Fragment, { children: [
362
375
  progress.alreadyProcessed !== void 0 && progress.alreadyProcessed > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
363
376
  progress.alreadyProcessed,
364
377
  " image",
@@ -388,13 +401,6 @@ function ProgressModal({
388
401
  " orphaned thumbnail",
389
402
  progress.orphansRemoved !== 1 ? "s" : "",
390
403
  "."
391
- ] }) : null,
392
- progress.errors !== void 0 && progress.errors > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
393
- " ",
394
- progress.errors,
395
- " error",
396
- progress.errors !== 1 ? "s" : "",
397
- " occurred."
398
404
  ] }) : null
399
405
  ] }),
400
406
  progress.errorMessages && progress.errorMessages.length > 0 && /* @__PURE__ */ jsxs("div", { css: progressStyles.errorList, children: [
@@ -2306,34 +2312,76 @@ function StudioToolbar() {
2306
2312
  setShowMoveModal(true);
2307
2313
  }, [selectedItems]);
2308
2314
  const handleMoveConfirm = useCallback2(async (destination) => {
2315
+ const paths = Array.from(selectedItems);
2316
+ setProgressTitle("Moving Files");
2317
+ setShowProgress(true);
2318
+ setProgressState({
2319
+ current: 0,
2320
+ total: paths.length,
2321
+ percent: 0,
2322
+ status: "processing"
2323
+ });
2309
2324
  try {
2310
2325
  const response = await fetch("/api/studio/move", {
2311
2326
  method: "POST",
2312
2327
  headers: { "Content-Type": "application/json" },
2313
- body: JSON.stringify({ paths: Array.from(selectedItems), destination })
2328
+ body: JSON.stringify({ paths, destination })
2314
2329
  });
2315
- const data = await response.json();
2316
- if (response.ok) {
2317
- clearSelection();
2318
- triggerRefresh();
2319
- if (data.errors && data.errors.length > 0) {
2320
- setAlertMessage({
2321
- title: "Move Completed with Errors",
2322
- message: data.errors.join("\n")
2323
- });
2330
+ if (!response.body) {
2331
+ throw new Error("No response body");
2332
+ }
2333
+ const reader = response.body.getReader();
2334
+ const decoder = new TextDecoder();
2335
+ let buffer = "";
2336
+ while (true) {
2337
+ const { done, value } = await reader.read();
2338
+ if (done) break;
2339
+ buffer += decoder.decode(value, { stream: true });
2340
+ const lines = buffer.split("\n\n");
2341
+ buffer = lines.pop() || "";
2342
+ for (const line of lines) {
2343
+ if (!line.startsWith("data: ")) continue;
2344
+ try {
2345
+ const data = JSON.parse(line.slice(6));
2346
+ if (data.type === "start") {
2347
+ setProgressState((prev) => ({ ...prev, total: data.total }));
2348
+ } else if (data.type === "progress") {
2349
+ setProgressState({
2350
+ current: data.current,
2351
+ total: data.total,
2352
+ percent: data.percent,
2353
+ currentFile: data.currentFile,
2354
+ status: "processing"
2355
+ });
2356
+ } else if (data.type === "complete") {
2357
+ setProgressState((prev) => ({
2358
+ ...prev,
2359
+ status: "complete",
2360
+ processed: data.moved,
2361
+ errors: data.errors,
2362
+ errorMessages: data.errorMessages,
2363
+ isMove: true
2364
+ }));
2365
+ clearSelection();
2366
+ triggerRefresh();
2367
+ } else if (data.type === "error") {
2368
+ setProgressState((prev) => ({
2369
+ ...prev,
2370
+ status: "error",
2371
+ errorMessage: data.message
2372
+ }));
2373
+ }
2374
+ } catch {
2375
+ }
2324
2376
  }
2325
- } else {
2326
- setAlertMessage({
2327
- title: "Move Failed",
2328
- message: data.error || "Unknown error"
2329
- });
2330
2377
  }
2331
2378
  } catch (error) {
2332
2379
  console.error("Move error:", error);
2333
- setAlertMessage({
2334
- title: "Move Failed",
2335
- message: "Failed to move items. Check console for details."
2336
- });
2380
+ setProgressState((prev) => ({
2381
+ ...prev,
2382
+ status: "error",
2383
+ errorMessage: "Failed to move items. Check console for details."
2384
+ }));
2337
2385
  }
2338
2386
  }, [selectedItems, clearSelection, triggerRefresh]);
2339
2387
  const { searchQuery, setSearchQuery } = useStudio();
@@ -5566,4 +5614,4 @@ export {
5566
5614
  StudioUI,
5567
5615
  StudioUI_default as default
5568
5616
  };
5569
- //# sourceMappingURL=StudioUI-4HMRUI6W.mjs.map
5617
+ //# sourceMappingURL=StudioUI-OFQB3F3W.mjs.map