Skip to content

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

fix: navigation was possible in moveNote intent

thecodrr2bd102c01626
diff --git a/apps/web/src/app.js b/apps/web/src/app.js
index e833eea2d..3d1e327fe 100644
--- a/apps/web/src/app.js
+++ b/apps/web/src/app.js
@@ -63,8 +63,8 @@ function App() {
>
{Object.values(routes).map((item, index) => (
<NavMenuItem
- onSelected={() => {
- if (navigate(item.key)) {
+ onSelected={async () => {
+ if (await navigate(item.key)) {
setSelectedIndex(index);
}
}}
diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.js
index 7d3a2da4c..86eb88508 100644
--- a/apps/web/src/components/note/index.js
+++ b/apps/web/src/components/note/index.js
@@ -12,8 +12,8 @@ const dropdownRefs = [];
const menuItems = note => [
{
title: note.notebook.notebook ? "Move" : "Add to",
- onClick: () => {
- navigate(routes.notebooks.key, undefined, {
+ onClick: async () => {
+ await navigate(routes.notebooks.key, undefined, {
intent: "moveNote",
data: note
});
diff --git a/apps/web/src/navigation/index.js b/apps/web/src/navigation/index.js
index f4f715d2f..1a7d4fe9c 100644
--- a/apps/web/src/navigation/index.js
+++ b/apps/web/src/navigation/index.js
@@ -49,7 +49,11 @@ export const navigationEvents = {
onWillNavigateAway: undefined
};
var lastRoute = undefined;
-export function navigate(routeName, root = "navigationView", params = {}) {
+export async function navigate(
+ routeName,
+ root = "navigationView",
+ params = {}
+) {
let route = routes[routeName];
// do not navigate if the previous route is the same
@@ -62,11 +66,11 @@ export function navigate(routeName, root = "navigationView", params = {}) {
if (
navigationEvents.onWillNavigateAway &&
- !navigationEvents.onWillNavigateAway(routeName, params)
+ !(await navigationEvents.onWillNavigateAway(routeName, params))
) {
- navigationEvents.onWillNavigateAway = undefined;
return false;
}
+ navigationEvents.onWillNavigateAway = undefined;
let rootView = document.querySelector(`.${root}`);
if (!rootView) return false;