fix: 💨

This commit is contained in:
codytseng
2025-07-06 00:58:21 +08:00
committed by Cody Tseng
parent 98bf906916
commit c729c20771
21 changed files with 63 additions and 42 deletions

View File

@@ -7,6 +7,7 @@ import { isSafari } from '@/lib/utils'
import { useMuteList } from '@/providers/MuteListProvider' import { useMuteList } from '@/providers/MuteListProvider'
import { useNostr } from '@/providers/NostrProvider' import { useNostr } from '@/providers/NostrProvider'
import { useScreenSize } from '@/providers/ScreenSizeProvider' import { useScreenSize } from '@/providers/ScreenSizeProvider'
import { useUserTrust } from '@/providers/UserTrustProvider'
import client from '@/services/client.service' import client from '@/services/client.service'
import storage from '@/services/local-storage.service' import storage from '@/services/local-storage.service'
import relayInfoService from '@/services/relay-info.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 NoteCard, { NoteCardLoadingSkeleton } from '../NoteCard'
import { PictureNoteCardMasonry } from '../PictureNoteCardMasonry' import { PictureNoteCardMasonry } from '../PictureNoteCardMasonry'
import Tabs from '../Tabs' import Tabs from '../Tabs'
import { useUserTrust } from '@/providers/UserTrustProvider'
import { useFeed } from '@/providers/FeedProvider'
const LIMIT = 100 const LIMIT = 100
const ALGO_LIMIT = 500 const ALGO_LIMIT = 500
@@ -34,7 +33,8 @@ export default function NoteList({
filterMutedNotes = true, filterMutedNotes = true,
needCheckAlgoRelay = false, needCheckAlgoRelay = false,
isMainFeed = false, isMainFeed = false,
topSpace = 0 topSpace = 0,
skipTrustCheck = false
}: { }: {
relayUrls?: string[] relayUrls?: string[]
filter?: Filter filter?: Filter
@@ -44,6 +44,7 @@ export default function NoteList({
needCheckAlgoRelay?: boolean needCheckAlgoRelay?: boolean
isMainFeed?: boolean isMainFeed?: boolean
topSpace?: number topSpace?: number
skipTrustCheck?: boolean
}) { }) {
const { t } = useTranslation() const { t } = useTranslation()
const { isLargeScreen } = useScreenSize() const { isLargeScreen } = useScreenSize()
@@ -63,13 +64,12 @@ export default function NoteList({
const bottomRef = useRef<HTMLDivElement | null>(null) const bottomRef = useRef<HTMLDivElement | null>(null)
const topRef = useRef<HTMLDivElement | null>(null) const topRef = useRef<HTMLDivElement | null>(null)
const { isUserTrusted, hideUntrustedNotes } = useUserTrust() const { isUserTrusted, hideUntrustedNotes } = useUserTrust()
const { feedInfo } = useFeed()
const filteredNewEvents = useMemo(() => { const filteredNewEvents = useMemo(() => {
return newEvents.filter((event: Event) => { return newEvents.filter((event: Event) => {
return ( return (
(!filterMutedNotes || !mutePubkeys.includes(event.pubkey)) && (!filterMutedNotes || !mutePubkeys.includes(event.pubkey)) &&
(listMode !== 'posts' || !isReplyNoteEvent(event)) && (listMode !== 'posts' || !isReplyNoteEvent(event)) &&
(!hideUntrustedNotes || isUserTrusted(event.pubkey)) (skipTrustCheck || !hideUntrustedNotes || isUserTrusted(event.pubkey))
) )
}) })
}, [newEvents, listMode, filterMutedNotes, mutePubkeys, hideUntrustedNotes]) }, [newEvents, listMode, filterMutedNotes, mutePubkeys, hideUntrustedNotes])
@@ -346,11 +346,11 @@ export default function NoteList({
<div> <div>
{events {events
.slice(0, showCount) .slice(0, showCount)
.filter((event: Event) => .filter(
(listMode !== 'posts' || !isReplyNoteEvent(event)) && (event: Event) =>
(author (listMode !== 'posts' || !isReplyNoteEvent(event)) &&
|| (feedInfo.feedType !== 'relay' && feedInfo.feedType !== 'relays') (skipTrustCheck || !hideUntrustedNotes || isUserTrusted(event.pubkey))
|| !hideUntrustedNotes || isUserTrusted(event.pubkey))) )
.map((event) => ( .map((event) => (
<NoteCard <NoteCard
key={event.id} key={event.id}

View File

@@ -92,4 +92,8 @@ export const NIP_96_SERVICE = [
] ]
export const DEFAULT_NIP_96_SERVICE = 'https://nostr.build' export const DEFAULT_NIP_96_SERVICE = 'https://nostr.build'
export const DEFAULT_NOSTRCONNECT_RELAY = ['wss://relay.nsec.app/', 'wss://nos.lol/', 'wss://relay.primal.net'] export const DEFAULT_NOSTRCONNECT_RELAY = [
'wss://relay.nsec.app/',
'wss://nos.lol/',
'wss://relay.primal.net'
]

View File

@@ -279,6 +279,7 @@ export default {
'Translating...': 'جارٍ الترجمة...', 'Translating...': 'جارٍ الترجمة...',
Translate: 'ترجمة', Translate: 'ترجمة',
'Show original': 'عرض الأصل', 'Show original': 'عرض الأصل',
Website: 'الموقع الإلكتروني' Website: 'الموقع الإلكتروني',
'Hide untrusted notes': 'إخفاء الملاحظات غير الموثوقة'
} }
} }

View File

@@ -286,6 +286,7 @@ export default {
'Translating...': 'Übersetze...', 'Translating...': 'Übersetze...',
Translate: 'Übersetzen', Translate: 'Übersetzen',
'Show original': 'Original anzeigen', 'Show original': 'Original anzeigen',
Website: 'Website' Website: 'Website',
'Hide untrusted notes': 'Untrusted Notizen ausblenden'
} }
} }

View File

@@ -279,6 +279,7 @@ export default {
'Translating...': 'Translating...', 'Translating...': 'Translating...',
Translate: 'Translate', Translate: 'Translate',
'Show original': 'Show original', 'Show original': 'Show original',
Website: 'Website' Website: 'Website',
'Hide untrusted notes': 'Hide untrusted notes'
} }
} }

View File

@@ -284,6 +284,7 @@ export default {
'Translating...': 'Traduciendo...', 'Translating...': 'Traduciendo...',
Translate: 'Traducir', Translate: 'Traducir',
'Show original': 'Mostrar original', 'Show original': 'Mostrar original',
Website: 'Sitio web' Website: 'Sitio web',
'Hide untrusted notes': 'Ocultar notas no confiables'
} }
} }

