Reopen the last DM that was open when navigating back to chat
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {Snippet} from "svelte"
|
import type {Snippet} from "svelte"
|
||||||
import {goto} from "$app/navigation"
|
|
||||||
import {splitAt} from "@welshman/lib"
|
import {splitAt} from "@welshman/lib"
|
||||||
import {userProfile} from "@welshman/app"
|
import {userProfile} from "@welshman/app"
|
||||||
import Widget from "@assets/icons/widget.svg?dataurl"
|
import Widget from "@assets/icons/widget.svg?dataurl"
|
||||||
@@ -19,6 +18,7 @@
|
|||||||
import {userSpaceUrls, PLATFORM_RELAYS, PLATFORM_LOGO} from "@app/core/state"
|
import {userSpaceUrls, PLATFORM_RELAYS, PLATFORM_LOGO} from "@app/core/state"
|
||||||
import {pushModal} from "@app/util/modal"
|
import {pushModal} from "@app/util/modal"
|
||||||
import {notifications} from "@app/util/notifications"
|
import {notifications} from "@app/util/notifications"
|
||||||
|
import {goToLastChat} from "@app/util/routes"
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
children?: Snippet
|
children?: Snippet
|
||||||
@@ -28,8 +28,6 @@
|
|||||||
|
|
||||||
const showSettingsMenu = () => pushModal(MenuSettings)
|
const showSettingsMenu = () => pushModal(MenuSettings)
|
||||||
|
|
||||||
const openChat = () => goto("/chat")
|
|
||||||
|
|
||||||
let windowHeight = $state(0)
|
let windowHeight = $state(0)
|
||||||
|
|
||||||
const itemHeight = 56
|
const itemHeight = 56
|
||||||
@@ -85,7 +83,7 @@
|
|||||||
</PrimaryNavItem>
|
</PrimaryNavItem>
|
||||||
<PrimaryNavItem
|
<PrimaryNavItem
|
||||||
title="Messages"
|
title="Messages"
|
||||||
onclick={openChat}
|
onclick={goToLastChat}
|
||||||
class="tooltip-right"
|
class="tooltip-right"
|
||||||
notification={$notifications.has("/chat")}>
|
notification={$notifications.has("/chat")}>
|
||||||
<ImageIcon alt="Messages" src={Letter} size={8} />
|
<ImageIcon alt="Messages" src={Letter} size={8} />
|
||||||
@@ -112,7 +110,7 @@
|
|||||||
</PrimaryNavItem>
|
</PrimaryNavItem>
|
||||||
<PrimaryNavItem
|
<PrimaryNavItem
|
||||||
title="Messages"
|
title="Messages"
|
||||||
onclick={openChat}
|
onclick={goToLastChat}
|
||||||
notification={$notifications.has("/chat")}>
|
notification={$notifications.has("/chat")}>
|
||||||
<ImageIcon alt="Messages" src={Letter} size={8} />
|
<ImageIcon alt="Messages" src={Letter} size={8} />
|
||||||
</PrimaryNavItem>
|
</PrimaryNavItem>
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
import {page} from "$app/stores"
|
import {page} from "$app/stores"
|
||||||
|
|
||||||
export const lastPageBySpaceUrl = new Map<string, string>()
|
export const lastPageBySpaceUrl = new Map<string, string>()
|
||||||
|
export let lastChatUrl: string | undefined = undefined
|
||||||
|
|
||||||
export const setupHistory = () =>
|
export const setupHistory = () =>
|
||||||
page.subscribe($page => {
|
page.subscribe($page => {
|
||||||
if ($page.params.relay) {
|
if ($page.params.relay) {
|
||||||
lastPageBySpaceUrl.set($page.params.relay, $page.url.pathname)
|
lastPageBySpaceUrl.set($page.params.relay, $page.url.pathname)
|
||||||
}
|
}
|
||||||
|
if ($page.params.chat) {
|
||||||
|
lastChatUrl = $page.url.pathname
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import {
|
|||||||
DM_KINDS,
|
DM_KINDS,
|
||||||
ROOM,
|
ROOM,
|
||||||
} from "@app/core/state"
|
} 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)[]) => {
|
export const makeSpacePath = (url: string, ...extra: (string | undefined)[]) => {
|
||||||
let path = `/spaces/${encodeRelay(url)}`
|
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 makeChatPath = (pubkeys: string[]) => `/chat/${makeChatId(pubkeys)}`
|
||||||
|
|
||||||
export const makeRoomPath = (url: string, h: string) => `/spaces/${encodeRelay(url)}/${h}`
|
export const makeRoomPath = (url: string, h: string) => `/spaces/${encodeRelay(url)}/${h}`
|
||||||
|
|||||||
Reference in New Issue
Block a user