Skip to content

Commit

Permalink
Verify context before saving
Browse files Browse the repository at this point in the history
  • Loading branch information
canmingir committed Jul 1, 2024
1 parent f218838 commit c1dba66
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/context/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { storage } from "@nucleoidjs/webstorage";
import { v4 as uuid } from "uuid";

function contextReducer(context, { type, payload }) {
const { id } = storage.get("ide", "selected", "context");
const { project } = storage.get("ide", "context", id);
context = Context.copy(context);

const { specification, pages } = context;
Expand Down Expand Up @@ -544,7 +542,13 @@ function contextReducer(context, { type, payload }) {
default:
}

service.saveContext({ project, specification });
const selectedContext = storage.get("ide", "selected", "context");

if (selectedContext) {
const { project } = storage.get("ide", "context", selectedContext.id);
service.saveContext({ project, specification });
}

console.debug("contextReducer", type, context);
return context;
}
Expand Down

0 comments on commit c1dba66

Please sign in to comment.