mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +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) => (
|
||||
<NavMenuItem
|
||||
onSelected={() => {
|
||||
if (navigate(item.key)) {
|
||||
onSelected={async () => {
|
||||
if (await navigate(item.key)) {
|
||||
setSelectedIndex(index);
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -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
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user