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

Merged
hodlbod merged 1 commits from feature/60-go-back-to-previous-chat into dev 2026-02-19 18:31:54 +00:00
3 changed files with 12 additions and 6 deletions
+3 -5
View File
@@ -1,6 +1,5 @@
<script lang="ts">
import type {Snippet} from "svelte"
import {goto} from "$app/navigation"
import {splitAt} from "@welshman/lib"
import {userProfile} from "@welshman/app"
import Widget from "@assets/icons/widget.svg?dataurl"
@@ -19,6 +18,7 @@
import {userSpaceUrls, PLATFORM_RELAYS, PLATFORM_LOGO} from "@app/core/state"
import {pushModal} from "@app/util/modal"
import {notifications} from "@app/util/notifications"
import {goToLastChat} from "@app/util/routes"
type Props = {
children?: Snippet
@@ -28,8 +28,6 @@
const showSettingsMenu = () => pushModal(MenuSettings)
const openChat = () => goto("/chat")
let windowHeight = $state(0)
const itemHeight = 56
@@ -85,7 +83,7 @@
</PrimaryNavItem>
<PrimaryNavItem
title="Messages"
onclick={openChat}
onclick={goToLastChat}
class="tooltip-right"
notification={$notifications.has("/chat")}>
<ImageIcon alt="Messages" src={Letter} size={8} />
@@ -112,7 +110,7 @@
</PrimaryNavItem>
<PrimaryNavItem
title="Messages"
onclick={openChat}
onclick={goToLastChat}
notification={$notifications.has("/chat")}>
<ImageIcon alt="Messages" src={Letter} size={8} />
</PrimaryNavItem>
+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}`