Skip to content

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

fix: dialog search param causing issues with locked note

thecodrr645d2415c1cd
diff --git a/apps/web/src/components/dialogs/dialog.js b/apps/web/src/components/dialogs/dialog.js
index df5a9161b..55f72d1ab 100644
--- a/apps/web/src/components/dialogs/dialog.js
+++ b/apps/web/src/components/dialogs/dialog.js
@@ -152,7 +152,7 @@ export function showDialog(dialog) {
if (!getHashParam("type")) perform(false);
}
- setHashParam({ type: "dialog" });
+ setHashParam({ type: "dialog" }, true, true, true);
const PropDialog = dialog(perform);
ReactDOM.render(<ThemeProvider>{PropDialog}</ThemeProvider>, root);
diff --git a/apps/web/src/utils/useHashParam.js b/apps/web/src/utils/useHashParam.js
index 9b5b810d0..3d185332b 100644
--- a/apps/web/src/utils/useHashParam.js
+++ b/apps/web/src/utils/useHashParam.js
@@ -13,10 +13,15 @@ const getHashParam = (key) => {
return searchParams.get(key);
};
-const setHashParam = (obj, notify = true) => {
- //const [prefix, searchParams] = getHashSearchParams();
- const searchParams = new URLSearchParams();
- const prefix = "";
+const setHashParam = (
+ obj,
+ notify = true,
+ append = false,
+ forcePush = false
+) => {
+ const [prefix, searchParams] = append
+ ? getHashSearchParams()
+ : ["", new URLSearchParams()];
for (let key in obj) {
let value = obj[key];
@@ -26,7 +31,7 @@ const setHashParam = (obj, notify = true) => {
const search = searchParams.toString();
let hash = search ? `${prefix}?${search}` : prefix;
if (window.history.replaceState) {
- if (isMobile()) {
+ if (isMobile() || forcePush) {
window.history.pushState(null, null, `#${hash}`);
} else {
window.history.replaceState(null, null, `#${hash}`);