View File

@@ -284,6 +284,7 @@ export default {
'Translating...': 'Traduction en cours...', 'Translating...': 'Traduction en cours...',
Translate: 'Traduire', Translate: 'Traduire',
'Show original': 'Afficher loriginal', 'Show original': 'Afficher loriginal',
Website: 'Site Web' Website: 'Site Web',
'Hide untrusted notes': 'Cacher les notes non fiables'
} }
} }

View File

@@ -283,6 +283,7 @@ export default {
'Translating...': 'Traduzione in corso...', 'Translating...': 'Traduzione in corso...',
Translate: 'Traduci', Translate: 'Traduci',
'Show original': 'Mostra originale', 'Show original': 'Mostra originale',
Website: 'Sito web' Website: 'Sito web',
'Hide untrusted notes': 'Nascondi note non fidate'
} }
} }

View File

@@ -281,6 +281,7 @@ export default {
'Translating...': '翻訳中...', 'Translating...': '翻訳中...',
Translate: '翻訳', Translate: '翻訳',
'Show original': '原文を表示', 'Show original': '原文を表示',
Website: 'ウェブサイト' Website: 'ウェブサイト',
'Hide untrusted notes': '信頼されていないノートを非表示'
} }
} }

View File

@@ -281,6 +281,7 @@ export default {
'Translating...': '번역 중...', 'Translating...': '번역 중...',
Translate: '번역', Translate: '번역',
'Show original': '원본 보기', 'Show original': '원본 보기',
Website: '웹사이트' Website: '웹사이트',
'Hide untrusted notes': '신뢰하지 않는 노트 숨기기'
} }
} }

View File

@@ -282,6 +282,7 @@ export default {
'Translating...': 'Tłumaczenie...', 'Translating...': 'Tłumaczenie...',
Translate: 'Przetłumacz', Translate: 'Przetłumacz',
'Show original': 'Pokaż oryginał', 'Show original': 'Pokaż oryginał',
Website: 'Strona internetowa' Website: 'Strona internetowa',
'Hide untrusted notes': 'Ukryj wpisy od nieznanych użytkowników'
} }
} }

View File

