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 { 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<HTMLDivElement | null>(null)
const topRef = useRef<HTMLDivElement | null>(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({
<div>
{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) => (
<NoteCard
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_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...': 'جارٍ الترجمة...',
Translate: 'ترجمة',
'Show original': 'عرض الأصل',
Website: 'الموقع الإلكتروني'
Website: 'الموقع الإلكتروني',
'Hide untrusted notes': 'إخفاء الملاحظات غير الموثوقة'
}
}

View File

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

View File

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

View File

@@ -284,6 +284,7 @@ export default {
'Translating...': 'Traduciendo...',
Translate: 'Traducir',
'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...',
Translate: 'Traduire',
'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...',
Translate: 'Traduci',
'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...': '翻訳中...',
Translate: '翻訳',
'Show original': '原文を表示',
Website: 'ウェブサイト'
Website: 'ウェブサイト',
'Hide untrusted notes': '信頼されていないノートを非表示'
}
}

View File

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

View File

@@ -282,6 +282,7 @@ export default {
'Translating...': 'Tłumaczenie...',
Translate: 'Przetłumacz',
'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...',
Translate: 'Traduzir',
'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...',
Translate: 'Traduzir',
'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...': 'Перевод...',
Translate: 'Перевести',
'Show original': 'Показать оригинал',
Website: 'Веб-сайт'
Website: 'Веб-сайт',
'Hide untrusted notes': 'Скрыть недоверенные заметки'
}
}

View File

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

View File

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

View File

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

View File

@@ -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) => {
<Switch id="autoplay" checked={autoplay} onCheckedChange={setAutoplay} />
</SettingItem>
<SettingItem>
<Label htmlFor="hideUntrustedNotes" className="text-base font-normal">
{t('Hide untrusted posts')}
<Label htmlFor="hide-untrusted-notes" className="text-base font-normal">
{t('Hide untrusted notes')}
</Label>
<Switch id="hideUntrustedNotes" checked={hideUntrustedNotes} onCheckedChange={updateHideUntrustedNotes} />
<Switch
id="hide-untrusted-notes"
checked={hideUntrustedNotes}
onCheckedChange={updateHideUntrustedNotes}
/>
</SettingItem>
</div>
</SecondaryPageLayout>

View File

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

View File

@@ -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 (

View File

@@ -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) {