mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
fix: navigation was possible in moveNote intent
This commit is contained in:
@@ -63,8 +63,8 @@ function App() {
|
|||||||
>
|
>
|
||||||
{Object.values(routes).map((item, index) => (
|
{Object.values(routes).map((item, index) => (
|
||||||
<NavMenuItem
|
<NavMenuItem
|
||||||
onSelected={() => {
|
onSelected={async () => {
|
||||||
if (navigate(item.key)) {
|
if (await navigate(item.key)) {
|
||||||
setSelectedIndex(index);
|
setSelectedIndex(index);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ const dropdownRefs = [];
|
|||||||
const menuItems = note => [
|
const menuItems = note => [
|
||||||
{
|
{
|
||||||
title: note.notebook.notebook ? "Move" : "Add to",
|
title: note.notebook.notebook ? "Move" : "Add to",
|
||||||
onClick: () => {
|
onClick: async () => {
|
||||||
navigate(routes.notebooks.key, undefined, {
|
await navigate(routes.notebooks.key, undefined, {
|
||||||
intent: "moveNote",
|
intent: "moveNote",
|
||||||
data: note
|
data: note
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -49,7 +49,11 @@ export const navigationEvents = {
|
|||||||
onWillNavigateAway: undefined
|
onWillNavigateAway: undefined
|
||||||
};
|
};
|
||||||
var lastRoute = undefined;
|
var lastRoute = undefined;
|
||||||
export function navigate(routeName, root = "navigationView", params = {}) {
|
export async function navigate(
|
||||||
|
routeName,
|
||||||
|
root = "navigationView",
|
||||||
|
params = {}
|
||||||
|
) {
|
||||||
let route = routes[routeName];
|
let route = routes[routeName];
|
||||||
|
|
||||||
// do not navigate if the previous route is the same
|
// do not navigate if the previous route is the same
|
||||||
@@ -62,11 +66,11 @@ export function navigate(routeName, root = "navigationView", params = {}) {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
navigationEvents.onWillNavigateAway &&
|
navigationEvents.onWillNavigateAway &&
|
||||||
!navigationEvents.onWillNavigateAway(routeName, params)
|
!(await navigationEvents.onWillNavigateAway(routeName, params))
|
||||||
) {
|
) {
|
||||||
navigationEvents.onWillNavigateAway = undefined;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
navigationEvents.onWillNavigateAway = undefined;
|
||||||
|
|
||||||
let rootView = document.querySelector(`.${root}`);
|
let rootView = document.querySelector(`.${root}`);
|
||||||
if (!rootView) return false;
|
if (!rootView) return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user