From c729c2077118bce26cb19852003d78b88881b2d5 Mon Sep 17 00:00:00 2001 From: codytseng Date: Sun, 6 Jul 2025 00:58:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=92=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/NoteList/index.tsx | 20 +++++++++---------- src/constants.ts | 6 +++++- src/i18n/locales/ar.ts | 3 ++- src/i18n/locales/de.ts | 3 ++- src/i18n/locales/en.ts | 3 ++- src/i18n/locales/es.ts | 3 ++- src/i18n/locales/fr.ts | 3 ++- src/i18n/locales/it.ts | 3 ++- src/i18n/locales/ja.ts | 3 ++- src/i18n/locales/ko.ts | 3 ++- src/i18n/locales/pl.ts | 3 ++- src/i18n/locales/pt-BR.ts | 3 ++- src/i18n/locales/pt-PT.ts | 3 ++- src/i18n/locales/ru.ts | 3 ++- src/i18n/locales/th.ts | 3 ++- src/i18n/locales/zh.ts | 3 ++- src/pages/primary/NoteListPage/index.tsx | 1 + .../secondary/GeneralSettingsPage/index.tsx | 12 +++++++---- src/pages/secondary/ProfilePage/index.tsx | 1 + src/providers/UserTrustProvider.tsx | 6 ++---- src/services/local-storage.service.ts | 17 ++++++++-------- 21 files changed, 63 insertions(+), 42 deletions(-) diff --git a/src/components/NoteList/index.tsx b/src/components/NoteList/index.tsx index aeafe417..1b4c25b2 100644 --- a/src/components/NoteList/index.tsx +++ b/src/components/NoteList/index.tsx @@ -7,6 +7,7 @@ import { isSafari } from '@/lib/utils' import { useMuteList } from '@/providers/MuteListProvider' import { useNostr } from '@/providers/NostrProvider' import { useScreenSize } from '@/providers/ScreenSizeProvider' +import { useUserTrust } from '@/providers/UserTrustProvider' import client from '@/services/client.service' import storage from '@/services/local-storage.service' import relayInfoService from '@/services/relay-info.service' @@ -19,8 +20,6 @@ import PullToRefresh from 'react-simple-pull-to-refresh' import NoteCard, { NoteCardLoadingSkeleton } from '../NoteCard' import { PictureNoteCardMasonry } from '../PictureNoteCardMasonry' import Tabs from '../Tabs' -import { useUserTrust } from '@/providers/UserTrustProvider' -import { useFeed } from '@/providers/FeedProvider' const LIMIT = 100 const ALGO_LIMIT = 500 @@ -34,7 +33,8 @@ export default function NoteList({ filterMutedNotes = true, needCheckAlgoRelay = false, isMainFeed = false, - topSpace = 0 + topSpace = 0, + skipTrustCheck = false }: { relayUrls?: string[] filter?: Filter @@ -44,6 +44,7 @@ export default function NoteList({ needCheckAlgoRelay?: boolean isMainFeed?: boolean topSpace?: number + skipTrustCheck?: boolean }) { const { t } = useTranslation() const { isLargeScreen } = useScreenSize() @@ -63,13 +64,12 @@ export default function NoteList({ const bottomRef = useRef(null) const topRef = useRef(null) const { isUserTrusted, hideUntrustedNotes } = useUserTrust() - const { feedInfo } = useFeed() const filteredNewEvents = useMemo(() => { return newEvents.filter((event: Event) => { return ( (!filterMutedNotes || !mutePubkeys.includes(event.pubkey)) && (listMode !== 'posts' || !isReplyNoteEvent(event)) && - (!hideUntrustedNotes || isUserTrusted(event.pubkey)) + (skipTrustCheck || !hideUntrustedNotes || isUserTrusted(event.pubkey)) ) }) }, [newEvents, listMode, filterMutedNotes, mutePubkeys, hideUntrustedNotes]) @@ -346,11 +346,11 @@ export default function NoteList({
{events .slice(0, showCount) - .filter((event: Event) => - (listMode !== 'posts' || !isReplyNoteEvent(event)) && - (author - || (feedInfo.feedType !== 'relay' && feedInfo.feedType !== 'relays') - || !hideUntrustedNotes || isUserTrusted(event.pubkey))) + .filter( + (event: Event) => + (listMode !== 'posts' || !isReplyNoteEvent(event)) && + (skipTrustCheck || !hideUntrustedNotes || isUserTrusted(event.pubkey)) + ) .map((event) => ( { filter={filter} needCheckAlgoRelay={feedInfo.feedType !== 'following'} isMainFeed + skipTrustCheck={feedInfo.feedType === 'following'} /> ) } diff --git a/src/pages/secondary/GeneralSettingsPage/index.tsx b/src/pages/secondary/GeneralSettingsPage/index.tsx index 39c9a923..adc0e8a6 100644 --- a/src/pages/secondary/GeneralSettingsPage/index.tsx +++ b/src/pages/secondary/GeneralSettingsPage/index.tsx @@ -6,10 +6,10 @@ import SecondaryPageLayout from '@/layouts/SecondaryPageLayout' import { cn } from '@/lib/utils' import { useAutoplay } from '@/providers/AutoplayProvider' import { useTheme } from '@/providers/ThemeProvider' +import { useUserTrust } from '@/providers/UserTrustProvider' import { SelectValue } from '@radix-ui/react-select' import { forwardRef, HTMLProps, useState } from 'react' import { useTranslation } from 'react-i18next' -import { useUserTrust } from '@/providers/UserTrustProvider' const GeneralSettingsPage = forwardRef(({ index }: { index?: number }, ref) => { const { t, i18n } = useTranslation() @@ -66,10 +66,14 @@ const GeneralSettingsPage = forwardRef(({ index }: { index?: number }, ref) => { -
diff --git a/src/pages/secondary/ProfilePage/index.tsx b/src/pages/secondary/ProfilePage/index.tsx index 4bc35f9f..65211d5c 100644 --- a/src/pages/secondary/ProfilePage/index.tsx +++ b/src/pages/secondary/ProfilePage/index.tsx @@ -198,6 +198,7 @@ const ProfilePage = forwardRef(({ id, index }: { id?: string; index?: number }, className="mt-2" filterMutedNotes={false} topSpace={topContainerHeight + 100} + skipTrustCheck /> ) diff --git a/src/providers/UserTrustProvider.tsx b/src/providers/UserTrustProvider.tsx index f9e4f1e8..bf09c81f 100644 --- a/src/providers/UserTrustProvider.tsx +++ b/src/providers/UserTrustProvider.tsx @@ -34,7 +34,7 @@ export function UserTrustProvider({ children }: { children: React.ReactNode }) { storage.getHideUntrustedNotifications() ) const [hideUntrustedNotes, setHideUntrustedNotes] = useState(() => - storage.getHideUntrustedNotes ? storage.getHideUntrustedNotes() : false + storage.getHideUntrustedNotes() ) useEffect(() => { @@ -73,9 +73,7 @@ export function UserTrustProvider({ children }: { children: React.ReactNode }) { const updateHideUntrustedNotes = (hide: boolean) => { setHideUntrustedNotes(hide) - if (storage.setHideUntrustedNotes) { - storage.setHideUntrustedNotes(hide) - } + storage.setHideUntrustedNotes(hide) } return ( diff --git a/src/services/local-storage.service.ts b/src/services/local-storage.service.ts index c28942c6..0bdf9277 100644 --- a/src/services/local-storage.service.ts +++ b/src/services/local-storage.service.ts @@ -96,9 +96,8 @@ class LocalStorageService { window.localStorage.getItem(StorageKey.MEDIA_UPLOAD_SERVICE) ?? DEFAULT_NIP_96_SERVICE this.autoplay = window.localStorage.getItem(StorageKey.AUTOPLAY) !== 'false' - this.hideUntrustedNotes = window.localStorage.getItem(StorageKey.HIDE_UNTRUSTED_NOTES) === 'true' - const hideUntrustedNotes = + const hideUntrustedEvents = window.localStorage.getItem(StorageKey.HIDE_UNTRUSTED_EVENTS) === 'true' const storedHideUntrustedInteractions = window.localStorage.getItem( StorageKey.HIDE_UNTRUSTED_INTERACTIONS @@ -106,13 +105,16 @@ class LocalStorageService { const storedHideUntrustedNotifications = window.localStorage.getItem( StorageKey.HIDE_UNTRUSTED_NOTIFICATIONS ) + const storedHideUntrustedNotes = window.localStorage.getItem(StorageKey.HIDE_UNTRUSTED_NOTES) this.hideUntrustedInteractions = storedHideUntrustedInteractions ? storedHideUntrustedInteractions === 'true' - : hideUntrustedNotes + : hideUntrustedEvents this.hideUntrustedNotifications = storedHideUntrustedNotifications ? storedHideUntrustedNotifications === 'true' - : hideUntrustedNotes - this.hideUntrustedNotes = hideUntrustedNotes + : hideUntrustedEvents + this.hideUntrustedNotes = storedHideUntrustedNotes + ? storedHideUntrustedNotes === 'true' + : hideUntrustedEvents const translationServiceConfigMapStr = window.localStorage.getItem( StorageKey.TRANSLATION_SERVICE_CONFIG_MAP @@ -310,10 +312,7 @@ class LocalStorageService { setHideUntrustedNotes(hideUntrustedNotes: boolean) { this.hideUntrustedNotes = hideUntrustedNotes - window.localStorage.setItem( - StorageKey.HIDE_UNTRUSTED_NOTES, - hideUntrustedNotes.toString() - ) + window.localStorage.setItem(StorageKey.HIDE_UNTRUSTED_NOTES, hideUntrustedNotes.toString()) } getTranslationServiceConfig(pubkey?: string | null) {