Skip to content

Commit

Permalink
ensure volume layer is saved before reloading; fixes #4857
Browse files Browse the repository at this point in the history
  • Loading branch information
philippotto committed Oct 8, 2020
1 parent 20e10fd commit 76f0e51
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions frontend/javascripts/oxalis/api/api_latest.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,13 +738,18 @@ class DataApi {
/**
* Invalidates all downloaded buckets of the given layer so that they are reloaded.
*/
reloadBuckets(layerName: string): void {
_.forEach(this.model.dataLayers, dataLayer => {
async reloadBuckets(layerName: string): Promise<void> {
await Promise.all(Object.keys(this.model.dataLayers).map(async (currentLayerName) => {
const dataLayer = this.model.dataLayers[currentLayerName]
if (dataLayer.cube.isSegmentation) {
await Model.ensureSavedState();
}

if (dataLayer.name === layerName) {
dataLayer.cube.collectAllBuckets();
dataLayer.layerRenderingManager.refresh();
}
});
}));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export async function importTracingFiles(files: Array<File>, createGroupForEachF
Store.dispatch(setVersionNumberAction(oldVolumeTracing.version + 1, "volume"));
Store.dispatch(setMaxCellAction(newLargestSegmentId));
await clearCache(dataset, oldVolumeTracing.tracingId);
api.data.reloadBuckets(oldVolumeTracing.tracingId);
await api.data.reloadBuckets(oldVolumeTracing.tracingId);
window.needsRerender = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps> {

reloadLayerData = async (layerName: string): Promise<void> => {
await clearCache(this.props.dataset, layerName);
api.data.reloadBuckets(layerName);
await api.data.reloadBuckets(layerName);
window.needsRerender = true;
Toast.success(`Successfully reloaded data of layer ${layerName}.`);
};
Expand All @@ -466,7 +466,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps> {
const { layers } = this.props.datasetConfiguration;
const reloadAllLayersPromises = Object.keys(layers).map(async layerName => {
await clearCache(this.props.dataset, layerName);
api.data.reloadBuckets(layerName);
await api.data.reloadBuckets(layerName);
});
await Promise.all(reloadAllLayersPromises);
window.needsRerender = true;
Expand Down

0 comments on commit 76f0e51

Please sign in to comment.