Skip to content

Commit

Permalink
Don't throw error when neighbors haven't been loaded yet
Browse files Browse the repository at this point in the history
  • Loading branch information
venkatesh-sivaraman committed Jan 6, 2022
1 parent bafe6ea commit 2bf2787
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@
/>
</div>
<div class="sidebar-content">
{#if $visibleSidebarPane == SidebarPanes.CURRENT && !!$thumbnailData}
{#if $visibleSidebarPane == SidebarPanes.CURRENT && !!$thumbnailData && !!$neighborData}
<DefaultThumbnailViewer
on:thumbnailClick={handleThumbnailClick}
on:thumbnailHover={handleThumbnailHover}
Expand Down
2 changes: 2 additions & 0 deletions src/visualization/models/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { transformPoint } from '../utils/helpers.js';
import {
ColumnarData,
ColumnarFrame,
emptyNeighborData,
FramePreview,
NeighborPreview,
Neighbors,
Expand Down Expand Up @@ -51,6 +52,7 @@ export class Dataset {
this.frameCount = frameSource.length;
this.hasPreviews = !!this.previews;
this.reformat(frameSource);
this.setNeighbors(this.frames.map((f) => emptyNeighborData(f.getIDs())));
}

reformat(rawData) {
Expand Down
8 changes: 8 additions & 0 deletions src/visualization/models/frames.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,14 @@ export class Neighbors extends ColumnarData {
}
}

// Returns a data object that can be read by Neighbors to produce a placeholder
// when neighbors are not yet loaded
export function emptyNeighborData(ids) {
let result = {};
ids.forEach((id) => (result[id] = { neighbors: [] }));
return result;
}

// Previews

const PREVIEW_LINE_SCHEMA = {
Expand Down

0 comments on commit 2bf2787

Please sign in to comment.