diff --git a/src/components/KindFilter/index.tsx b/src/components/KindFilter/index.tsx index c4c8103..2414eff 100644 --- a/src/components/KindFilter/index.tsx +++ b/src/components/KindFilter/index.tsx @@ -84,7 +84,7 @@ export default function KindFilter({ variant="ghost" size="titlebar-icon" className={cn( - 'relative w-fit px-3 hover:text-foreground', + 'relative hover:text-foreground', !isDifferentFromSaved && 'text-muted-foreground' )} onClick={() => { diff --git a/src/components/LiveFeedToggle/index.tsx b/src/components/LiveFeedToggle/index.tsx deleted file mode 100644 index a93d317..0000000 --- a/src/components/LiveFeedToggle/index.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { Button } from '@/components/ui/button' -import { cn } from '@/lib/utils' -import { useUserPreferences } from '@/providers/UserPreferencesProvider' -import { Radio } from 'lucide-react' -import { useTranslation } from 'react-i18next' - -export function LiveFeedToggle() { - const { t } = useTranslation() - const { enableLiveFeed, updateEnableLiveFeed } = useUserPreferences() - - return ( - - ) -} diff --git a/src/components/NormalFeed/index.tsx b/src/components/NormalFeed/index.tsx index 5ca5dd1..d0cfa62 100644 --- a/src/components/NormalFeed/index.tsx +++ b/src/components/NormalFeed/index.tsx @@ -9,8 +9,6 @@ import { TFeedSubRequest, TNoteListMode } from '@/types' import { useMemo, useRef, useState } from 'react' import KindFilter from '../KindFilter' import { RefreshButton } from '../RefreshButton' -import { LiveFeedToggle } from '../LiveFeedToggle' -import { useUserPreferences } from '@/providers/UserPreferencesProvider' export default function NormalFeed({ subRequests, @@ -30,7 +28,6 @@ export default function NormalFeed({ isPubkeyFeed?: boolean }) { const { showKinds } = useKindFilter() - const { enableLiveFeed } = useUserPreferences() const [temporaryShowKinds, setTemporaryShowKinds] = useState(showKinds) const [listMode, setListMode] = useState(() => storage.getNoteListMode()) const supportTouch = useMemo(() => isTouchDevice(), []) @@ -88,7 +85,6 @@ export default function NormalFeed({ }} /> )} - {!isPubkeyFeed && } {showKindsFilter && ( ) : ( )} diff --git a/src/components/NoteList/index.tsx b/src/components/NoteList/index.tsx index 653596c..b850eea 100644 --- a/src/components/NoteList/index.tsx +++ b/src/components/NoteList/index.tsx @@ -338,9 +338,21 @@ const NoteList = forwardRef< oldEvents.some((e) => e.id === event.id) ? oldEvents : [event, ...oldEvents] ) } else { - setNewEvents((oldEvents) => - [event, ...oldEvents].sort((a, b) => b.created_at - a.created_at) - ) + const isAtTop = (() => { + if (!topRef.current) return true + const rect = topRef.current.getBoundingClientRect() + return rect.top >= 50 + })() + + if (isAtTop) { + setEvents((oldEvents) => + oldEvents.some((e) => e.id === event.id) ? oldEvents : [event, ...oldEvents] + ) + } else { + setNewEvents((oldEvents) => + [event, ...oldEvents].sort((a, b) => b.created_at - a.created_at) + ) + } } threadService.addRepliesToThread([event]) }, diff --git a/src/components/Profile/ProfileFeed.tsx b/src/components/Profile/ProfileFeed.tsx index bc31902..6800d3b 100644 --- a/src/components/Profile/ProfileFeed.tsx +++ b/src/components/Profile/ProfileFeed.tsx @@ -7,14 +7,12 @@ import { generateBech32IdFromETag } from '@/lib/tag' import { isTouchDevice } from '@/lib/utils' import { useKindFilter } from '@/providers/KindFilterProvider' import { useNostr } from '@/providers/NostrProvider' -import { useUserPreferences } from '@/providers/UserPreferencesProvider' import client from '@/services/client.service' import storage from '@/services/local-storage.service' import relayInfoService from '@/services/relay-info.service' import { TFeedSubRequest, TNoteListMode } from '@/types' import { NostrEvent } from 'nostr-tools' import { useEffect, useMemo, useRef, useState } from 'react' -import { LiveFeedToggle } from '../LiveFeedToggle' import { RefreshButton } from '../RefreshButton' export default function ProfileFeed({ @@ -27,7 +25,6 @@ export default function ProfileFeed({ search?: string }) { const { pubkey: myPubkey, pinListEvent: myPinListEvent } = useNostr() - const { enableLiveFeed } = useUserPreferences() const { showKinds } = useKindFilter() const [temporaryShowKinds, setTemporaryShowKinds] = useState(showKinds) const [listMode, setListMode] = useState(() => { @@ -168,7 +165,6 @@ export default function ProfileFeed({ options={ <> {!supportTouch && noteListRef.current?.refresh()} />} - } @@ -180,7 +176,7 @@ export default function ProfileFeed({ hideReplies={listMode === 'posts'} filterMutedNotes={false} pinnedEventIds={listMode === 'you' || !!search ? [] : pinnedEventIds} - showNewNotesDirectly={myPubkey === pubkey || enableLiveFeed} + showNewNotesDirectly={myPubkey === pubkey} /> ) diff --git a/src/components/Tabs/index.tsx b/src/components/Tabs/index.tsx index b139fce..58359d7 100644 --- a/src/components/Tabs/index.tsx +++ b/src/components/Tabs/index.tsx @@ -1,8 +1,9 @@ +import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area' +import { Separator } from '@/components/ui/separator' import { cn } from '@/lib/utils' import { useDeepBrowsing } from '@/providers/DeepBrowsingProvider' import { ReactNode, useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' -import { ScrollArea, ScrollBar } from '../ui/scroll-area' type TabDefinition = { value: string @@ -124,7 +125,12 @@ export default function Tabs({ - {options &&
{options}
} + {options && ( +
+ + {options} +
+ )} ) } diff --git a/src/components/UserAggregationList/index.tsx b/src/components/UserAggregationList/index.tsx index ecc4987..bf8dfe1 100644 --- a/src/components/UserAggregationList/index.tsx +++ b/src/components/UserAggregationList/index.tsx @@ -54,7 +54,6 @@ const UserAggregationList = forwardRef< areAlgoRelays?: boolean showRelayCloseReason?: boolean isPubkeyFeed?: boolean - showNewNotesDirectly?: boolean } >( ( @@ -64,8 +63,7 @@ const UserAggregationList = forwardRef< filterMutedNotes = true, areAlgoRelays = false, showRelayCloseReason = false, - isPubkeyFeed = false, - showNewNotesDirectly = false + isPubkeyFeed = false }, ref ) => { @@ -97,8 +95,6 @@ const UserAggregationList = forwardRef< const bottomRef = useRef(null) const topRef = useRef(null) const nonPinnedTopRef = useRef(null) - const showNewNotesDirectlyRef = useRef(showNewNotesDirectly) - showNewNotesDirectlyRef.current = showNewNotesDirectly const scrollToTop = (behavior: ScrollBehavior = 'instant') => { setTimeout(() => { @@ -180,13 +176,9 @@ const UserAggregationList = forwardRef< } }, onNew: (event) => { - if (showNewNotesDirectlyRef.current) { - setEvents((oldEvents) => [event, ...oldEvents]) - } else { - setNewEvents((oldEvents) => - [event, ...oldEvents].sort((a, b) => b.created_at - a.created_at) - ) - } + setNewEvents((oldEvents) => + [event, ...oldEvents].sort((a, b) => b.created_at - a.created_at) + ) threadService.addRepliesToThread([event]) }, onClose: (url, reason) => { diff --git a/src/constants.ts b/src/constants.ts index 86cf42d..c74766a 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -42,8 +42,8 @@ export const StorageKey = { QUICK_REACTION_EMOJI: 'quickReactionEmoji', NSFW_DISPLAY_POLICY: 'nsfwDisplayPolicy', MIN_TRUST_SCORE: 'minTrustScore', - ENABLE_LIVE_FEED: 'enableLiveFeed', DEFAULT_RELAY_URLS: 'defaultRelayUrls', + ENABLE_LIVE_FEED: 'enableLiveFeed', // deprecated HIDE_UNTRUSTED_NOTES: 'hideUntrustedNotes', // deprecated HIDE_UNTRUSTED_INTERACTIONS: 'hideUntrustedInteractions', // deprecated HIDE_UNTRUSTED_NOTIFICATIONS: 'hideUntrustedNotifications', // deprecated diff --git a/src/providers/UserPreferencesProvider.tsx b/src/providers/UserPreferencesProvider.tsx index a48a419..9302aef 100644 --- a/src/providers/UserPreferencesProvider.tsx +++ b/src/providers/UserPreferencesProvider.tsx @@ -21,9 +21,6 @@ type TUserPreferencesContext = { quickReactionEmoji: string | TEmoji updateQuickReactionEmoji: (emoji: string | TEmoji) => void - - enableLiveFeed: boolean - updateEnableLiveFeed: (enable: boolean) => void } const UserPreferencesContext = createContext(undefined) @@ -48,7 +45,6 @@ export function UserPreferencesProvider({ children }: { children: React.ReactNod ) const [quickReaction, setQuickReaction] = useState(storage.getQuickReaction()) const [quickReactionEmoji, setQuickReactionEmoji] = useState(storage.getQuickReactionEmoji()) - const [enableLiveFeed, setEnableLiveFeed] = useState(storage.getEnableLiveFeed()) useEffect(() => { if (!isSmallScreen && enableSingleColumnLayout) { @@ -83,11 +79,6 @@ export function UserPreferencesProvider({ children }: { children: React.ReactNod storage.setQuickReactionEmoji(emoji) } - const updateEnableLiveFeed = (enable: boolean) => { - setEnableLiveFeed(enable) - storage.setEnableLiveFeed(enable) - } - return ( {children} diff --git a/src/services/local-storage.service.ts b/src/services/local-storage.service.ts index bbcf028..95ea95f 100644 --- a/src/services/local-storage.service.ts +++ b/src/services/local-storage.service.ts @@ -65,7 +65,6 @@ class LocalStorageService { private quickReactionEmoji: string | TEmoji = '+' private nsfwDisplayPolicy: TNsfwDisplayPolicy = NSFW_DISPLAY_POLICY.HIDE_CONTENT private minTrustScore: number = 40 - private enableLiveFeed: boolean = false private defaultRelayUrls: string[] = BIG_RELAY_URLS constructor() { @@ -278,8 +277,6 @@ class LocalStorageService { } } - this.enableLiveFeed = window.localStorage.getItem(StorageKey.ENABLE_LIVE_FEED) === 'true' - const defaultRelayUrlsStr = window.localStorage.getItem(StorageKey.DEFAULT_RELAY_URLS) if (defaultRelayUrlsStr) { try { @@ -305,6 +302,7 @@ class LocalStorageService { window.localStorage.removeItem(StorageKey.ACCOUNT_MUTE_DECRYPTED_TAGS_MAP) window.localStorage.removeItem(StorageKey.ACTIVE_RELAY_SET_ID) window.localStorage.removeItem(StorageKey.FEED_TYPE) + window.localStorage.removeItem(StorageKey.ENABLE_LIVE_FEED) } getRelaySets() { @@ -634,15 +632,6 @@ class LocalStorageService { } } - getEnableLiveFeed() { - return this.enableLiveFeed - } - - setEnableLiveFeed(enable: boolean) { - this.enableLiveFeed = enable - window.localStorage.setItem(StorageKey.ENABLE_LIVE_FEED, enable.toString()) - } - getDefaultRelayUrls() { return this.defaultRelayUrls }