Fix dialog navigation by making navigate() async

This commit is contained in:
Petar Petrov 2024-12-11 11:56:32 +02:00
parent e4fc21c991
commit 142e674020

View File

@ -16,28 +16,32 @@ export interface NavigateOptions {
export const navigate = (path: string, options?: NavigateOptions) => { export const navigate = (path: string, options?: NavigateOptions) => {
const replace = options?.replace || false; const replace = options?.replace || false;
if (__DEMO__) { setTimeout(() => {
if (replace) { if (__DEMO__) {
if (replace) {
mainWindow.history.replaceState(
mainWindow.history.state?.root
? { root: true }
: (options?.data ?? null),
"",
`${mainWindow.location.pathname}#${path}`
);
} else {
mainWindow.location.hash = path;
}
} else if (replace) {
mainWindow.history.replaceState( mainWindow.history.replaceState(
mainWindow.history.state?.root mainWindow.history.state?.root
? { root: true } ? { root: true }
: (options?.data ?? null), : (options?.data ?? null),
"", "",
`${mainWindow.location.pathname}#${path}` path
); );
} else { } else {
mainWindow.location.hash = path; mainWindow.history.pushState(options?.data ?? null, "", path);
} }
} else if (replace) { fireEvent(mainWindow, "location-changed", {
mainWindow.history.replaceState( replace,
mainWindow.history.state?.root ? { root: true } : (options?.data ?? null), });
"",
path
);
} else {
mainWindow.history.pushState(options?.data ?? null, "", path);
}
fireEvent(mainWindow, "location-changed", {
replace,
}); });
}; };