Skip to content

Commit 7e938ae

Browse files
Copilotlstein
andcommitted
Await Plotly operations to keep spinner visible during rendering
Co-authored-by: lstein <[email protected]>
1 parent 566c101 commit 7e938ae

File tree

1 file changed

+7
-7
lines changed
  • photomap/frontend/static/javascript

1 file changed

+7
-7
lines changed

photomap/frontend/static/javascript/umap.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ export async function colorizeUmap({ highlight = false, searchResults = [] } = {
478478
const highlightedPoints = points.filter((p) => searchSet.has(p.index));
479479

480480
// Update main trace with only regular points
481-
Plotly.restyle(
481+
await Plotly.restyle(
482482
"umapPlot",
483483
{
484484
x: [regularPoints.map((p) => p.x)],
@@ -511,9 +511,9 @@ export async function colorizeUmap({ highlight = false, searchResults = [] } = {
511511
};
512512

513513
if (highlightTraceIdx === -1) {
514-
Plotly.addTraces(plotDiv, [highlightTrace]);
514+
await Plotly.addTraces(plotDiv, [highlightTrace]);
515515
} else {
516-
Plotly.restyle(
516+
await Plotly.restyle(
517517
plotDiv,
518518
{
519519
x: [highlightTrace.x],
@@ -530,21 +530,21 @@ export async function colorizeUmap({ highlight = false, searchResults = [] } = {
530530
// Ensure Current Image marker stays on top
531531
const markerTraceIndex = plotDiv.data.findIndex((trace) => trace.name === "Current Image");
532532
if (markerTraceIndex !== -1 && markerTraceIndex !== plotDiv.data.length - 1) {
533-
Plotly.moveTraces(plotDiv, markerTraceIndex, plotDiv.data.length - 1);
533+
await Plotly.moveTraces(plotDiv, markerTraceIndex, plotDiv.data.length - 1);
534534
}
535535
} else {
536536
// Remove highlight trace if it exists
537537
const highlightTraceIdx = plotDiv.data?.findIndex((t) => t.name === "HighlightedPoints");
538538
if (highlightTraceIdx !== -1) {
539-
Plotly.deleteTraces(plotDiv, highlightTraceIdx);
539+
await Plotly.deleteTraces(plotDiv, highlightTraceIdx);
540540
}
541541

542542
// Restore ALL points to main trace with normal coloring
543543
const markerColors = points.map((p) => getClusterColor(p.cluster));
544544
const markerAlphas = points.map((p) => (p.cluster === -1 ? 0.2 : 0.75));
545545
const markerSizes = points.map(() => 5);
546546

547-
Plotly.restyle(
547+
await Plotly.restyle(
548548
"umapPlot",
549549
{
550550
x: [points.map((p) => p.x)],
@@ -561,7 +561,7 @@ export async function colorizeUmap({ highlight = false, searchResults = [] } = {
561561
// Ensure Current Image marker stays on top after removing highlight
562562
const markerTraceIndex = plotDiv.data.findIndex((trace) => trace.name === "Current Image");
563563
if (markerTraceIndex !== -1 && markerTraceIndex !== plotDiv.data.length - 1) {
564-
Plotly.moveTraces(plotDiv, markerTraceIndex, plotDiv.data.length - 1);
564+
await Plotly.moveTraces(plotDiv, markerTraceIndex, plotDiv.data.length - 1);
565565
}
566566
}
567567
}

0 commit comments

Comments
 (0)