Keep a deleted room out of the space history when leaving its page
This commit is contained in:
parent
b49fd0b6fd
commit
bc7bc61f1f
2 changed files with 25 additions and 11 deletions
|
|
@ -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
|
||||
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`
|
||||
- `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
|
||||
|
||||
## Development Workflow
|
||||
|
|
|
|||
|
|
@ -42,22 +42,34 @@ export const highlightedEvent = writable<string | undefined>(undefined)
|
|||
// in a space. A store because it's read from markup, unlike lastChatUrl.
|
||||
export const lastSpaceUrl = writable<string | undefined>(undefined)
|
||||
|
||||
export const setupHistory = () =>
|
||||
page.subscribe($page => {
|
||||
if ($page.params.relay) {
|
||||
const url = decodeRelay($page.params.relay)
|
||||
// The page store notifies on a modal opening or closing as well as on a navigation, and a modal
|
||||
// leaves the url where it is. Only a changed path is somewhere the user went, and recording an
|
||||
// unchanged one puts back a `lastPageBySpaceUrl` entry `forgetSpacePage` has just dropped.
|
||||
export const setupHistory = () => {
|
||||
let lastPath: string | undefined
|
||||
|
||||
if ($page.url.pathname !== makeSpacePath(url)) {
|
||||
lastPageBySpaceUrl.set(url, $page.url.pathname)
|
||||
return page.subscribe($page => {
|
||||
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 = $page.url.pathname
|
||||
if ($page.params.chat) {
|
||||
lastChatUrl = path
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Profiles
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue