From 2c94ced77ece7ec31e65ccb594da112b13c35165 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sat, 11 Oct 2025 00:20:14 +0200 Subject: [PATCH] navigation for discussions updated --- src/PageManager.tsx | 10 +++++++- src/components/Note/index.tsx | 23 +++++++++++++------ .../NotificationItem/index.tsx | 11 --------- src/components/NotificationList/index.tsx | 17 +------------- src/providers/NotificationProvider.tsx | 8 ------- 5 files changed, 26 insertions(+), 43 deletions(-) diff --git a/src/PageManager.tsx b/src/PageManager.tsx index 7c69c91..13ca4fa 100644 --- a/src/PageManager.tsx +++ b/src/PageManager.tsx @@ -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 }) { 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 diff --git a/src/components/Note/index.tsx b/src/components/Note/index.tsx index f5dfd47..932ed1a 100644 --- a/src/components/Note/index.tsx +++ b/src/components/Note/index.tsx @@ -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({ 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({
{event.kind === ExtendedKind.DISCUSSION && ( - + > + + + )} {size === 'normal' && ( diff --git a/src/components/NotificationList/NotificationItem/index.tsx b/src/components/NotificationList/NotificationItem/index.tsx index 2a13484..f929b82 100644 --- a/src/components/NotificationList/NotificationItem/index.tsx +++ b/src/components/NotificationList/NotificationItem/index.tsx @@ -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 }, [ diff --git a/src/components/NotificationList/index.tsx b/src/components/NotificationList/index.tsx index b43235c..6c0ca88 100644 --- a/src/components/NotificationList/index.tsx +++ b/src/components/NotificationList/index.tsx @@ -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) => { } }, onNew: (event) => { - console.log('📋 NotificationList onNew event:', { - id: event.id, - kind: event.kind, - pubkey: event.pubkey, - content: event.content.substring(0, 30) + '...' - }) handleNewEvent(event) } } diff --git a/src/providers/NotificationProvider.tsx b/src/providers/NotificationProvider.tsx index 96bbea6..c36c0d4 100644 --- a/src/providers/NotificationProvider.tsx +++ b/src/providers/NotificationProvider.tsx @@ -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]