tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
27
pulls
pipelines
update query param when toggling interaction drawer state
awarm.space
6 months ago
41a7783e
ee0a141e
+17
-1
1 changed file
expand all
collapse all
unified
split
app
lish
[did]
[publication]
[rkey]
Interactions
Interactions.tsx
+17
-1
app/lish/[did]/[publication]/[rkey]/Interactions/Interactions.tsx
···
51
51
const updatedState =
52
52
typeof update === "function" ? update(currentDocState) : update;
53
53
54
54
-
return {
54
54
+
const newState = {
55
55
...state,
56
56
[document_uri]: {
57
57
...currentDocState,
58
58
...updatedState,
59
59
},
60
60
};
61
61
+
62
62
+
// Update query parameter when drawer state changes
63
63
+
if (typeof window !== "undefined" && (updatedState.drawerOpen !== undefined || updatedState.drawer !== undefined)) {
64
64
+
const url = new URL(window.location.href);
65
65
+
const newDocState = newState[document_uri];
66
66
+
67
67
+
if (newDocState.drawerOpen && newDocState.drawer) {
68
68
+
url.searchParams.set("interactionDrawer", newDocState.drawer);
69
69
+
} else {
70
70
+
url.searchParams.delete("interactionDrawer");
71
71
+
}
72
72
+
73
73
+
window.history.replaceState({}, "", url.toString());
74
74
+
}
75
75
+
76
76
+
return newState;
61
77
});
62
78
}
63
79
export function openInteractionDrawer(