Keep a deleted room out of the space history when leaving its page

This commit is contained in:
Coracle-Bot 2026-09-23 07:05:01 +00:00
parent b49fd0b6fd
commit bc7bc61f1f
2 changed files with 25 additions and 11 deletions

View file

@ -201,6 +201,8 @@ return a `Command`, so `.then(publish)` is usually all you need.
- Navigate with `navigate` from `app/modal.ts` rather than `goto` — an open modal owns a history - Navigate with `navigate` from `app/modal.ts` rather than `goto` — an open modal owns a history
entry, and a navigation that drops the modal gives that entry back before it pushes its own. entry, and a navigation that drops the modal gives that entry back before it pushes its own.
A plain `<a>` inside a modal goes the same way, through `ModalContainer`'s `beforeNavigate` A plain `<a>` inside a modal goes the same way, through `ModalContainer`'s `beforeNavigate`
- `navigate` is async and gives those entries back before it goes anywhere, so the page store
notifies again at the page being left — state cleared before the call has to survive that
- Pass `keepModal` to `navigate` to change the page under a modal and leave it open - Pass `keepModal` to `navigate` to change the page under a modal and leave it open
## Development Workflow ## Development Workflow

View file

@ -42,22 +42,34 @@ export const highlightedEvent = writable<string | undefined>(undefined)
// in a space. A store because it's read from markup, unlike lastChatUrl. // in a space. A store because it's read from markup, unlike lastChatUrl.
export const lastSpaceUrl = writable<string | undefined>(undefined) export const lastSpaceUrl = writable<string | undefined>(undefined)
export const setupHistory = () => // The page store notifies on a modal opening or closing as well as on a navigation, and a modal
page.subscribe($page => { // leaves the url where it is. Only a changed path is somewhere the user went, and recording an
if ($page.params.relay) { // unchanged one puts back a `lastPageBySpaceUrl` entry `forgetSpacePage` has just dropped.
const url = decodeRelay($page.params.relay) export const setupHistory = () => {
let lastPath: string | undefined
if ($page.url.pathname !== makeSpacePath(url)) { return page.subscribe($page => {
lastPageBySpaceUrl.set(url, $page.url.pathname) const path = $page.url.pathname
if (path !== lastPath) {
lastPath = path
if ($page.params.relay) {
const url = decodeRelay($page.params.relay)
if (path !== makeSpacePath(url)) {
lastPageBySpaceUrl.set(url, path)
}
lastSpaceUrl.set(url)
} }
lastSpaceUrl.set(url) if ($page.params.chat) {
} lastChatUrl = path
}
if ($page.params.chat) {
lastChatUrl = $page.url.pathname
} }
}) })
}
// Profiles // Profiles