Browse Source

navigation for discussions updated

imwald
Silberengel 5 months ago
parent
commit
2c94ced77e
  1. 10
      src/PageManager.tsx
  2. 23
      src/components/Note/index.tsx
  3. 11
      src/components/NotificationList/NotificationItem/index.tsx
  4. 17
      src/components/NotificationList/index.tsx
  5. 8
      src/providers/NotificationProvider.tsx

10
src/PageManager.tsx

@ -258,8 +258,14 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { @@ -258,8 +258,14 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) {
}
const pushSecondaryPage = (url: string, index?: number) => {
console.log('🔗 pushSecondaryPage called with:', url)
setSecondaryStack((prevStack) => {
if (isCurrentPage(prevStack, url)) {
console.log('🔗 Current stack:', prevStack.map(item => ({ url: item.url, index: item.index })))
const isCurrent = isCurrentPage(prevStack, url)
console.log('🔗 Is current page?', isCurrent)
if (isCurrent) {
console.log('🔗 URL is current page, scrolling to top instead of navigating')
const currentItem = prevStack[prevStack.length - 1]
if (currentItem?.ref?.current) {
currentItem.ref.current.scrollToTop('instant')
@ -267,8 +273,10 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { @@ -267,8 +273,10 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) {
return prevStack
}
console.log('🔗 Creating new page for URL:', url)
const { newStack, newItem } = pushNewPageToStack(prevStack, url, maxStackSize, index)
if (newItem) {
console.log('🔗 Pushing to history:', url)
window.history.pushState({ index: newItem.index, url }, '', url)
}
return newStack

23
src/components/Note/index.tsx

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import { usePrimaryPage, useSecondaryPage } from '@/PageManager'
import { useSecondaryPage } from '@/PageManager'
import { ExtendedKind, SUPPORTED_KINDS } from '@/constants'
import { getParentBech32Id, isNsfwEvent } from '@/lib/event'
import { toNote } from '@/lib/link'
@ -50,7 +50,6 @@ export default function Note({ @@ -50,7 +50,6 @@ export default function Note({
showFull?: boolean
}) {
const { push } = useSecondaryPage()
const { navigate } = usePrimaryPage()
const { isSmallScreen } = useScreenSize()
const parentEventId = useMemo(
() => (hideParentNotePreview ? undefined : getParentBech32Id(event)),
@ -150,16 +149,26 @@ export default function Note({ @@ -150,16 +149,26 @@ export default function Note({
</div>
<div className="flex items-center gap-1">
{event.kind === ExtendedKind.DISCUSSION && (
<button
<>
{console.log('🔍 Discussion button should render:', { eventKind: event.kind, discussionKind: ExtendedKind.DISCUSSION })}
<button
className="p-1 hover:bg-muted rounded transition-colors"
onClick={(e) => {
e.stopPropagation()
navigate('discussions')
console.log('🔗 View in Discussions clicked:', {
eventId: event.id,
eventKind: event.kind,
noteUrl: toNote(event)
})
console.log('🔗 About to call push with:', toNote(event))
push(toNote(event))
console.log('🔗 Push called successfully')
}}
title="View in Discussions"
>
<MessageSquare className="w-4 h-4 text-blue-500" />
</button>
>
<MessageSquare className="w-4 h-4 text-blue-500" />
</button>
</>
)}
<TranslateButton event={event} className={size === 'normal' ? '' : 'pr-0'} />
{size === 'normal' && (

11
src/components/NotificationList/NotificationItem/index.tsx

@ -34,17 +34,6 @@ export function NotificationItem({ @@ -34,17 +34,6 @@ export function NotificationItem({
isUserTrusted
})
if (notification.kind === 11) {
console.log('🔍 Discussion notification filter result:', {
id: notification.id,
kind: notification.kind,
canShow: result,
pubkey: notification.pubkey,
isMuted: mutePubkeySet.has(notification.pubkey),
hideUntrusted: hideUntrustedNotifications,
isTrusted: isUserTrusted(notification.pubkey)
})
}
return result
}, [

17
src/components/NotificationList/index.tsx

@ -155,16 +155,7 @@ const NotificationList = forwardRef((_, ref) => { @@ -155,16 +155,7 @@ const NotificationList = forwardRef((_, ref) => {
{
onEvents: (events, eosed) => {
if (events.length > 0) {
console.log('📋 NotificationList received events:', events.map(e => ({
id: e.id,
kind: e.kind,
pubkey: e.pubkey,
content: e.content.substring(0, 30) + '...'
})))
const filteredEvents = events.filter((event) => event.pubkey !== pubkey)
console.log('📋 After filtering own events:', filteredEvents.length, 'events')
setNotifications(filteredEvents)
setNotifications(events.filter((event) => event.pubkey !== pubkey))
}
if (eosed) {
setLoading(false)
@ -173,12 +164,6 @@ const NotificationList = forwardRef((_, ref) => { @@ -173,12 +164,6 @@ const NotificationList = forwardRef((_, ref) => {
}
},
onNew: (event) => {
console.log('📋 NotificationList onNew event:', {
id: event.id,
kind: event.kind,
pubkey: event.pubkey,
content: event.content.substring(0, 30) + '...'
})
handleNewEvent(event)
}
}

8
src/providers/NotificationProvider.tsx

@ -129,14 +129,6 @@ export function NotificationProvider({ children }: { children: React.ReactNode } @@ -129,14 +129,6 @@ export function NotificationProvider({ children }: { children: React.ReactNode }
onevent: (evt) => {
// Don't notify about our own threads
if (evt.pubkey !== pubkey) {
console.log('📢 Discussion notification received:', {
id: evt.id,
pubkey: evt.pubkey,
kind: evt.kind,
content: evt.content.substring(0, 50) + '...',
topics: evt.tags.filter(tag => tag[0] === 't').map(tag => tag[1])
})
setNewNotifications((prev) => {
if (!discussionEosed) {
return [evt, ...prev]

Loading…
Cancel
Save