Reopen the last DM that was open when navigating back to chat (#81)

#60

Co-authored-by: mplorentz <mplorentz@users.noreply.github.com>
Reviewed-on: #81
Co-authored-by: Matt Lorentz <mplorentz@noreply.coracle.social>
Co-committed-by: Matt Lorentz <mplorentz@noreply.coracle.social>
This commit is contained in:
2026-02-19 18:31:54 +00:00
committed by Jon Staab
parent 482121db5c
commit bc864b29f8
3 changed files with 12 additions and 6 deletions
+4
View File
@@ -1,10 +1,14 @@
import {page} from "$app/stores"
export const lastPageBySpaceUrl = new Map<string, string>()
export let lastChatUrl: string | undefined = undefined
export const setupHistory = () =>
page.subscribe($page => {
if ($page.params.relay) {
lastPageBySpaceUrl.set($page.params.relay, $page.url.pathname)
}
if ($page.params.chat) {
lastChatUrl = $page.url.pathname
}
})
+5 -1
View File
@@ -27,7 +27,7 @@ import {
DM_KINDS,
ROOM,
} from "@app/core/state"
import {lastPageBySpaceUrl} from "@app/util/history"
import {lastPageBySpaceUrl, lastChatUrl} from "@app/util/history"
export const makeSpacePath = (url: string, ...extra: (string | undefined)[]) => {
let path = `/spaces/${encodeRelay(url)}`
@@ -56,6 +56,10 @@ export const goToSpace = async (url: string) => {
}
}
export const goToLastChat = () => {
goto(lastChatUrl ?? "/chat")
}
export const makeChatPath = (pubkeys: string[]) => `/chat/${makeChatId(pubkeys)}`
export const makeRoomPath = (url: string, h: string) => `/spaces/${encodeRelay(url)}/${h}`