Skip to content

Commit de41e02

Browse files
committed
Removed graph IDs from url
1 parent 425d7f4 commit de41e02

2 files changed

Lines changed: 27 additions & 30 deletions

File tree

src/GraphArea.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import React, { useEffect, useRef, useState } from 'react';
2-
import path from 'path';
32
import { edgeValidator, nodeValidator } from './config/defaultValidators';
43
import MyGraph from './graph-builder';
54
import { actionType as T } from './reducer';
65

76
function Graph({
8-
el, superState, dispatcher, graphID, serverID, graphML, projectName, graphContainerRef, active, loaded,
7+
el, superState, dispatcher, graphID, serverID, graphML, projectName, graphContainerRef, active,
98
}) {
109
const [instance, setInstance] = useState(null);
1110
const ref = useRef();

src/GraphWorkspace.jsx

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import Graph from './GraphArea';
1010
const GraphComp = (props) => {
1111
const graphContainerRef = React.useRef();
1212
const { dispatcher, superState } = props;
13-
const [loadedFromStorage, setLoadedFromStorage] = React.useState(false);
14-
const [loadedFromURL, setLoadedFromURL] = React.useState(false);
13+
// const [loadedFromStorage, setLoadedFromStorage] = React.useState(false);
1514

1615
useEffect(() => {
1716
const allSavedGs = localStorageManager.getAllGraphs().map((graphID) => ({
@@ -21,33 +20,33 @@ const GraphComp = (props) => {
2120
type: T.ADD_GRAPH_BULK,
2221
payload: allSavedGs,
2322
});
24-
setLoadedFromStorage(true);
23+
// setLoadedFromStorage(true);
2524
}, []);
2625

27-
useEffect(() => {
28-
if (!loadedFromStorage) return;
29-
const graphFromParams = Object.fromEntries(new URLSearchParams(window.location.search).entries()).g;
30-
if (graphFromParams) {
31-
const graphContent = JSON.parse(window.atob(graphFromParams));
32-
const gid = new Date().getTime().toString();
33-
localStorageManager.addToFront(gid);
34-
localStorageManager.save(gid, graphContent);
35-
window.history.replaceState({}, document.title, window.location.pathname);
36-
dispatcher({ type: T.ADD_GRAPH, payload: { graphID: gid } });
37-
}
38-
const urlParms = window.location.pathname.split('/');
39-
const serverIDIndex = urlParms.indexOf('s');
40-
const localIDIndex = urlParms.indexOf('l');
41-
if (serverIDIndex !== -1 && serverIDIndex + 1 < urlParms.length) {
42-
const serverID = urlParms[serverIDIndex + 1];
43-
dispatcher({ type: T.ADD_GRAPH, payload: { serverID } });
44-
}
45-
if (localIDIndex !== -1 && localIDIndex + 1 < urlParms.length) {
46-
const graphID = urlParms[localIDIndex + 1];
47-
dispatcher({ type: T.ADD_GRAPH, payload: { graphID } });
48-
}
49-
setLoadedFromURL(true);
50-
}, [loadedFromStorage]);
26+
// Remote server implementation - Not being used.
27+
// useEffect(() => {
28+
// if (!loadedFromStorage) return;
29+
// const graphFromParams = Object.fromEntries(new URLSearchParams(window.location.search).entries()).g;
30+
// if (graphFromParams) {
31+
// const graphContent = JSON.parse(window.atob(graphFromParams));
32+
// const gid = new Date().getTime().toString();
33+
// localStorageManager.addToFront(gid);
34+
// localStorageManager.save(gid, graphContent);
35+
// window.history.replaceState({}, document.title, window.location.pathname);
36+
// dispatcher({ type: T.ADD_GRAPH, payload: { graphID: gid } });
37+
// }
38+
// const urlParms = window.location.pathname.split('/');
39+
// const serverIDIndex = urlParms.indexOf('s');
40+
// const localIDIndex = urlParms.indexOf('l');
41+
// if (serverIDIndex !== -1 && serverIDIndex + 1 < urlParms.length) {
42+
// const serverID = urlParms[serverIDIndex + 1];
43+
// dispatcher({ type: T.ADD_GRAPH, payload: { serverID } });
44+
// }
45+
// if (localIDIndex !== -1 && localIDIndex + 1 < urlParms.length) {
46+
// const graphID = urlParms[localIDIndex + 1];
47+
// dispatcher({ type: T.ADD_GRAPH, payload: { graphID } });
48+
// }
49+
// }, [loadedFromStorage]);
5150

5251
return (
5352
<div
@@ -73,7 +72,6 @@ const GraphComp = (props) => {
7372
serverID={el.serverID}
7473
graphML={el.graphML}
7574
projectName={el.projectName}
76-
loaded={loadedFromURL}
7775
/>
7876
))}
7977
<ZoomComp dispatcher={dispatcher} superState={superState} />

0 commit comments

Comments
 (0)