a tool for shared writing and social publishing

update query param when toggling interaction drawer state

+17 -1
+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 - return { 54 + const newState = { 55 55 ...state, 56 56 [document_uri]: { 57 57 ...currentDocState, 58 58 ...updatedState, 59 59 }, 60 60 }; 61 + 62 + // Update query parameter when drawer state changes 63 + if (typeof window !== "undefined" && (updatedState.drawerOpen !== undefined || updatedState.drawer !== undefined)) { 64 + const url = new URL(window.location.href); 65 + const newDocState = newState[document_uri]; 66 + 67 + if (newDocState.drawerOpen && newDocState.drawer) { 68 + url.searchParams.set("interactionDrawer", newDocState.drawer); 69 + } else { 70 + url.searchParams.delete("interactionDrawer"); 71 + } 72 + 73 + window.history.replaceState({}, "", url.toString()); 74 + } 75 + 76 + return newState; 61 77 }); 62 78 } 63 79 export function openInteractionDrawer(