Skip to content

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

fix: clear notes context when navigating to home

thecodrra5f55fbf22ec
diff --git a/apps/web/src/stores/note-store.js b/apps/web/src/stores/note-store.js
index 623d2c6d2..92792e25e 100644
--- a/apps/web/src/stores/note-store.js
+++ b/apps/web/src/stores/note-store.js
@@ -45,6 +45,12 @@ class NoteStore extends BaseStore {
this.setContext(context);
};
+ clearContext = () => {
+ this.set((state) => {
+ state.context = undefined;
+ });
+ };
+
setContext = (context) => {
db.notes.init().then(() => {
this.set((state) => {
diff --git a/apps/web/src/views/home.js b/apps/web/src/views/home.js
index 62afd6cc8..5ab858db7 100644
--- a/apps/web/src/views/home.js
+++ b/apps/web/src/views/home.js
@@ -4,10 +4,15 @@ import ListContainer from "../components/list-container";
import NotesPlaceholder from "../components/placeholders/notesplacholder";
import { db } from "../common/db";
import { hashNavigate } from "../navigation";
+import useNavigate from "../utils/use-navigate";
function Home() {
const notes = useStore((store) => store.notes);
+ const clearContext = useStore((store) => store.clearContext);
const [isLoading, setIsLoading] = useState(true);
+ useNavigate("home", () => {
+ clearContext();
+ });
useEffect(() => {
(async function () {