Skip to content

Commit 1a2ef64

Browse files
committed
[core] Fixes "Open empty graph" with a selection
This commit improves the resetGraph action, to actually reset the filters, selection and appearance states as well.
1 parent d7501cd commit 1a2ef64

File tree

1 file changed

+18
-6
lines changed
  • packages/gephi-lite/src/core/graph

1 file changed

+18
-6
lines changed

packages/gephi-lite/src/core/graph/index.ts

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { APPEARANCE_ITEM_TYPES, AppearanceState, FilteredGraph, getEmptyAppearanceState } from "@gephi/gephi-lite-sdk";
1+
import {
2+
APPEARANCE_ITEM_TYPES,
3+
AppearanceState,
4+
FilteredGraph,
5+
FiltersState,
6+
getEmptyAppearanceState,
7+
} from "@gephi/gephi-lite-sdk";
28
import { MultiProducer, Producer, atom, derivedAtom, multiProducerToAction, producerToAction } from "@ouestware/atoms";
39
import EventEmitter from "events";
410
import { Attributes } from "graphology-types";
@@ -11,11 +17,12 @@ import { applyVisualProperties, getAllVisualGetters } from "../appearance/utils"
1117
import { filtersAtom } from "../filters";
1218
import { buildTopologicalFiltersDefinitions } from "../filters/topological";
1319
import { FilterType } from "../filters/types";
14-
import { applyFilters } from "../filters/utils";
20+
import { applyFilters, getEmptyFiltersState } from "../filters/utils";
1521
import { itemsRemove, searchActions, searchAtom } from "../search";
1622
import { SearchState } from "../search/types";
1723
import { selectionAtom } from "../selection";
1824
import { SelectionState } from "../selection/types";
25+
import { getEmptySelectionState } from "../selection/utils";
1926
import { ItemType } from "../types";
2027
import { computeAllDynamicAttributes, dynamicAttributes } from "./dynamicAttributes";
2128
import { DynamicItemData, FieldModel, GraphDataset, SigmaGraph } from "./types";
@@ -31,7 +38,7 @@ import {
3138

3239
/**
3340
* Producers:
34-
* **********graphToExport
41+
* **********
3542
*/
3643
const setGraphDataset: Producer<GraphDataset, [GraphDataset]> = (dataset) => {
3744
return () => dataset;
@@ -172,8 +179,13 @@ const updateEdge: Producer<GraphDataset, [string, Attributes]> = (edge, attribut
172179
};
173180
};
174181

175-
const resetGraph: Producer<GraphDataset, []> = () => {
176-
return () => getEmptyGraphDataset();
182+
const resetGraph: MultiProducer<[FiltersState, AppearanceState, SelectionState, GraphDataset], []> = () => {
183+
return [
184+
() => getEmptyFiltersState(),
185+
() => getEmptyAppearanceState(),
186+
() => getEmptySelectionState(),
187+
() => getEmptyGraphDataset(),
188+
];
177189
};
178190

179191
/**
@@ -253,7 +265,7 @@ export const graphDatasetActions = {
253265
updateEdge: producerToAction(updateEdge, graphDatasetAtom),
254266
deleteItemsAttribute: producerToAction(deleteItemsAttribute, graphDatasetAtom),
255267
deleteItems: multiProducerToAction(deleteItems, [searchAtom, selectionAtom, graphDatasetAtom]),
256-
resetGraph: producerToAction(resetGraph, graphDatasetAtom),
268+
resetGraph: multiProducerToAction(resetGraph, [filtersAtom, appearanceAtom, selectionAtom, graphDatasetAtom]),
257269
};
258270

259271
/**

0 commit comments

Comments
 (0)