@@ -282,6 +282,7 @@ export default {
'Translating...': 'Traduzindo...', 'Translating...': 'Traduzindo...',
Translate: 'Traduzir', Translate: 'Traduzir',
'Show original': 'Mostrar original', 'Show original': 'Mostrar original',
Website: 'Website' Website: 'Website',
'Hide untrusted notes': 'Ocultar notas não confiáveis'
} }
} }

View File

@@ -283,6 +283,7 @@ export default {
'Translating...': 'Traduzindo...', 'Translating...': 'Traduzindo...',
Translate: 'Traduzir', Translate: 'Traduzir',
'Show original': 'Mostrar original', 'Show original': 'Mostrar original',
Website: 'Website' Website: 'Website',
'Hide untrusted notes': 'Esconder notas não confiáveis'
} }
} }

View File

@@ -284,6 +284,7 @@ export default {
'Translating...': 'Перевод...', 'Translating...': 'Перевод...',
Translate: 'Перевести', Translate: 'Перевести',
'Show original': 'Показать оригинал', 'Show original': 'Показать оригинал',
Website: 'Веб-сайт' Website: 'Веб-сайт',
'Hide untrusted notes': 'Скрыть недоверенные заметки'
} }
} }

View File

@@ -278,6 +278,7 @@ export default {
'Translating...': 'กำลังแปล...', 'Translating...': 'กำลังแปล...',
Translate: 'แปล', Translate: 'แปล',
'Show original': 'แสดงต้นฉบับ', 'Show original': 'แสดงต้นฉบับ',
Website: 'เว็บไซต์' Website: 'เว็บไซต์',
'Hide untrusted notes': 'ซ่อนโน้ตที่ไม่น่าเชื่อถือ'
} }
} }

View File

@@ -279,6 +279,7 @@ export default {
'Translating...': '翻译中...', 'Translating...': '翻译中...',
Translate: '翻译', Translate: '翻译',
'Show original': '显示原文', 'Show original': '显示原文',
Website: '网站' Website: '网站',
'Hide untrusted notes': '隐藏不受信任的笔记'
} }
} }

View File

@@ -55,6 +55,7 @@ const NoteListPage = forwardRef((_, ref) => {
filter={filter} filter={filter}
needCheckAlgoRelay={feedInfo.feedType !== 'following'} needCheckAlgoRelay={feedInfo.feedType !== 'following'}
isMainFeed isMainFeed
skipTrustCheck={feedInfo.feedType === 'following'}
/> />
) )
} }

View File

