Enter a space on the page it was left on or its details page
This commit is contained in:
parent
903c5cb19a
commit
c234f9f198
2 changed files with 24 additions and 15 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import {spec} from "@welshman/lib"
|
import {spec} from "@welshman/lib"
|
||||||
import type {TrustedEvent} from "@welshman/util"
|
import type {TrustedEvent} from "@welshman/util"
|
||||||
import {RelayMessageType} from "@welshman/net"
|
import {RelayMessageType} from "@welshman/net"
|
||||||
import {expect, getTranscript, roomPath, spacePath, test, users} from "../harness"
|
import {expect, getTranscript, pathPattern, roomPath, spacePath, test, users} from "../harness"
|
||||||
|
|
||||||
test("keeps two spaces' contents on their own relays", async ({seed, as}) => {
|
test("keeps two spaces' contents on their own relays", async ({seed, as}) => {
|
||||||
const scenario = await seed(({relay, user}) => {
|
const scenario = await seed(({relay, user}) => {
|
||||||
|
|
@ -182,3 +182,23 @@ test("switches spaces inside the space menu without closing it", async ({seed, a
|
||||||
await expect(page).toHaveURL(new RegExp(`${roomPath(other.url, "garden")}$`))
|
await expect(page).toHaveURL(new RegExp(`${roomPath(other.url, "garden")}$`))
|
||||||
await expect(drawer).toHaveCount(0)
|
await expect(drawer).toHaveCount(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("enters a space on its details page whatever its relay advertises", async ({seed, as}) => {
|
||||||
|
const scenario = await seed(({relay, user}) => {
|
||||||
|
const space = relay("space")
|
||||||
|
|
||||||
|
space.room("lounge", {name: "Space Lounge"})
|
||||||
|
space.join(user.alice, "lounge")
|
||||||
|
})
|
||||||
|
|
||||||
|
const space = scenario.space("space")
|
||||||
|
|
||||||
|
// A relay whose document claims no nip-29. The entry path used to read that as "open the chat
|
||||||
|
// page", which a cold load could never get right: the document arrives after the first
|
||||||
|
// navigation, so a space opened on chat and corrected itself to about a moment later.
|
||||||
|
const relayInfo = {[space.url]: {supported_nips: [1, 11, 42]}}
|
||||||
|
const page = await as(users.alice, spacePath(space.url), {relayInfo})
|
||||||
|
|
||||||
|
await expect(page).toHaveURL(pathPattern(spacePath(space.url) + "/about"))
|
||||||
|
await expect(page.locator('[data-component="PageBar"]')).toContainText("Space Details")
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import {
|
||||||
tagValue,
|
tagValue,
|
||||||
tagValues,
|
tagValues,
|
||||||
} from "@welshman/util"
|
} from "@welshman/util"
|
||||||
import {app, messagingRelayLists, relays, user} from "@app/core"
|
import {app, messagingRelayLists, user} from "@app/core"
|
||||||
import {makeChatId} from "@app/chats"
|
import {makeChatId} from "@app/chats"
|
||||||
import {entityLink, PLATFORM_URL, PLATFORM_RELAYS} from "@app/env"
|
import {entityLink, PLATFORM_URL, PLATFORM_RELAYS} from "@app/env"
|
||||||
import {decodeRelay, encodeRelay} from "@app/relays"
|
import {decodeRelay, encodeRelay} from "@app/relays"
|
||||||
|
|
@ -95,19 +95,8 @@ export const makeSpacePath = (url: string, ...extra: (string | undefined)[]) =>
|
||||||
|
|
||||||
export const forgetSpacePage = (url: string) => lastPageBySpaceUrl.delete(url)
|
export const forgetSpacePage = (url: string) => lastPageBySpaceUrl.delete(url)
|
||||||
|
|
||||||
export const makeSpaceEntryPath = (url: string) => {
|
export const makeSpaceEntryPath = (url: string) =>
|
||||||
const prevPath = lastPageBySpaceUrl.get(url)
|
lastPageBySpaceUrl.get(url) ?? makeSpacePath(url, "about")
|
||||||
|
|
||||||
if (prevPath) {
|
|
||||||
return prevPath
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!relays.get().get(url)?.hasNip(29)) {
|
|
||||||
return makeSpaceChatPath(url)
|
|
||||||
}
|
|
||||||
|
|
||||||
return makeSpacePath(url, "about")
|
|
||||||
}
|
|
||||||
|
|
||||||
export const goToSpace = (url: string, options: {replaceState?: boolean} = {}) =>
|
export const goToSpace = (url: string, options: {replaceState?: boolean} = {}) =>
|
||||||
navigate(makeSpaceEntryPath(url), options)
|
navigate(makeSpaceEntryPath(url), options)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue