forked from coracle/flotilla
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: coracle/flotilla#81 Co-authored-by: Matt Lorentz <mplorentz@noreply.coracle.social> Co-committed-by: Matt Lorentz <mplorentz@noreply.coracle.social>
This commit is contained in:
@@ -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
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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}`
|
||||
|
||||
Reference in New Issue
Block a user