@@ -6,10 +6,10 @@ import SecondaryPageLayout from '@/layouts/SecondaryPageLayout'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { useAutoplay } from '@/providers/AutoplayProvider' import { useAutoplay } from '@/providers/AutoplayProvider'
import { useTheme } from '@/providers/ThemeProvider' import { useTheme } from '@/providers/ThemeProvider'
import { useUserTrust } from '@/providers/UserTrustProvider'
import { SelectValue } from '@radix-ui/react-select' import { SelectValue } from '@radix-ui/react-select'
import { forwardRef, HTMLProps, useState } from 'react' import { forwardRef, HTMLProps, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { useUserTrust } from '@/providers/UserTrustProvider'
const GeneralSettingsPage = forwardRef(({ index }: { index?: number }, ref) => { const GeneralSettingsPage = forwardRef(({ index }: { index?: number }, ref) => {
const { t, i18n } = useTranslation() const { t, i18n } = useTranslation()
@@ -66,10 +66,14 @@ const GeneralSettingsPage = forwardRef(({ index }: { index?: number }, ref) => {
<Switch id="autoplay" checked={autoplay} onCheckedChange={setAutoplay} /> <Switch id="autoplay" checked={autoplay} onCheckedChange={setAutoplay} />
</SettingItem> </SettingItem>
<SettingItem> <SettingItem>
<Label htmlFor="hideUntrustedNotes" className="text-base font-normal"> <Label htmlFor="hide-untrusted-notes" className="text-base font-normal">
{t('Hide untrusted posts')} {t('Hide untrusted notes')}
</Label> </Label>
<Switch id="hideUntrustedNotes" checked={hideUntrustedNotes} onCheckedChange={updateHideUntrustedNotes} /> <Switch
id="hide-untrusted-notes"
checked={hideUntrustedNotes}
onCheckedChange={updateHideUntrustedNotes}
/>
</SettingItem> </SettingItem>
</div> </div>
</SecondaryPageLayout> </SecondaryPageLayout>

View File

@@ -198,6 +198,7 @@ const ProfilePage = forwardRef(({ id, index }: { id?: string; index?: number },
className="mt-2" className="mt-2"
filterMutedNotes={false} filterMutedNotes={false}
topSpace={topContainerHeight + 100} topSpace={topContainerHeight + 100}
skipTrustCheck
/> />
</SecondaryPageLayout> </SecondaryPageLayout>
) )

View File

@@ -34,7 +34,7 @@ export function UserTrustProvider({ children }: { children: React.ReactNode }) {
storage.getHideUntrustedNotifications() storage.getHideUntrustedNotifications()
) )
const [hideUntrustedNotes, setHideUntrustedNotes] = useState(() => const [hideUntrustedNotes, setHideUntrustedNotes] = useState(() =>
storage.getHideUntrustedNotes ? storage.getHideUntrustedNotes() : false storage.getHideUntrustedNotes()
) )
useEffect(() => { useEffect(() => {
@@ -73,9 +73,7 @@ export function UserTrustProvider({ children }: { children: React.ReactNode }) {
const updateHideUntrustedNotes = (hide: boolean) => { const updateHideUntrustedNotes = (hide: boolean) => {
setHideUntrustedNotes(hide) setHideUntrustedNotes(hide)
if (storage.setHideUntrustedNotes) { storage.setHideUntrustedNotes(hide)
storage.setHideUntrustedNotes(hide)
}
} }
return ( return (

View File

@@ -96,9 +96,8 @@ class LocalStorageService {
window.localStorage.getItem(StorageKey.MEDIA_UPLOAD_SERVICE) ?? DEFAULT_NIP_96_SERVICE window.localStorage.getItem(StorageKey.MEDIA_UPLOAD_SERVICE) ?? DEFAULT_NIP_96_SERVICE
this.autoplay = window.localStorage.getItem(StorageKey.AUTOPLAY) !== 'false' 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' window.localStorage.getItem(StorageKey.HIDE_UNTRUSTED_EVENTS) === 'true'
const storedHideUntrustedInteractions = window.localStorage.getItem( const storedHideUntrustedInteractions = window.localStorage.getItem(
StorageKey.HIDE_UNTRUSTED_INTERACTIONS StorageKey.HIDE_UNTRUSTED_INTERACTIONS
@@ -106,13 +105,16 @@ class LocalStorageService {
const storedHideUntrustedNotifications = window.localStorage.getItem( const storedHideUntrustedNotifications = window.localStorage.getItem(
StorageKey.HIDE_UNTRUSTED_NOTIFICATIONS StorageKey.HIDE_UNTRUSTED_NOTIFICATIONS
) )
const storedHideUntrustedNotes = window.localStorage.getItem(StorageKey.HIDE_UNTRUSTED_NOTES)
this.hideUntrustedInteractions = storedHideUntrustedInteractions this.hideUntrustedInteractions = storedHideUntrustedInteractions
? storedHideUntrustedInteractions === 'true' ? storedHideUntrustedInteractions === 'true'
: hideUntrustedNotes : hideUntrustedEvents
this.hideUntrustedNotifications = storedHideUntrustedNotifications this.hideUntrustedNotifications = storedHideUntrustedNotifications
? storedHideUntrustedNotifications === 'true' ? storedHideUntrustedNotifications === 'true'
: hideUntrustedNotes : hideUntrustedEvents
this.hideUntrustedNotes = hideUntrustedNotes this.hideUntrustedNotes = storedHideUntrustedNotes
? storedHideUntrustedNotes === 'true'
: hideUntrustedEvents
const translationServiceConfigMapStr = window.localStorage.getItem( const translationServiceConfigMapStr = window.localStorage.getItem(
StorageKey.TRANSLATION_SERVICE_CONFIG_MAP StorageKey.TRANSLATION_SERVICE_CONFIG_MAP
@@ -310,10 +312,7 @@ class LocalStorageService {
setHideUntrustedNotes(hideUntrustedNotes: boolean) { setHideUntrustedNotes(hideUntrustedNotes: boolean) {
this.hideUntrustedNotes = hideUntrustedNotes this.hideUntrustedNotes = hideUntrustedNotes
window.localStorage.setItem( window.localStorage.setItem(StorageKey.HIDE_UNTRUSTED_NOTES, hideUntrustedNotes.toString())
StorageKey.HIDE_UNTRUSTED_NOTES,
hideUntrustedNotes.toString()
)
} }
getTranslationServiceConfig(pubkey?: string | null) { getTranslationServiceConfig(pubkey?: string | null) {