feat: remove showCompactTimelineInSub

This commit is contained in:
DIYgod
2025-10-25 16:45:09 +08:00
parent ca8c3d5b21
commit d1f0ce3c10
14 changed files with 3 additions and 516 deletions
@@ -1,7 +1,7 @@
import { createSettingAtom } from "@follow/atoms/helper/setting.js"
import { defaultGeneralSettings } from "@follow/shared/settings/defaults"
import { hookEnhancedSettings as baseHookEnhancedSettings } from "@follow/shared/settings/hook"
import type { GeneralSettings as BaseGeneralSettings } from "@follow/shared/settings/interface"
import type { GeneralSettings } from "@follow/shared/settings/interface"
import type { SupportedLanguages } from "@follow-app/client-sdk"
import { jotaiStore } from "~/lib/jotai"
@@ -9,13 +9,9 @@ import { getDefaultLanguage } from "~/lib/language"
export const DEFAULT_ACTION_LANGUAGE = "default"
export interface GeneralSettings extends BaseGeneralSettings {
showCompactTimelineInSub: boolean
}
export const createDefaultGeneralSettings = (): GeneralSettings => ({
...defaultGeneralSettings,
language: getDefaultLanguage(),
showCompactTimelineInSub: false,
})
const {
@@ -93,7 +89,6 @@ export const generalServerSyncWhiteListKeys: (keyof GeneralSettings)[] = [
export const enhancedGeneralSettingKeys = new Set<keyof GeneralSettings>([
"groupByDate",
"autoExpandLongSocialMedia",
"showCompactTimelineInSub",
])
const [
@@ -1,5 +1,4 @@
import { atom } from "jotai"
import type { ReactNode } from "react"
import { createAtomHooks } from "~/lib/jotai"
@@ -26,21 +25,3 @@ export const [
getSubscriptionColumnTempShow,
setSubscriptionColumnTempShow,
] = createAtomHooks(atom(false))
export const [
,
,
useSubscriptionColumnApronNode,
,
getSubscriptionColumnApronNode,
setSubscriptionColumnApronNode,
] = createAtomHooks(atom<ReactNode | null>(null))
export const [
,
,
useSubscriptionEntryPlaneVisible,
,
getSubscriptionEntryPlaneVisible,
setSubscriptionEntryPlaneVisible,
] = createAtomHooks(atom(true))
@@ -6,13 +6,11 @@ import { cn } from "@follow/utils"
import { isSafari } from "@follow/utils/utils"
import { AnimatePresence } from "motion/react"
import type { TransitionEvent } from "react"
import { memo, startTransition, useCallback, useEffect, useMemo, useRef, useState } from "react"
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react"
import { useResizable } from "react-resizable-layout"
import { AIChatPanelStyle, useAIChatPanelStyle, useAIPanelVisibility } from "~/atoms/settings/ai"
import { useGeneralSettingKey } from "~/atoms/settings/general"
import { getUISettings, setUISetting, useUISettingKey } from "~/atoms/settings/ui"
import { setSubscriptionColumnApronNode, useSubscriptionEntryPlaneVisible } from "~/atoms/sidebar"
import { m } from "~/components/common/Motion"
import { ROUTE_ENTRY_PENDING } from "~/constants"
import { useFeature } from "~/hooks/biz/useFeature"
@@ -23,8 +21,6 @@ import { AIChatLayout } from "~/modules/app-layout/ai/AIChatLayout"
import { AIIndicator } from "~/modules/app-layout/ai/AISplineButton"
import { EntryContentPlaceholder } from "~/modules/app-layout/entry-content/EntryContentPlaceholder"
import { EntryColumn } from "~/modules/entry-column"
import { EntryPlaneToolbar } from "~/modules/entry-column/components/EntryPlaneToolbar"
import { EntrySubscriptionList } from "~/modules/entry-column/EntrySubscriptionList"
import { EntryContent } from "~/modules/entry-content/components/entry-content"
import { AIEntryHeader } from "~/modules/entry-content/components/entry-header"
import { AppLayoutGridContainerProvider } from "~/providers/app-grid-layout-container-provider"
@@ -189,7 +185,6 @@ const AIEnhancedTimelineLayoutImpl = () => {
setShouldRenderDetailsColumn(false)
}, [showEntryDetailsColumn])
const showCompactTimelineColumn = useGeneralSettingKey("showCompactTimelineInSub")
return (
<div ref={layoutContainerRef} className="relative flex min-w-0 grow">
<div className="relative min-w-0 flex-1">
@@ -316,7 +311,6 @@ const AIEnhancedTimelineLayoutImpl = () => {
{/* Floating panel - renders outside layout flow */}
{aiPanelStyle === AIChatPanelStyle.Floating && <AIChatLayout key="ai-chat-layout" />}
{showCompactTimelineColumn && <SubscriptionColumnToggler />}
</div>
)
}
@@ -332,57 +326,3 @@ export const AIEnhancedTimelineLayout = memo(function AIEnhancedTimelineLayout()
)
})
AIEnhancedTimelineLayout.displayName = "AIEnhancedTimelineLayout"
const SubscriptionColumnToggler = () => {
const isInEntry = useRouteParamsSelector((s) => s.entryId !== ROUTE_ENTRY_PENDING)
useEffect(() => {
if (isInEntry) {
startTransition(() => {
setSubscriptionColumnApronNode(<SubscriptionEntryListPlaneNode />)
})
return () => {
startTransition(() => {
setSubscriptionColumnApronNode(null)
})
}
}
}, [isInEntry])
return null
}
const SubscriptionEntryListPlaneNode = () => {
const entryId = useRouteParamsSelector((s) => s.entryId)
const isVisible = useSubscriptionEntryPlaneVisible()
return (
<m.div
className={cn(
"absolute left-0 top-12 z-[2] rounded-r-lg bg-sidebar backdrop-blur-background",
isVisible ? "bottom-0 flex w-feed-col flex-col" : "w-[40px]",
)}
id="subscription-entry-list-plane-node"
initial={false}
animate={{
width: isVisible ? "var(--fo-feed-col-w, 256px)" : "40px",
}}
transition={Spring.presets.smooth}
>
<EntryPlaneToolbar />
<AnimatePresence mode="popLayout">
{isVisible && (
<m.div
key="entry-list"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.1 }}
className="flex w-feed-col flex-1 flex-col whitespace-pre"
>
<EntrySubscriptionList scrollToEntryId={entryId} />
</m.div>
)}
</AnimatePresence>
</m.div>
)
}
@@ -1,115 +0,0 @@
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
import type { FeedViewType } from "@follow/constants"
import { useEntry } from "@follow/store/entry/hooks"
import { useFeedById } from "@follow/store/feed/hooks"
import { clsx, cn } from "@follow/utils/utils"
import { memo, useCallback } from "react"
import { RelativeTime } from "~/components/ui/datetime"
import { useEntryContextMenu } from "~/hooks/biz/useEntryContextMenu"
import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry"
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
import { FeedIcon } from "~/modules/feed/feed-icon"
import { feedColumnStyles } from "~/modules/subscription-column/styles"
interface EntrySubscriptionItemProps {
entryId: string
view: FeedViewType
className?: string
isPreview?: boolean
}
const EntrySubscriptionItemImpl = ({ entryId, view, className }: EntrySubscriptionItemProps) => {
const navigate = useNavigateEntry()
// Use current route view for navigation to stay in current view
const currentRouteView = useRouteParamsSelector((s) => s.view)
const navigationView = currentRouteView ?? view
const entry = useEntry(entryId, (entry) => {
if (!entry) return null
return {
id: entry.id,
title: entry.title,
publishedAt: entry.publishedAt,
feedId: entry.feedId,
read: entry.read,
}
})
const feed = useFeedById(entry?.feedId, (feed) => {
if (!feed) return null
return {
id: feed.id,
type: feed.type || "feed",
title: feed.title,
image: feed.image,
siteUrl: feed.siteUrl,
url: feed.url,
}
})
const isActive = useRouteParamsSelector((routerParams) => routerParams.entryId === entryId)
const { contextMenuProps } = useEntryContextMenu({
entryId,
view: navigationView as FeedViewType,
feedId: entry?.feedId || "",
})
const handleClick = useCallback(
(e: React.MouseEvent<HTMLDivElement>) => {
e.stopPropagation()
if (navigationView === undefined || !entry) return
navigate({
feedId: entry.feedId,
entryId: entry.id,
view: navigationView,
})
},
[entry, navigate, navigationView],
)
if (!entry || !feed) return null
return (
<div
data-entry-id={entryId}
data-active={isActive}
className={cn(
feedColumnStyles.item,
"mx-1 w-[calc(100%_-0.5rem)] py-1 pl-2.5",
!entry.read && "font-medium",
className,
)}
onClick={handleClick}
{...contextMenuProps}
>
<div className="flex min-w-0 flex-1 items-start gap-2">
<FeedIcon fallback target={feed} size={14} className="mt-0.5 shrink-0" />
<div className="min-w-0 flex-1">
<EllipsisHorizontalTextWithTooltip
className={clsx("truncate text-sm leading-tight text-text", entry.read && "opacity-90")}
>
{entry.title}
</EllipsisHorizontalTextWithTooltip>
<div className="flex items-center gap-1 text-xs text-text-secondary opacity-80">
<EllipsisHorizontalTextWithTooltip className="max-w-24 truncate">
{feed.title}
</EllipsisHorizontalTextWithTooltip>
{entry.publishedAt && (
<>
<span>·</span>
<RelativeTime date={entry.publishedAt} />
</>
)}
</div>
</div>
</div>
</div>
)
}
export const EntrySubscriptionItem = memo(EntrySubscriptionItemImpl)
@@ -1,103 +0,0 @@
import { ScrollArea } from "@follow/components/ui/scroll-area/ScrollArea.js"
import type { FC, RefObject } from "react"
import { memo, startTransition, useEffect, useRef, useState } from "react"
import { EntrySubscriptionSkeleton } from "./components/EntrySubscriptionSkeleton"
import { useEntriesActions, useEntriesState } from "./context/EntriesContext"
import { EntrySubscriptionItem } from "./EntrySubscriptionItem"
import { useEntryVirtualizer } from "./hooks/subscription/useEntryVirtualizer"
export interface EntrySubscriptionListProps {
scrollToEntryId?: string
}
// Prevent scroll list move when press up/down key
const handleKeyDown: React.KeyboardEventHandler<HTMLDivElement> = (e) => {
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
e.preventDefault()
}
}
export const EntrySubscriptionList: FC<EntrySubscriptionListProps> = memo(({ scrollToEntryId }) => {
// Use shared context exclusively to guarantee full synchronization
const { entriesIds, hasNextPage, isFetchingNextPage, view } = useEntriesState()
const { fetchNextPage } = useEntriesActions()
const scrollAreaRef = useRef<HTMLDivElement>(null)
// Handle virtualization internally
const { rowVirtualizer, renderData, totalSize, scrollToEntry } = useEntryVirtualizer({
entriesIds,
scrollElement: scrollAreaRef as RefObject<HTMLElement>,
})
// Handle infinite loading
useEffect(() => {
const lastRenderItem = renderData.at(-1)
if (!lastRenderItem) return
if (lastRenderItem.isLoaderRow && hasNextPage && !isFetchingNextPage) {
fetchNextPage()
}
}, [renderData, hasNextPage, isFetchingNextPage, fetchNextPage])
const [ready, setReady] = useState(false)
useEffect(() => {
startTransition(() => {
setReady(true)
})
}, [])
useEffect(() => {
if (scrollToEntryId) {
scrollToEntry(scrollToEntryId)
}
}, [scrollToEntryId, scrollToEntry])
return (
<ScrollArea rootClassName="h-0 grow" ref={scrollAreaRef}>
<div
onKeyDown={handleKeyDown}
className="relative w-full select-none"
style={{
height: `${totalSize}px`,
}}
>
{renderData.map((item) => {
if (!ready) return null
if (item.isLoaderRow) {
const Content = hasNextPage ? <EntrySubscriptionSkeleton count={3} /> : null
return (
<div
ref={rowVirtualizer.measureElement}
className="absolute left-0 top-0 w-full will-change-transform"
key={item.key}
data-index={item.index}
style={{
transform: item.transform,
}}
>
{Content}
</div>
)
}
return (
<div
key={item.key}
className="absolute left-0 top-0 w-full will-change-transform"
style={{ transform: item.transform }}
ref={rowVirtualizer.measureElement}
data-index={item.index}
>
<EntrySubscriptionItem entryId={item.entryId!} view={view} />
</div>
)
})}
</div>
</ScrollArea>
)
})
EntrySubscriptionList.displayName = "EntrySubscriptionList"
@@ -1,69 +0,0 @@
import { ActionButton } from "@follow/components/ui/button/index.js"
import { cn, stopPropagation } from "@follow/utils"
import type { FC, SVGProps } from "react"
import { setSubscriptionEntryPlaneVisible, useSubscriptionEntryPlaneVisible } from "~/atoms/sidebar"
interface EntryPlaneToolbarProps {
className?: string
}
export const EntryPlaneToolbar: FC<EntryPlaneToolbarProps> = ({ className }) => {
const isVisible = useSubscriptionEntryPlaneVisible()
const handleToggle = () => {
setSubscriptionEntryPlaneVisible(!isVisible)
}
// When hidden, show only a compact toggle button
if (!isVisible) {
return (
<div className={cn("translate-y-2 p-2", className)} onClick={stopPropagation}>
<ActionButton tooltip="Show Entry List" size="sm" onClick={handleToggle}>
<MaterialSymbolsExpandContent />
</ActionButton>
</div>
)
}
// When visible, show full toolbar
return (
<div
onClick={stopPropagation}
className={cn(
"flex h-11 items-center justify-between px-2 text-xl text-text-secondary",
"shrink-0 backdrop-blur-background",
className,
)}
>
<div className="flex items-center gap-2 whitespace-pre">
<div className="text-sm font-medium">Entry List</div>
</div>
<ActionButton tooltip="Hide Entry List" size="sm" onClick={handleToggle}>
<MaterialSymbolsCollapseContentRounded />
</ActionButton>
</div>
)
}
function MaterialSymbolsCollapseContentRounded(props: SVGProps<SVGSVGElement>) {
return (
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}>
{/* Icon from Material Symbols by Google - https://github.com/google/material-design-icons/blob/master/LICENSE */}
<path
fill="currentColor"
d="M9 15H6q-.425 0-.712-.288T5 14t.288-.712T6 13h4q.425 0 .713.288T11 14v4q0 .425-.288.713T10 19t-.712-.288T9 18zm6-6h3q.425 0 .713.288T19 10t-.288.713T18 11h-4q-.425 0-.712-.288T13 10V6q0-.425.288-.712T14 5t.713.288T15 6z"
/>
</svg>
)
}
export function MaterialSymbolsExpandContent(props: SVGProps<SVGSVGElement>) {
return (
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}>
{/* Icon from Material Symbols by Google - https://github.com/google/material-design-icons/blob/master/LICENSE */}
<path fill="currentColor" d="M5 19v-6h2v4h4v2zm12-8V7h-4V5h6v6z" />
</svg>
)
}
@@ -1,47 +0,0 @@
import { cn } from "@follow/utils"
import type { FC } from "react"
import { feedColumnStyles } from "~/modules/subscription-column/styles"
interface EntrySubscriptionSkeletonProps {
count?: number
className?: string
}
const EntrySubscriptionSkeletonItem: FC<{ className?: string }> = ({ className }) => {
return (
<div
className={cn(feedColumnStyles.item, "mx-1 w-[calc(100%_-0.5rem)] py-1 pl-2.5", className)}
>
<div className="flex min-w-0 flex-1 items-start gap-2">
{/* Feed icon skeleton */}
<div className="mt-0.5 size-3.5 shrink-0 rounded-full bg-fill-secondary" />
<div className="min-w-0 flex-1 space-y-1">
{/* Title skeleton */}
<div className="space-y-1">
<div className="h-3.5 w-full rounded bg-fill-secondary" />
<div className="h-3.5 w-3/4 rounded bg-fill-secondary" />
</div>
{/* Meta info skeleton */}
<div className="flex items-center gap-1">
<div className="h-2.5 w-16 rounded bg-fill-tertiary" />
<div className="size-1 rounded-full bg-fill-tertiary" />
<div className="h-2.5 w-12 rounded bg-fill-tertiary" />
</div>
</div>
</div>
</div>
)
}
export const EntrySubscriptionSkeleton: FC<EntrySubscriptionSkeletonProps> = ({ count = 3 }) => {
return (
<div className="space-y-0">
{Array.from({ length: count }, (_, i) => (
<EntrySubscriptionSkeletonItem key={i} />
))}
</div>
)
}
@@ -1,73 +0,0 @@
import type { Range } from "@tanstack/react-virtual"
import type { RefObject } from "react"
import { useCallback, useMemo, useRef } from "react"
import { useEntryVirtualization } from "../useEntryVirtualization"
interface UseEntryVirtualizerOptions {
entriesIds: string[]
onRangeChange?: (range: Range) => void
scrollToEntryId?: string
scrollElement?: RefObject<HTMLElement> | (() => HTMLElement | null)
}
export const useEntryVirtualizer = ({
entriesIds,
onRangeChange,
scrollToEntryId,
scrollElement,
}: UseEntryVirtualizerOptions) => {
// Find scroll to index
const scrollToIndex = useMemo(() => {
if (scrollToEntryId) {
const index = entriesIds.indexOf(scrollToEntryId)
return index !== -1 ? { index, align: "start" as const } : undefined
}
return
}, [entriesIds, scrollToEntryId])
const virtualization = useEntryVirtualization({
count: entriesIds.length + 1, // +1 for loading placeholder
estimateSize: () => 48, // Smaller height for subscription column
overscan: 5,
cacheKey: "entry-subscription-list",
onRangeChange,
scrollToIndex,
scrollElement,
})
// Memoized render data with subscription-specific logic
const renderData = useMemo(() => {
return virtualization.renderData.map((item) => {
const isLoaderRow = item.index === entriesIds.length
return {
key: item.key,
index: item.index,
isLoaderRow,
transform: item.transform,
entryId: isLoaderRow ? null : entriesIds[item.index],
}
})
}, [virtualization.renderData, entriesIds])
const scrollToRef = useRef<typeof virtualization.scrollTo>(null)
scrollToRef.current = virtualization.scrollTo.bind(virtualization)
// Scroll to specific entry programmatically
const scrollToEntry = useCallback(
(entryId: string) => {
const index = entriesIds.indexOf(entryId)
if (index !== -1) {
scrollToRef.current?.(index, "center")
}
},
[entriesIds, scrollToRef],
)
return {
rowVirtualizer: virtualization.virtualizer,
renderData,
totalSize: virtualization.totalSize,
scrollToEntry,
}
}
@@ -138,10 +138,6 @@ export const SettingGeneral = () => {
label: t("general.dim_read.label"),
description: t("general.dim_read.description"),
}),
defineSettingItem("showCompactTimelineInSub", {
label: t("general.show_compact_timeline_in_sub.label"),
description: t("general.show_compact_timeline_in_sub.description"),
}),
{ type: "title", value: t("general.mark_as_read.title") },
@@ -17,11 +17,7 @@ import { memo, useCallback, useEffect, useLayoutEffect, useRef, useState } from
import { useRootContainerElement } from "~/atoms/dom"
import { useUISettingKey } from "~/atoms/settings/ui"
import {
setTimelineColumnShow,
useSubscriptionColumnApronNode,
useSubscriptionColumnShow,
} from "~/atoms/sidebar"
import { setTimelineColumnShow, useSubscriptionColumnShow } from "~/atoms/sidebar"
import { Focusable } from "~/components/common/Focusable"
import { HotkeyScope } from "~/constants"
import { useBackHome } from "~/hooks/biz/useNavigateEntry"
@@ -175,17 +171,11 @@ export function SubscriptionColumn({
</SwipeWrapper>
</div>
<ApronNodeContainer />
{children}
</WindowUnderBlur>
)
}
const ApronNodeContainer: FC = () => {
return useSubscriptionColumnApronNode()
}
const SwipeWrapper: FC<{ active: string; children: React.JSX.Element[] }> = memo(
({ children, active }) => {
const reduceMotion = useReduceMotion()
-2
View File
@@ -327,8 +327,6 @@
"general.rebuild_database.warning.line2": "Are you sure you want to continue?",
"general.send_anonymous_data.description": "By opting to send anonymized telemetry data, you contribute to improving the overall user experience of Folo.",
"general.send_anonymous_data.label": "Send anonymous data",
"general.show_compact_timeline_in_sub.description": "When viewing entry content, show timeline items in the left subscription column for quick selection.",
"general.show_compact_timeline_in_sub.label": "Show timeline in subscription column while reading",
"general.show_quick_timeline.description": "Show the quick timeline at the top of the feed list.",
"general.show_quick_timeline.label": "Show feed list timeline",
"general.show_unread_on_launch.description": "Automatically filter to unread content when the app starts.",
-2
View File
@@ -323,8 +323,6 @@
"general.rebuild_database.warning.line2": "本当に続行しますか?",
"general.send_anonymous_data.description": "匿名化されたテレメトリーデータを送信することにより、Folo の全体的なユーザーエクスペリエンスの向上に貢献します。",
"general.send_anonymous_data.label": "匿名データを送信",
"general.show_compact_timeline_in_sub.description": "記事コンテンツを閲覧中、左側の購読カラムにタイムラインの項目を表示して素早く選択できるようにします。",
"general.show_compact_timeline_in_sub.label": "読書中に購読カラムへタイムラインを表示",
"general.show_quick_timeline.description": "フィードリストの最上部にクイックタイムラインを表示する。",
"general.show_quick_timeline.label": "フィードリストにタイムラインを表示する",
"general.show_unread_on_launch.description": "アプリ起動時に未読コンテンツに自動的にフィルタリングします。",
-2
View File
@@ -323,8 +323,6 @@
"general.rebuild_database.warning.line2": "确定继续?",
"general.send_anonymous_data.description": "发送匿名用户数据,帮助产品改进和功能迭代。",
"general.send_anonymous_data.label": "发送匿名数据",
"general.show_compact_timeline_in_sub.description": "进入文章内容页时,在左侧订阅栏显示时间线条目以便快速选择。",
"general.show_compact_timeline_in_sub.label": "阅读时在订阅栏显示时间线",
"general.show_quick_timeline.description": "在时间线顶部显示列表和分类的时间线快递导航。",
"general.show_quick_timeline.label": "显示时间线快速导航",
"general.show_unread_on_launch.description": "应用启动时仅显示未读内容。",
-2
View File
@@ -288,8 +288,6 @@
"general.rebuild_database.warning.line2": "您確定要繼續嗎?",
"general.send_anonymous_data.description": "選擇傳送匿名使用資料,您將幫助改善 Folo 的整體使用體驗。",
"general.send_anonymous_data.label": "傳送匿名資料",
"general.show_compact_timeline_in_sub.description": "進入文章內容頁時,在左側訂閱欄顯示時間軸項目以便快速選擇。",
"general.show_compact_timeline_in_sub.label": "閱讀時在訂閱欄顯示時間軸",
"general.show_quick_timeline.description": "在 RSS 摘要列表頂部顯示快速時間軸。",
"general.show_quick_timeline.label": "顯示 RSS 摘要列表時間軸",
"general.sidebar_title": "一般",