From 5a9129e046bb334d8ab182386a661bdc5981dfe9 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sun, 24 May 2026 12:02:14 +0200 Subject: [PATCH] bug-fixes --- src/components/NoteList/index.tsx | 4 ++-- src/components/PaytoLink/index.tsx | 2 +- src/components/Profile/ProfileFeed.tsx | 4 ++-- src/hooks/useProfileReportsEvents.tsx | 4 ++-- src/hooks/useProfileTimeline.tsx | 4 ++-- src/hooks/useProfileWall.tsx | 4 ++-- src/i18n/locales/cs.ts | 2 +- src/i18n/locales/de.ts | 2 +- src/i18n/locales/en.ts | 2 +- src/i18n/locales/es.ts | 2 +- src/i18n/locales/fr.ts | 2 +- src/i18n/locales/nl.ts | 2 +- src/i18n/locales/pl.ts | 2 +- src/i18n/locales/ru.ts | 2 +- src/i18n/locales/tr.ts | 2 +- src/i18n/locales/zh.ts | 2 +- src/providers/DeletedEventProvider.tsx | 14 ++++++++++++++ 17 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/components/NoteList/index.tsx b/src/components/NoteList/index.tsx index 4e0918be..8236176f 100644 --- a/src/components/NoteList/index.tsx +++ b/src/components/NoteList/index.tsx @@ -34,7 +34,7 @@ import { useFeedAttestedSuperchatIds } from '@/hooks/useFeedAttestedSuperchatIds import { shouldIncludePaymentInFeed } from '@/lib/superchat' import { isTouchDevice } from '@/lib/utils' import { useContentPolicyOptional } from '@/providers/ContentPolicyProvider' -import { useDeletedEvent } from '@/providers/DeletedEventProvider' +import { useDeletedEventSafe } from '@/providers/DeletedEventProvider' import { useMuteList } from '@/contexts/mute-list-context' import { muteSetHas } from '@/lib/mute-set' import { useNostr } from '@/providers/NostrProvider' @@ -858,7 +858,7 @@ const NoteList = forwardRef( const isOffline = contentPolicy?.isOffline ?? (!navigator.onLine || (navigator as Navigator & { connection?: { type?: string } }).connection?.type === 'none') - const { isEventDeleted } = useDeletedEvent() + const { isEventDeleted } = useDeletedEventSafe() const { favoriteRelays, blockedRelays } = useFavoriteRelays() const [events, setEvents] = useState([]) const eventsRef = useRef([]) diff --git a/src/components/PaytoLink/index.tsx b/src/components/PaytoLink/index.tsx index 1f5837b4..5dd807ee 100644 --- a/src/components/PaytoLink/index.tsx +++ b/src/components/PaytoLink/index.tsx @@ -84,7 +84,7 @@ export default function PaytoLink({ const categoryLabel = (() => { const c = info?.category if (!c) return '' - if (c === 'bitcoin-layer') return 'Bitcoin layer' + if (c === 'bitcoin-layer') return 'Bitcoin layer (Lightning)' return c.charAt(0).toUpperCase() + c.slice(1) })() const childText = flattenPaytoLinkChildText(children) diff --git a/src/components/Profile/ProfileFeed.tsx b/src/components/Profile/ProfileFeed.tsx index 99e2b014..b3ca9941 100644 --- a/src/components/Profile/ProfileFeed.tsx +++ b/src/components/Profile/ProfileFeed.tsx @@ -7,7 +7,7 @@ import { ExtendedKind, PROFILE_FEED_KINDS, PROFILE_TIMELINE_REQ_LIMIT } from '@/ import { useProfileAuthorFeedSubRequests } from '@/hooks/useProfileAuthorFeedSubRequests' import { useProfilePins } from '@/hooks/useProfilePins' import { useKindFilterOrDefaults } from '@/providers/KindFilterProvider' -import { useDeletedEvent } from '@/providers/DeletedEventProvider' +import { useDeletedEventSafe } from '@/providers/DeletedEventProvider' import client from '@/services/client.service' import { nip19, kinds } from 'nostr-tools' import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react' @@ -20,7 +20,7 @@ const ProfileFeed = forwardRef< { pubkey: string; /** Payment methods, badges, and other author replaceables. */ onRefreshExtras?: () => void } >(({ pubkey, onRefreshExtras }, ref) => { const { t } = useTranslation() - const { isEventDeleted } = useDeletedEvent() + const { isEventDeleted } = useDeletedEventSafe() const { showKinds, showKind1OPs, showKind1Replies, showKind1111, feedKindFilterBypass } = useKindFilterOrDefaults() const profileTimelineShowKinds = useMemo(() => { diff --git a/src/hooks/useProfileReportsEvents.tsx b/src/hooks/useProfileReportsEvents.tsx index b5bfaace..99884383 100644 --- a/src/hooks/useProfileReportsEvents.tsx +++ b/src/hooks/useProfileReportsEvents.tsx @@ -7,7 +7,7 @@ import { isReportAuthoredBy, reportTargetsPubkey } from '@/lib/nip56-reports' import { normalizeHexPubkey } from '@/lib/pubkey' import { dedupeNormalizeRelayUrlsOrdered } from '@/lib/relay-url-priority' import { normalizeAnyRelayUrl, subtractNormalizedRelayUrls } from '@/lib/url' -import { useDeletedEvent } from '@/providers/DeletedEventProvider' +import { useDeletedEventSafe } from '@/providers/DeletedEventProvider' import { useFavoriteRelays } from '@/providers/FavoriteRelaysProvider' import { useNostrOptional } from '@/providers/nostr-context' import client from '@/services/client.service' @@ -80,7 +80,7 @@ export function useProfileReportsEvents({ const { favoriteRelays, blockedRelays } = useFavoriteRelays() const useGlobalRelayBootstrap = useGlobalRelayBootstrapDefaults() const nostr = useNostrOptional() - const { isEventDeleted, tombstoneEpoch } = useDeletedEvent() + const { isEventDeleted, tombstoneEpoch } = useDeletedEventSafe() const isEventDeletedRef = useRef(isEventDeleted) isEventDeletedRef.current = isEventDeleted diff --git a/src/hooks/useProfileTimeline.tsx b/src/hooks/useProfileTimeline.tsx index 31146d86..73b918fc 100644 --- a/src/hooks/useProfileTimeline.tsx +++ b/src/hooks/useProfileTimeline.tsx @@ -1,4 +1,4 @@ -import { useDeletedEvent } from '@/providers/DeletedEventProvider' +import { useDeletedEventSafe } from '@/providers/DeletedEventProvider' import client, { eventService } from '@/services/client.service' import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { Event, kinds as nostrKinds, type Filter } from 'nostr-tools' @@ -158,7 +158,7 @@ export function useProfileTimeline({ () => relayListsContentKey(favoriteRelays, blockedRelays), [favoriteRelays, blockedRelays] ) - const { isEventDeleted, tombstoneEpoch } = useDeletedEvent() + const { isEventDeleted, tombstoneEpoch } = useDeletedEventSafe() const isEventDeletedRef = useRef(isEventDeleted) isEventDeletedRef.current = isEventDeleted diff --git a/src/hooks/useProfileWall.tsx b/src/hooks/useProfileWall.tsx index 2652465c..379b3607 100644 --- a/src/hooks/useProfileWall.tsx +++ b/src/hooks/useProfileWall.tsx @@ -35,7 +35,7 @@ import { isValidPubkey, userIdToPubkey } from '@/lib/pubkey' import { normalizeAnyRelayUrl } from '@/lib/url' import { useFavoriteRelays } from '@/providers/FavoriteRelaysProvider' import type { TSubRequestFilter } from '@/types' -import { useDeletedEvent } from '@/providers/DeletedEventProvider' +import { useDeletedEventSafe } from '@/providers/DeletedEventProvider' import client, { replaceableEventService } from '@/services/client.service' import { ReplaceableEventService } from '@/services/client-replaceable-events.service' import indexedDb from '@/services/indexed-db.service' @@ -263,7 +263,7 @@ function relayListsContentKey(favoriteRelays: string[], blockedRelays: string[]) export function useProfileWall(pubkey: string, profileEventId: string | undefined) { const { favoriteRelays, blockedRelays } = useFavoriteRelays() const useGlobalRelayBootstrap = useGlobalRelayBootstrapDefaults() - const { isEventDeleted } = useDeletedEvent() + const { isEventDeleted } = useDeletedEventSafe() const isEventDeletedRef = useRef(isEventDeleted) isEventDeletedRef.current = isEventDeleted diff --git a/src/i18n/locales/cs.ts b/src/i18n/locales/cs.ts index 0bc1801e..b3153bb7 100644 --- a/src/i18n/locales/cs.ts +++ b/src/i18n/locales/cs.ts @@ -675,7 +675,7 @@ export default { 'Show all categories': 'Show all categories', 'Other payment categories ({{count}})': 'Other payment categories ({{count}})', 'paytoCategory.bitcoin': 'Bitcoin', - 'paytoCategory.bitcoin-layer': 'Bitcoin layer', + 'paytoCategory.bitcoin-layer': 'Bitcoin layer (Lightning)', 'paytoCategory.monero': 'Monero', 'paytoCategory.crypto': 'Crypto', 'paytoCategory.stablecoin': 'Stablecoin', diff --git a/src/i18n/locales/de.ts b/src/i18n/locales/de.ts index 0bf0174e..d8eeb2f3 100644 --- a/src/i18n/locales/de.ts +++ b/src/i18n/locales/de.ts @@ -683,7 +683,7 @@ export default { 'Show all categories': 'Alle Kategorien anzeigen', 'Other payment categories ({{count}})': 'Weitere Zahlungskategorien ({{count}})', 'paytoCategory.bitcoin': 'Bitcoin', - 'paytoCategory.bitcoin-layer': 'Bitcoin-Layer', + 'paytoCategory.bitcoin-layer': 'Bitcoin-Layer (Lightning)', 'paytoCategory.monero': 'Monero', 'paytoCategory.crypto': 'Krypto', 'paytoCategory.stablecoin': 'Stablecoin', diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index 5e437fb1..6f1e836a 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -673,7 +673,7 @@ export default { 'Show all categories': 'Show all categories', 'Other payment categories ({{count}})': 'Other payment categories ({{count}})', 'paytoCategory.bitcoin': 'Bitcoin', - 'paytoCategory.bitcoin-layer': 'Bitcoin layer', + 'paytoCategory.bitcoin-layer': 'Bitcoin layer (Lightning)', 'paytoCategory.monero': 'Monero', 'paytoCategory.crypto': 'Crypto', 'paytoCategory.stablecoin': 'Stablecoin', diff --git a/src/i18n/locales/es.ts b/src/i18n/locales/es.ts index c707f4be..0a2faf85 100644 --- a/src/i18n/locales/es.ts +++ b/src/i18n/locales/es.ts @@ -677,7 +677,7 @@ export default { 'Show all categories': 'Mostrar todas las categorías', 'Other payment categories ({{count}})': 'Otras categorías de pago ({{count}})', 'paytoCategory.bitcoin': 'Bitcoin', - 'paytoCategory.bitcoin-layer': 'Capa Bitcoin', + 'paytoCategory.bitcoin-layer': 'Capa Bitcoin (Lightning)', 'paytoCategory.monero': 'Monero', 'paytoCategory.crypto': 'Cripto', 'paytoCategory.stablecoin': 'Stablecoin', diff --git a/src/i18n/locales/fr.ts b/src/i18n/locales/fr.ts index 3a9e69d6..213727ae 100644 --- a/src/i18n/locales/fr.ts +++ b/src/i18n/locales/fr.ts @@ -676,7 +676,7 @@ export default { 'Show all categories': 'Afficher toutes les catégories', 'Other payment categories ({{count}})': 'Autres catégories de paiement ({{count}})', 'paytoCategory.bitcoin': 'Bitcoin', - 'paytoCategory.bitcoin-layer': 'Couche Bitcoin', + 'paytoCategory.bitcoin-layer': 'Couche Bitcoin (Lightning)', 'paytoCategory.monero': 'Monero', 'paytoCategory.crypto': 'Crypto', 'paytoCategory.stablecoin': 'Stablecoin', diff --git a/src/i18n/locales/nl.ts b/src/i18n/locales/nl.ts index a515615b..a1c786b8 100644 --- a/src/i18n/locales/nl.ts +++ b/src/i18n/locales/nl.ts @@ -675,7 +675,7 @@ export default { 'Show all categories': 'Show all categories', 'Other payment categories ({{count}})': 'Other payment categories ({{count}})', 'paytoCategory.bitcoin': 'Bitcoin', - 'paytoCategory.bitcoin-layer': 'Bitcoin layer', + 'paytoCategory.bitcoin-layer': 'Bitcoin layer (Lightning)', 'paytoCategory.monero': 'Monero', 'paytoCategory.crypto': 'Crypto', 'paytoCategory.stablecoin': 'Stablecoin', diff --git a/src/i18n/locales/pl.ts b/src/i18n/locales/pl.ts index 5dde00da..45ddfd3f 100644 --- a/src/i18n/locales/pl.ts +++ b/src/i18n/locales/pl.ts @@ -674,7 +674,7 @@ export default { 'Show all categories': 'Pokaż wszystkie kategorie', 'Other payment categories ({{count}})': 'Inne kategorie płatności ({{count}})', 'paytoCategory.bitcoin': 'Bitcoin', - 'paytoCategory.bitcoin-layer': 'Warstwa Bitcoin', + 'paytoCategory.bitcoin-layer': 'Warstwa Bitcoin (Lightning)', 'paytoCategory.monero': 'Monero', 'paytoCategory.crypto': 'Krypto', 'paytoCategory.stablecoin': 'Stablecoin', diff --git a/src/i18n/locales/ru.ts b/src/i18n/locales/ru.ts index cadb8e11..8db824bf 100644 --- a/src/i18n/locales/ru.ts +++ b/src/i18n/locales/ru.ts @@ -677,7 +677,7 @@ export default { 'Show all categories': 'Показать все категории', 'Other payment categories ({{count}})': 'Другие категории оплаты ({{count}})', 'paytoCategory.bitcoin': 'Bitcoin', - 'paytoCategory.bitcoin-layer': 'Слой Bitcoin', + 'paytoCategory.bitcoin-layer': 'Слой Bitcoin (Lightning)', 'paytoCategory.monero': 'Monero', 'paytoCategory.crypto': 'Крипто', 'paytoCategory.stablecoin': 'Стейблкоин', diff --git a/src/i18n/locales/tr.ts b/src/i18n/locales/tr.ts index 36036d7c..613158de 100644 --- a/src/i18n/locales/tr.ts +++ b/src/i18n/locales/tr.ts @@ -675,7 +675,7 @@ export default { 'Show all categories': 'Show all categories', 'Other payment categories ({{count}})': 'Other payment categories ({{count}})', 'paytoCategory.bitcoin': 'Bitcoin', - 'paytoCategory.bitcoin-layer': 'Bitcoin layer', + 'paytoCategory.bitcoin-layer': 'Bitcoin layer (Lightning)', 'paytoCategory.monero': 'Monero', 'paytoCategory.crypto': 'Crypto', 'paytoCategory.stablecoin': 'Stablecoin', diff --git a/src/i18n/locales/zh.ts b/src/i18n/locales/zh.ts index edf7a528..ace98b14 100644 --- a/src/i18n/locales/zh.ts +++ b/src/i18n/locales/zh.ts @@ -673,7 +673,7 @@ export default { 'Show all categories': '显示所有类别', 'Other payment categories ({{count}})': '其他支付类别 ({{count}})', 'paytoCategory.bitcoin': '比特币', - 'paytoCategory.bitcoin-layer': '比特币二层', + 'paytoCategory.bitcoin-layer': '比特币二层 (Lightning)', 'paytoCategory.monero': '门罗币', 'paytoCategory.crypto': '加密货币', 'paytoCategory.stablecoin': '稳定币', diff --git a/src/providers/DeletedEventProvider.tsx b/src/providers/DeletedEventProvider.tsx index 220c7f22..2573f464 100644 --- a/src/providers/DeletedEventProvider.tsx +++ b/src/providers/DeletedEventProvider.tsx @@ -16,12 +16,26 @@ type TDeletedEventContext = { const DeletedEventContext = createContext(undefined) const noopIsEventDeleted = () => false +const noopAddDeletedEvent = () => {} +const noopAddDeletedEventId = () => {} + +const DELETED_EVENT_CONTEXT_FALLBACK: TDeletedEventContext = { + addDeletedEvent: noopAddDeletedEvent, + addDeletedEventId: noopAddDeletedEventId, + isEventDeleted: noopIsEventDeleted, + tombstoneEpoch: 0 +} /** Returns undefined outside provider (e.g. Asciidoc `createRoot` embeds before wrappers mount). */ export function useDeletedEventOptional(): TDeletedEventContext | undefined { return useContext(DeletedEventContext) } +/** Non-throwing; use in feeds/lists that only filter tombstones (survives HMR context splits). */ +export function useDeletedEventSafe(): TDeletedEventContext { + return useDeletedEventOptional() ?? DELETED_EVENT_CONTEXT_FALLBACK +} + export const useDeletedEvent = () => { const context = useDeletedEventOptional() if (!context) {