fix: 🐛

This commit is contained in:
codytseng
2025-01-17 23:11:27 +08:00
parent ed2a21a51f
commit b2f111a4e7
4 changed files with 19 additions and 4 deletions

View File

@@ -275,7 +275,7 @@ function isCurrentPage(stack: TStackItem[], url: string) {
}
function findAndCreateComponent(url: string, index: number) {
const path = url.split('?')[0]
const path = url.split('?')[0].split('#')[0]
for (const { matcher, element } of routes) {
const match = matcher(path)
if (!match) continue

View File

@@ -31,7 +31,7 @@ export default function FeedSwitcher({ close }: { close?: () => void }) {
<div className="flex justify-between px-2">
<div className="text-muted-foreground text-sm font-semibold">{t('relay sets')}</div>
<SecondaryPageLink
to={toRelaySettings()}
to={toRelaySettings('relay-sets')}
className="text-highlight text-sm font-semibold"
onClick={() => close?.()}
>

View File

@@ -32,7 +32,9 @@ export const toOthersRelaySettings = (pubkey: string) => {
const npub = nip19.npubEncode(pubkey)
return `/users/${npub}/relays`
}
export const toRelaySettings = () => '/relay-settings'
export const toRelaySettings = (tag?: 'mailbox' | 'relay-sets') => {
return '/relay-settings' + (tag === 'relay-sets' ? '#relay-sets' : '')
}
export const toSettings = () => '/settings'
export const toProfileEditor = () => '/profile-editor'
export const toRelay = (url: string) => `/relays/${encodeURIComponent(url)}`

View File

@@ -2,14 +2,27 @@ import MailboxSetting from '@/components/MailboxSetting'
import RelaySetsSetting from '@/components/RelaySetsSetting'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
import SecondaryPageLayout from '@/layouts/SecondaryPageLayout'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
export default function RelaySettingsPage({ index }: { index?: number }) {
const { t } = useTranslation()
const [tabValue, setTabValue] = useState('mailbox')
useEffect(() => {
if (window.location.hash === '#relay-sets') {
setTabValue('relay-sets')
}
}, [])
return (
<SecondaryPageLayout index={index} title={t('Relay settings')}>
<Tabs defaultValue="mailbox" className="px-4 space-y-4">
<Tabs
defaultValue="mailbox"
value={tabValue}
onValueChange={setTabValue}
className="px-4 space-y-4"
>
<TabsList>
<TabsTrigger value="mailbox">{t('Read & Write Relays')}</TabsTrigger>
<TabsTrigger value="relay-sets">{t('Relay Sets')}</TabsTrigger>