Skip to content

Commit 3fc6c7b

Browse files
committed
bugs corrected in issue #101
1 parent e242772 commit 3fc6c7b

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/graph-builder/graph-core/5-load-save.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import graphmlBuilder from '../graphml/builder';
44
import BendingDistanceWeight from '../calculations/bending-dist-weight';
55
import GraphUndoRedo from './4-undo-redo';
66
import graphMLParser from '../graphml/parser';
7+
import { actionType as T } from '../../reducer';
78

89
class GraphLoadSave extends GraphUndoRedo {
910
autoSaveIntervalId
@@ -141,6 +142,10 @@ class GraphLoadSave extends GraphUndoRedo {
141142
],
142143
};
143144
const handle = await window.showSaveFilePicker(options);
145+
this.dispatcher({
146+
type: T.SET_FILE_HANDLE,
147+
payload: { curGraphIndex: this.superState.curGraphIndex, fileHandle: handle },
148+
});
144149
const stream = await handle.createWritable();
145150
await stream.write(blob);
146151
await stream.close();

src/reducer/actionType.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const actionType = {
3131
SET_EDIT_DETAILS_MODAL: 'SET_EDIT_DETAILS_MODAL',
3232
SET_NEW_GRAPH_MODAL: 'SET_NEW_GRAPH_MODAL',
3333
EDIT_TEXTFILE: 'EDIT_TEXTFILE',
34+
SET_FILE_HANDLE: 'SET_FILE_HANDLE',
3435
};
3536

3637
export default zealit(actionType);

src/reducer/reducer.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ const reducer = (state, action) => {
139139
return { ...state, fileRef: action.payload };
140140
}
141141

142+
case T.SET_FILE_HANDLE: {
143+
const newState = { ...state };
144+
newState.graphs = newState.graphs.map((g) => (
145+
newState.curGraphIndex === action.payload.curGraphIndex ? { ...g, fileHandle: action.payload.fileHandle }
146+
: g
147+
));
148+
return { ...newState };
149+
}
150+
142151
case T.SET_HISTORY_MODAL: {
143152
return { ...state, viewHistory: action.payload };
144153
}

0 commit comments

Comments
 (0)