Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: bring editor session context support

thecodrr4aa9c0fe4cf0
diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.js
index 45384e1c6..9c0284393 100644
--- a/apps/web/src/stores/editor-store.js
+++ b/apps/web/src/stores/editor-store.js
@@ -80,11 +80,14 @@ function editorStore(set, get) {
}, 500);
});
},
- newSession: function() {
+ newSession: function(context = {}) {
set(state => {
clearTimeout(state.session.timeout);
- state.session = DEFAULT_SESSION;
- state.session.state = SESSION_STATES.new;
+ state.session = {
+ ...DEFAULT_SESSION,
+ ...context,
+ state: SESSION_STATES.new
+ };
});
},
setColor: function(color) {
diff --git a/apps/web/src/views/Notes.js b/apps/web/src/views/Notes.js
index 466f78b96..bdf1c3523 100644
--- a/apps/web/src/views/Notes.js
+++ b/apps/web/src/views/Notes.js
@@ -1,21 +1,23 @@
import React from "react";
import Note from "../components/note";
import ListContainer from "../components/list-container";
+import { useStore } from "../stores/editor-store";
const Notes = props => {
+ const newSession = useStore(store => store.newSession);
return (
<ListContainer
item={index => <Note index={index} item={props.notes[index]} />}
itemsLength={props.notes.length}
button={{
content: "Make a new note",
- onClick: () => {}
- /* sendNewNoteEvent({
+ onClick: () =>
+ newSession({
colors: [],
tags: [],
notebook: {},
...props.context
- }) */
+ })
}}
/>
);