Merge pull request #4738 from RSSNext/release/desktop/1.2.1
release(desktop): Release v1.2.1
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
# What's new in v1.2.1
|
||||
|
||||
## Shiny new things
|
||||
|
||||
- **AI**
|
||||
- Added **BYOK (Bring Your Own Key)** support — choose your own AI provider freely.
|
||||
- Improved **AI Memory**: you can now update or refine past memories whenever you need.
|
||||
- Reduced the “guiding tone” in **AI Summary** so summaries feel more natural and personal.
|
||||
- Introduced **AI Timeline Sort (Beta)**: your timeline can now rearrange itself based on your reading preferences.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
- **UI**
|
||||
- Several UI components have been refined with an improved design system for a cleaner, more consistent feel.
|
||||
|
||||
- **Subscription**
|
||||
- Added a new **Basic Plan (non-AI version)** for users who prefer a lighter subscription option.
|
||||
|
||||
- **Selection**
|
||||
- Added **underline sharing** and **Ask AI** directly from selected text to make reading actions smoother.
|
||||
|
||||
## Improvements
|
||||
|
||||
- **Feed**
|
||||
- RSSHub subscriptions now include a clear identifier, making source management easier.
|
||||
|
||||
- **Web**
|
||||
- You can now browse recommended content without logging in — explore before committing.
|
||||
|
||||
- **Onboarding**
|
||||
- The onboarding flow has been fully redesigned for a smoother, more intuitive first-time experience.
|
||||
|
||||
- **Entry**
|
||||
- Entries now come with AI-generated labels to help you sort and revisit content effortlessly.
|
||||
|
||||
## No longer broken
|
||||
|
||||
We fixed several bugs to make everything feel more stable and reliable.
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
## Shiny new things
|
||||
|
||||
- Onboarding: Re-designed the onboarding flow
|
||||
- AI:
|
||||
- Supports BYOK (Bring Your Own Key)
|
||||
- AI Memory tool has been improved, now can update your past memories
|
||||
- UI:
|
||||
- The design system of some UI components has been improved
|
||||
## Improvements
|
||||
|
||||
## No longer broken
|
||||
|
||||
## Thanks
|
||||
|
||||
Special thanks to volunteer contributors @ for their valuable contributions
|
||||
|
||||
@@ -18,7 +18,7 @@ const styles = {
|
||||
} as React.CSSProperties,
|
||||
innerGlow: {
|
||||
background:
|
||||
"linear-gradient(to bottom right, hsl(var(--fo-a) / 0.05), transparent, hsl(var(--fo-a) / 0.05))",
|
||||
"linear-gradient(to bottom right, hsl(var(--fo-a) / 0.01), transparent, hsl(var(--fo-a) / 0.01))",
|
||||
} as React.CSSProperties,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { nextFrame } from "@follow/utils/dom"
|
||||
import { getImageProxyUrl } from "@follow/utils/img-proxy"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { ErrorBoundary } from "@sentry/react"
|
||||
import { useForceUpdate } from "motion/react"
|
||||
@@ -9,6 +8,7 @@ import { memo, use, useEffect, useMemo, useRef, useState } from "react"
|
||||
import { Blurhash, BlurhashCanvas } from "react-blurhash"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { useGetImageProxyUrl } from "~/lib/img-proxy"
|
||||
import { saveImageDimensionsToDb } from "~/store/image/db"
|
||||
|
||||
import { useMediaContainerWidth, usePreviewMedia } from "./hooks"
|
||||
@@ -77,6 +77,7 @@ const MediaImpl: FC<MediaProps> = ({
|
||||
videoClassName,
|
||||
...rest
|
||||
} = props
|
||||
const getImageProxyUrl = useGetImageProxyUrl()
|
||||
|
||||
const ctxMediaInfo = use(MediaInfoRecordContext)
|
||||
const ctxHeight = ctxMediaInfo[src!]?.height
|
||||
@@ -121,7 +122,7 @@ const MediaImpl: FC<MediaProps> = ({
|
||||
}
|
||||
|
||||
return sources
|
||||
}, [src, proxy, preferOrigin])
|
||||
}, [src, proxy, preferOrigin, getImageProxyUrl])
|
||||
|
||||
const [currentSourceIndex, setCurrentSourceIndex] = useState(0)
|
||||
const [isError, setIsError] = useState(false)
|
||||
|
||||
@@ -18,7 +18,7 @@ import { m } from "~/components/common/Motion"
|
||||
import { GlassButton } from "~/components/ui/button/GlassButton"
|
||||
import { COPY_MAP } from "~/constants"
|
||||
import { ipcServices } from "~/lib/client"
|
||||
import { replaceImgUrlIfNeed } from "~/lib/img-proxy"
|
||||
import { useReplaceImgUrlIfNeed } from "~/lib/img-proxy"
|
||||
|
||||
import { useCurrentModal } from "../modal/stacked/hooks"
|
||||
import type { VideoPlayerRef } from "./VideoPlayer"
|
||||
@@ -421,6 +421,7 @@ const FallbackableImage: FC<
|
||||
onZoomChange?: (isZoomed: boolean) => void
|
||||
}
|
||||
> = ({ src, fallbackUrl, containerClassName, onZoomChange, loading }) => {
|
||||
const replaceImgUrlIfNeed = useReplaceImgUrlIfNeed()
|
||||
const [currentSrc, setCurrentSrc] = useState(() => replaceImgUrlIfNeed(src))
|
||||
const [isAllError, setIsAllError] = useState(false)
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { isMobile } from "@follow/components/hooks/useMobile.js"
|
||||
import { use, useCallback } from "react"
|
||||
|
||||
import { replaceImgUrlIfNeed } from "~/lib/img-proxy"
|
||||
|
||||
import { PlainModal } from "../modal/stacked/custom-modal"
|
||||
import { useModalStack } from "../modal/stacked/hooks"
|
||||
import { MediaContainerWidthContext } from "./MediaContainerWidthContext"
|
||||
@@ -17,7 +15,7 @@ export const usePreviewMedia = (children?: React.ReactNode) => {
|
||||
return
|
||||
}
|
||||
if (isMobile()) {
|
||||
window.open(replaceImgUrlIfNeed(media[initialIndex]!.url))
|
||||
window.open(media[initialIndex]!.url)
|
||||
return
|
||||
}
|
||||
present({
|
||||
|
||||
@@ -369,14 +369,6 @@ export const ModalInternal = memo(function Modal({
|
||||
cursor: "grabbing",
|
||||
}}
|
||||
>
|
||||
{/* Inner glow layer */}
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0 rounded-xl"
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(to bottom right, hsl(var(--fo-a) / 0.05), transparent, hsl(var(--fo-a) / 0.05))",
|
||||
}}
|
||||
/>
|
||||
<ResizeSwitch
|
||||
// enable={resizableOnly("bottomRight")}
|
||||
onResizeStart={handleResizeStart}
|
||||
|
||||
@@ -27,7 +27,7 @@ import { COMMAND_ID } from "~/modules/command/commands/id"
|
||||
import { getCommand, useRunCommandFn } from "~/modules/command/hooks/use-command"
|
||||
import { useCommandShortcuts } from "~/modules/command/hooks/use-command-binding"
|
||||
import { isMutationCommandId } from "~/modules/command/mutation-command-ids"
|
||||
import type { FollowCommandId } from "~/modules/command/types"
|
||||
import type { FollowCommandId, UnknownCommand } from "~/modules/command/types"
|
||||
import { useToolbarOrderMap } from "~/modules/customize-toolbar/hooks"
|
||||
|
||||
import { useRouteParams } from "./useRouteParams"
|
||||
@@ -446,7 +446,7 @@ export const useEntryActions = ({ entryId, view }: { entryId: string; view: Feed
|
||||
onClick: runCmdFn(COMMAND_ID.integration.custom, [{ entryId }]),
|
||||
entryId,
|
||||
children: enabledIntegrations.map((integration) => {
|
||||
const virtualId = `integration:custom:${integration.id}` as FollowCommandId
|
||||
const virtualId = `integration:custom:${integration.id}` as UnknownCommand["id"]
|
||||
return new EntryActionMenuItem({
|
||||
id: virtualId,
|
||||
onClick: () => {
|
||||
|
||||
@@ -331,6 +331,15 @@ export const useListActions = ({ listId, view }: { listId: string; view?: FeedVi
|
||||
if (!list) return []
|
||||
|
||||
const items: MenuItemInput[] = [
|
||||
new MenuItemText({
|
||||
label: t("sidebar.feed_actions.mark_all_as_read"),
|
||||
shortcut: shortcuts[COMMAND_ID.subscription.markAllAsRead],
|
||||
click: () => {
|
||||
unreadSyncService.markFeedAsRead(list.feedIds)
|
||||
},
|
||||
requiresLogin: true,
|
||||
}),
|
||||
MenuItemSeparator.default,
|
||||
new MenuItemText({
|
||||
label: t("sidebar.feed_actions.edit"),
|
||||
shortcut: "E",
|
||||
@@ -349,15 +358,6 @@ export const useListActions = ({ listId, view }: { listId: string; view?: FeedVi
|
||||
requiresLogin: true,
|
||||
}),
|
||||
MenuItemSeparator.default,
|
||||
new MenuItemText({
|
||||
label: t("sidebar.feed_actions.mark_all_as_read"),
|
||||
shortcut: shortcuts[COMMAND_ID.subscription.markAllAsRead],
|
||||
click: () => {
|
||||
unreadSyncService.markFeedAsRead(list.feedIds)
|
||||
},
|
||||
requiresLogin: true,
|
||||
}),
|
||||
MenuItemSeparator.default,
|
||||
...(list.ownerUserId === whoami()?.id
|
||||
? [
|
||||
new MenuItemText({
|
||||
|
||||
@@ -22,3 +22,30 @@ export const readFromClipboard = async (): Promise<string> => {
|
||||
throw new Error(message)
|
||||
}
|
||||
}
|
||||
|
||||
export const copyImageToClipboard = async (canvas: HTMLCanvasElement): Promise<void> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
canvas.toBlob(async (blob) => {
|
||||
if (!blob) {
|
||||
const error = new Error("Failed to create image blob")
|
||||
reject(error)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await navigator.clipboard.write([
|
||||
new ClipboardItem({
|
||||
[blob.type]: blob,
|
||||
}),
|
||||
])
|
||||
resolve()
|
||||
} catch (e) {
|
||||
const message =
|
||||
"Unable to copy image to clipboard. Please ensure clipboard permissions are granted."
|
||||
console.error(e)
|
||||
toast.error(message)
|
||||
reject(new Error(message))
|
||||
}
|
||||
}, "image/png")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,9 +1,40 @@
|
||||
import { WEB_BUILD } from "@follow/shared/constants"
|
||||
import { replaceImgUrlIfNeed as replaceImgUrlIfNeedUtils } from "@follow/utils/img-proxy"
|
||||
import { useUserRole } from "@follow/store/user/hooks"
|
||||
import {
|
||||
getImageProxyUrl as getImageProxyUrlUtils,
|
||||
replaceImgUrlIfNeed as replaceImgUrlIfNeedUtils,
|
||||
} from "@follow/utils/img-proxy"
|
||||
|
||||
export const replaceImgUrlIfNeed = (url?: string) => {
|
||||
return replaceImgUrlIfNeedUtils({
|
||||
url,
|
||||
inBrowser: WEB_BUILD,
|
||||
})
|
||||
import { useServerConfigs } from "~/atoms/server-configs"
|
||||
|
||||
export const useCanUseImageProxy = () => {
|
||||
const userRole = useUserRole()
|
||||
const serverConfig = useServerConfigs()
|
||||
const canUseProxy =
|
||||
!userRole ||
|
||||
serverConfig?.PAYMENT_PLAN_LIST.find((i) => i.role === userRole)?.limit.SECURE_IMAGE_PROXY
|
||||
return canUseProxy
|
||||
}
|
||||
|
||||
export const useReplaceImgUrlIfNeed = () => {
|
||||
const canUseProxy = useCanUseImageProxy()
|
||||
|
||||
return (url?: string) => {
|
||||
return replaceImgUrlIfNeedUtils({
|
||||
url,
|
||||
inBrowser: WEB_BUILD,
|
||||
canUseProxy,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const useGetImageProxyUrl = () => {
|
||||
const canUseProxy = useCanUseImageProxy()
|
||||
|
||||
return (params: Omit<Parameters<typeof getImageProxyUrlUtils>[0], "canUseProxy">) => {
|
||||
return getImageProxyUrlUtils({
|
||||
canUseProxy,
|
||||
...params,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,19 @@
|
||||
* Simple text selection utilities for ShadowDOM
|
||||
*/
|
||||
|
||||
export interface SelectionRect {
|
||||
top: number
|
||||
right: number
|
||||
bottom: number
|
||||
left: number
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
|
||||
export interface TextSelectionEvent {
|
||||
selectedText: string
|
||||
timestamp: number
|
||||
rect: SelectionRect
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,21 +38,23 @@ export function addTextSelectionListener(
|
||||
try {
|
||||
const range = selection.getRangeAt(0)
|
||||
if (!shadowRoot.contains(range.commonAncestorContainer)) return
|
||||
|
||||
if (!selection.isCollapsed) {
|
||||
const selectedText = selection.toString().trim()
|
||||
if (selectedText) {
|
||||
onTextSelect({
|
||||
selectedText,
|
||||
timestamp: Date.now(),
|
||||
rect: normalizeRect(range.getBoundingClientRect()),
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
// Uncaught IndexSizeError: Failed to execute 'getRangeAt' on 'Selection': 0 is not a valid index.
|
||||
return
|
||||
}
|
||||
if (!selection.isCollapsed) {
|
||||
const selectedText = selection.toString().trim()
|
||||
if (selectedText) {
|
||||
onTextSelect({
|
||||
selectedText,
|
||||
timestamp: Date.now(),
|
||||
})
|
||||
}
|
||||
} else {
|
||||
onSelectionClear?.()
|
||||
}
|
||||
onSelectionClear?.()
|
||||
}, 200)
|
||||
}
|
||||
|
||||
@@ -53,3 +65,14 @@ export function addTextSelectionListener(
|
||||
document.removeEventListener("selectionchange", handleSelectionChange)
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeRect(rect: DOMRect | DOMRectReadOnly): SelectionRect {
|
||||
return {
|
||||
top: rect.top,
|
||||
right: rect.right,
|
||||
bottom: rect.bottom,
|
||||
left: rect.left,
|
||||
width: rect.width,
|
||||
height: rect.height,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,21 +85,23 @@ class AIChatSessionServiceStatic {
|
||||
force?: boolean
|
||||
},
|
||||
): Promise<void> {
|
||||
const [dbSession, hasPersistedMessages] = await Promise.all([
|
||||
const [dbSession, hasPersistedMessages, needsMetadataBackfill] = await Promise.all([
|
||||
AIPersistService.getChatSession(session.chatId),
|
||||
AIPersistService.hasPersistedMessages(session.chatId),
|
||||
AIPersistService.hasAssistantMessagesMissingMetadata(session.chatId),
|
||||
])
|
||||
|
||||
const lastUpdatedAt = dbSession ? dbSession.updatedAt : new Date(0)
|
||||
const hasUpToDateSession = lastUpdatedAt >= new Date(session.updatedAt)
|
||||
|
||||
if (!options?.force && hasUpToDateSession && hasPersistedMessages) {
|
||||
if (!options?.force && hasUpToDateSession && hasPersistedMessages && !needsMetadataBackfill) {
|
||||
// If local session is already up-to-date, skip fetching messages
|
||||
return
|
||||
}
|
||||
const referenceLastSeenAt = session.lastSeenAt ? new Date(session.lastSeenAt) : new Date(0)
|
||||
const unseenMessages = await this.fetchUnseenRemoteMessages(
|
||||
session.chatId,
|
||||
new Date(session.lastSeenAt),
|
||||
needsMetadataBackfill ? new Date(0) : referenceLastSeenAt,
|
||||
)
|
||||
const normalized = unseenMessages.map(this.normalizeRemoteMessage)
|
||||
|
||||
|
||||
+5
-4
@@ -160,8 +160,7 @@ export const ChatHistoryDropdown = ({
|
||||
session={session}
|
||||
onClick={() => handleSessionSelect(session)}
|
||||
onDelete={(e) => {
|
||||
setLoadingChatId(session.chatId)
|
||||
handleDeleteSession(session.chatId, e).finally(() => {
|
||||
handleDeleteSession(session.chatId, { event: e }).finally(() => {
|
||||
setLoadingChatId(null)
|
||||
})
|
||||
}}
|
||||
@@ -183,8 +182,10 @@ export const ChatHistoryDropdown = ({
|
||||
session={session}
|
||||
onClick={() => handleSessionSelect(session)}
|
||||
onDelete={(e) => {
|
||||
setLoadingChatId(session.chatId)
|
||||
handleDeleteSession(session.chatId, e).finally(() => {
|
||||
handleDeleteSession(session.chatId, {
|
||||
event: e,
|
||||
onBeforeDelete: () => setLoadingChatId(session.chatId),
|
||||
}).finally(() => {
|
||||
setLoadingChatId(null)
|
||||
})
|
||||
}}
|
||||
|
||||
@@ -15,7 +15,7 @@ import { COMMAND_ID } from "~/modules/command/commands/id"
|
||||
import { getCommand } from "~/modules/command/hooks/use-command"
|
||||
import { useCommandShortcut } from "~/modules/command/hooks/use-command-binding"
|
||||
|
||||
import { FileUploadPlugin, MentionPlugin, ShortcutPlugin } from "../../editor"
|
||||
import { FileUploadPlugin, MentionPlugin, SelectedTextPlugin, ShortcutPlugin } from "../../editor"
|
||||
import { useMainEntryId } from "../../hooks/useMainEntryId"
|
||||
import { AIPanelRefsContext } from "../../store/AIChatContext"
|
||||
import { useChatActions, useChatScene, useChatStatus } from "../../store/hooks"
|
||||
@@ -173,7 +173,9 @@ export const ChatInput = memo(
|
||||
onKeyDown={handleKeyDown}
|
||||
autoFocus
|
||||
plugins={
|
||||
scene === "onboarding" ? [] : [MentionPlugin, ShortcutPlugin, FileUploadPlugin]
|
||||
scene === "onboarding"
|
||||
? []
|
||||
: [MentionPlugin, ShortcutPlugin, FileUploadPlugin, SelectedTextPlugin]
|
||||
}
|
||||
namespace="AIChatRichEditor"
|
||||
/>
|
||||
|
||||
+187
-102
@@ -1,16 +1,21 @@
|
||||
import { useFocusable } from "@follow/components/common/Focusable/hooks.js"
|
||||
import type { LexicalRichEditorRef } from "@follow/components/ui/lexical-rich-editor/types.js"
|
||||
import {
|
||||
convertLexicalToMarkdown,
|
||||
getEditorStateJSONString,
|
||||
} from "@follow/components/ui/lexical-rich-editor/utils.js"
|
||||
import { isFreeRole } from "@follow/constants"
|
||||
import { getCategoryFeedIds } from "@follow/store/subscription/getter"
|
||||
import { usePrefetchSummary } from "@follow/store/summary/hooks"
|
||||
import { useUserRole } from "@follow/store/user/hooks"
|
||||
import { tracker } from "@follow/tracker"
|
||||
import { detectIsEditableElement, nextFrame } from "@follow/utils"
|
||||
import type { ConfigResponse } from "@follow-app/client-sdk"
|
||||
import { ErrorBoundary } from "@sentry/react"
|
||||
import type { EditorState } from "lexical"
|
||||
import { createEditor } from "lexical"
|
||||
import { nanoid } from "nanoid"
|
||||
import type { RefObject } from "react"
|
||||
import { use, useEffect, useMemo, useRef, useState } from "react"
|
||||
import { useEventCallback, useEventListener } from "usehooks-ts"
|
||||
|
||||
@@ -56,31 +61,14 @@ const ChatInterfaceContent = ({ centerInputOnEmpty }: ChatInterfaceProps) => {
|
||||
const error = useChatError()
|
||||
const messages = useMessages()
|
||||
const { ensureLogin } = useRequireLogin()
|
||||
const userRole = useUserRole()
|
||||
|
||||
const isFocusWithIn = useFocusable()
|
||||
const isFocusWithin = useFocusable()
|
||||
|
||||
const aiPanelRefs = use(AIPanelRefsContext)
|
||||
|
||||
useEventListener("keydown", (e) => {
|
||||
if (isFocusWithIn) {
|
||||
const currentActiveElement = document.activeElement
|
||||
|
||||
if (detectIsEditableElement(currentActiveElement as HTMLElement)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (e.shiftKey || e.metaKey || e.ctrlKey) {
|
||||
return
|
||||
}
|
||||
aiPanelRefs.inputRef?.current?.focus()
|
||||
}
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (error) {
|
||||
console.error("AIChat Error:", error)
|
||||
}
|
||||
}, [error])
|
||||
useChatInputFocusHandler(isFocusWithin, aiPanelRefs.inputRef)
|
||||
useLogChatError(error)
|
||||
|
||||
const currentChatId = useCurrentChatId()
|
||||
const mainEntryId = useMainEntryId()
|
||||
@@ -93,15 +81,16 @@ const ChatInterfaceContent = ({ centerInputOnEmpty }: ChatInterfaceProps) => {
|
||||
enabled: !!mainEntryId && !hasMessages,
|
||||
})
|
||||
|
||||
const [scrollAreaRef, setScrollAreaRef] = useState<HTMLDivElement | null>(null)
|
||||
const [messageContainerMinHeight, setMessageContainerMinHeight] = useState<number | undefined>()
|
||||
const previousMinHeightRef = useRef<number>(0)
|
||||
const messagesContentRef = useRef<HTMLDivElement | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
setMessageContainerMinHeight(undefined)
|
||||
previousMinHeightRef.current = 0
|
||||
}, [currentChatId])
|
||||
const {
|
||||
scrollAreaRef,
|
||||
setScrollAreaRef,
|
||||
messageContainerMinHeight,
|
||||
messagesContentRef,
|
||||
scrollContainerParentRef,
|
||||
captureContentHeightBeforeSend,
|
||||
handleScrollPositioning,
|
||||
updateContentHeightSnapshot,
|
||||
} = useChatScroller(currentChatId)
|
||||
|
||||
const { isLoading: isLoadingHistory, isSyncingRemote } = useLoadMessages(currentChatId || "", {
|
||||
onLoad: () => {
|
||||
@@ -120,27 +109,7 @@ const ChatInterfaceContent = ({ centerInputOnEmpty }: ChatInterfaceProps) => {
|
||||
|
||||
const autoScrollWhenStreaming = useAISettingKey("autoScrollWhenStreaming")
|
||||
|
||||
const { shouldShowInterruptionNotice, lastUserMessage } = useMemo(() => {
|
||||
if (messages.length === 0) {
|
||||
return {
|
||||
shouldShowInterruptionNotice: false,
|
||||
lastUserMessage: null as BizUIMessage | null,
|
||||
}
|
||||
}
|
||||
|
||||
const lastMessage = messages.at(-1)!
|
||||
|
||||
const shouldShow =
|
||||
lastMessage.role === "user" &&
|
||||
status !== "streaming" &&
|
||||
status !== "error" &&
|
||||
status !== "submitted"
|
||||
|
||||
return {
|
||||
shouldShowInterruptionNotice: shouldShow,
|
||||
lastUserMessage: shouldShow ? lastMessage : null,
|
||||
}
|
||||
}, [messages, status])
|
||||
const { shouldShowInterruptionNotice, lastUserMessage } = useInterruptionNotice(messages, status)
|
||||
|
||||
const { resetScrollState } = useAutoScroll(
|
||||
scrollAreaRef,
|
||||
@@ -149,32 +118,6 @@ const ChatInterfaceContent = ({ centerInputOnEmpty }: ChatInterfaceProps) => {
|
||||
|
||||
const blockActions = useBlockActions()
|
||||
|
||||
const scrollHeightBeforeSendingRef = useRef<number>(0)
|
||||
const scrollContainerParentRef = useRef<HTMLDivElement | null>(null)
|
||||
const handleScrollPositioning = useEventCallback(() => {
|
||||
const $scrollContainerParent = scrollContainerParentRef.current
|
||||
if (!scrollAreaRef || !$scrollContainerParent) return
|
||||
|
||||
const parentClientHeight = $scrollContainerParent.clientHeight
|
||||
// Use actual content height captured before send (messages container height), not inflated by minHeight
|
||||
const currentScrollHeight = scrollHeightBeforeSendingRef.current
|
||||
|
||||
// Calculate new minimum height based on actual content height
|
||||
// Use previousMinHeightRef which tracks the real content height, not reserved space
|
||||
const baseHeight = Math.max(previousMinHeightRef.current, currentScrollHeight)
|
||||
const newMinHeight = baseHeight + parentClientHeight - 250
|
||||
|
||||
setMessageContainerMinHeight(newMinHeight)
|
||||
|
||||
// Scroll to the end immediately to position user message at top
|
||||
nextFrame(() => {
|
||||
scrollAreaRef.scrollTo({
|
||||
top: scrollAreaRef.scrollHeight,
|
||||
behavior: "instant",
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
const staticEditor = useMemo(() => {
|
||||
return createEditor({
|
||||
nodes: LexicalAIEditorNodes,
|
||||
@@ -244,8 +187,7 @@ const ChatInterfaceContent = ({ centerInputOnEmpty }: ChatInterfaceProps) => {
|
||||
})
|
||||
}
|
||||
|
||||
// Capture actual content height (messages container), not including reserved minHeight
|
||||
scrollHeightBeforeSendingRef.current = messagesContentRef.current?.scrollHeight ?? 0
|
||||
captureContentHeightBeforeSend()
|
||||
const messageId = prefixMessageIdWithShortcut(nanoid(), shortcutIdFromMessage)
|
||||
const sendMessage: SendingUIMessage = {
|
||||
parts,
|
||||
@@ -256,9 +198,7 @@ const ChatInterfaceContent = ({ centerInputOnEmpty }: ChatInterfaceProps) => {
|
||||
tracker.aiChatMessageSent()
|
||||
|
||||
// Clear draft message after sending
|
||||
if (currentChatId) {
|
||||
draftMessages.delete(currentChatId)
|
||||
}
|
||||
clearDraft()
|
||||
|
||||
nextFrame(() => {
|
||||
// Calculate and adjust scroll positioning immediately
|
||||
@@ -285,7 +225,7 @@ const ChatInterfaceContent = ({ centerInputOnEmpty }: ChatInterfaceProps) => {
|
||||
const retryShortcutId = extractShortcutIdFromMessageParts(retryMessage.parts)
|
||||
retryMessage.id = prefixMessageIdWithShortcut(retryMessage.id, retryShortcutId)
|
||||
|
||||
scrollHeightBeforeSendingRef.current = messagesContentRef.current?.scrollHeight ?? 0
|
||||
captureContentHeightBeforeSend()
|
||||
|
||||
chatActions.popMessage()
|
||||
void chatActions.sendMessage(retryMessage)
|
||||
@@ -296,15 +236,7 @@ const ChatInterfaceContent = ({ centerInputOnEmpty }: ChatInterfaceProps) => {
|
||||
})
|
||||
})
|
||||
|
||||
// Save draft message when input changes
|
||||
const handleDraftChange = useEventCallback((editorState: EditorState) => {
|
||||
if (currentChatId) {
|
||||
draftMessages.set(currentChatId, editorState)
|
||||
}
|
||||
})
|
||||
|
||||
// Get initial draft message for current chat
|
||||
const initialDraft = currentChatId ? draftMessages.get(currentChatId) : undefined
|
||||
const { handleDraftChange, initialDraft, clearDraft } = useChatDraft(currentChatId)
|
||||
|
||||
const [bottomPanelHeight, setBottomPanelHeight] = useState<number>(0)
|
||||
|
||||
@@ -317,23 +249,20 @@ const ChatInterfaceContent = ({ centerInputOnEmpty }: ChatInterfaceProps) => {
|
||||
// This avoids CLS while ensuring next calculation is based on actual content
|
||||
if (status === "ready" && scrollAreaRef && messagesContentRef.current) {
|
||||
// Update the reference to actual content height for next calculation (use messages container)
|
||||
previousMinHeightRef.current = messagesContentRef.current.scrollHeight
|
||||
updateContentHeightSnapshot()
|
||||
// Keep the current minHeight unchanged to avoid CLS
|
||||
}
|
||||
}, [status, resetScrollState, messageContainerMinHeight, scrollAreaRef])
|
||||
}, [status, resetScrollState, scrollAreaRef, updateContentHeightSnapshot, messagesContentRef])
|
||||
|
||||
const { handleScroll } = useAttachScrollBeyond()
|
||||
|
||||
const { data: configuration } = useAIConfiguration()
|
||||
const shouldHideResetDetails = userRole ? isFreeRole(userRole) : false
|
||||
|
||||
const isRateLimited = useMemo(
|
||||
() => computeIsRateLimited(error, configuration),
|
||||
[error, configuration],
|
||||
)
|
||||
|
||||
const rateLimitMessage = useMemo(
|
||||
() => computeRateLimitMessage(error, configuration),
|
||||
[error, configuration],
|
||||
const { isRateLimited, rateLimitMessage } = useRateLimitInfo(
|
||||
error,
|
||||
configuration,
|
||||
shouldHideResetDetails,
|
||||
)
|
||||
|
||||
return (
|
||||
@@ -381,3 +310,159 @@ export const ChatInterface = (props: ChatInterfaceProps) => (
|
||||
<ChatInterfaceContent {...props} />
|
||||
</ErrorBoundary>
|
||||
)
|
||||
|
||||
const useChatInputFocusHandler = (
|
||||
isFocusWithin: boolean,
|
||||
inputRef?: RefObject<LexicalRichEditorRef>,
|
||||
) => {
|
||||
useEventListener("keydown", (event) => {
|
||||
if (!isFocusWithin) {
|
||||
return
|
||||
}
|
||||
const currentActiveElement = document.activeElement
|
||||
|
||||
if (detectIsEditableElement(currentActiveElement as HTMLElement)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (event.shiftKey || event.metaKey || event.ctrlKey) {
|
||||
return
|
||||
}
|
||||
|
||||
inputRef?.current?.focus()
|
||||
})
|
||||
}
|
||||
|
||||
const useLogChatError = (error: unknown) => {
|
||||
useEffect(() => {
|
||||
if (error) {
|
||||
console.error("AIChat Error:", error)
|
||||
}
|
||||
}, [error])
|
||||
}
|
||||
|
||||
const useInterruptionNotice = (
|
||||
messages: BizUIMessage[],
|
||||
status: ReturnType<typeof useChatStatus>,
|
||||
) => {
|
||||
return useMemo(() => {
|
||||
if (messages.length === 0) {
|
||||
return {
|
||||
shouldShowInterruptionNotice: false,
|
||||
lastUserMessage: null as BizUIMessage | null,
|
||||
}
|
||||
}
|
||||
|
||||
const lastMessage = messages.at(-1)!
|
||||
const shouldShow =
|
||||
lastMessage.role === "user" &&
|
||||
status !== "streaming" &&
|
||||
status !== "error" &&
|
||||
status !== "submitted"
|
||||
|
||||
return {
|
||||
shouldShowInterruptionNotice: shouldShow,
|
||||
lastUserMessage: shouldShow ? lastMessage : null,
|
||||
}
|
||||
}, [messages, status])
|
||||
}
|
||||
|
||||
const useChatDraft = (currentChatId?: string | null) => {
|
||||
const handleDraftChange = useEventCallback((editorState: EditorState) => {
|
||||
if (currentChatId) {
|
||||
draftMessages.set(currentChatId, editorState)
|
||||
}
|
||||
})
|
||||
|
||||
const clearDraft = useEventCallback(() => {
|
||||
if (currentChatId) {
|
||||
draftMessages.delete(currentChatId)
|
||||
}
|
||||
})
|
||||
|
||||
const initialDraft = currentChatId ? draftMessages.get(currentChatId) : undefined
|
||||
|
||||
return {
|
||||
handleDraftChange,
|
||||
initialDraft,
|
||||
clearDraft,
|
||||
}
|
||||
}
|
||||
|
||||
const useRateLimitInfo = (
|
||||
error: Error | string | undefined,
|
||||
configuration: ConfigResponse | undefined,
|
||||
shouldHideResetDetails: boolean,
|
||||
) => {
|
||||
const isRateLimited = useMemo(
|
||||
() => computeIsRateLimited(error, configuration),
|
||||
[error, configuration],
|
||||
)
|
||||
|
||||
const rateLimitMessage = useMemo(
|
||||
() =>
|
||||
computeRateLimitMessage(error, configuration, {
|
||||
hideResetDetails: shouldHideResetDetails,
|
||||
}),
|
||||
[error, configuration, shouldHideResetDetails],
|
||||
)
|
||||
|
||||
return {
|
||||
isRateLimited,
|
||||
rateLimitMessage,
|
||||
}
|
||||
}
|
||||
|
||||
const useChatScroller = (currentChatId?: string | null) => {
|
||||
const [scrollAreaRef, setScrollAreaRef] = useState<HTMLDivElement | null>(null)
|
||||
const [messageContainerMinHeight, setMessageContainerMinHeight] = useState<number | undefined>()
|
||||
const messagesContentRef = useRef<HTMLDivElement | null>(null)
|
||||
const scrollContainerParentRef = useRef<HTMLDivElement | null>(null)
|
||||
const scrollHeightBeforeSendingRef = useRef<number>(0)
|
||||
const previousMinHeightRef = useRef<number>(0)
|
||||
|
||||
useEffect(() => {
|
||||
setMessageContainerMinHeight(undefined)
|
||||
previousMinHeightRef.current = 0
|
||||
}, [currentChatId])
|
||||
|
||||
const captureContentHeightBeforeSend = useEventCallback(() => {
|
||||
scrollHeightBeforeSendingRef.current = messagesContentRef.current?.scrollHeight ?? 0
|
||||
})
|
||||
|
||||
const handleScrollPositioning = useEventCallback(() => {
|
||||
const $scrollContainerParent = scrollContainerParentRef.current
|
||||
if (!scrollAreaRef || !$scrollContainerParent) return
|
||||
|
||||
const parentClientHeight = $scrollContainerParent.clientHeight
|
||||
const currentScrollHeight = scrollHeightBeforeSendingRef.current
|
||||
const baseHeight = Math.max(previousMinHeightRef.current, currentScrollHeight)
|
||||
const newMinHeight = baseHeight + parentClientHeight - 250
|
||||
|
||||
setMessageContainerMinHeight(newMinHeight)
|
||||
|
||||
nextFrame(() => {
|
||||
scrollAreaRef.scrollTo({
|
||||
top: scrollAreaRef.scrollHeight,
|
||||
behavior: "instant",
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
const updateContentHeightSnapshot = useEventCallback(() => {
|
||||
if (scrollAreaRef && messagesContentRef.current) {
|
||||
previousMinHeightRef.current = messagesContentRef.current.scrollHeight
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
scrollAreaRef,
|
||||
setScrollAreaRef,
|
||||
messageContainerMinHeight,
|
||||
messagesContentRef,
|
||||
scrollContainerParentRef,
|
||||
captureContentHeightBeforeSend,
|
||||
handleScrollPositioning,
|
||||
updateContentHeightSnapshot,
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -111,8 +111,10 @@ export const TaskReportDropdown = ({ triggerElement, asChild = true }: TaskRepor
|
||||
session={session}
|
||||
onClick={() => handleSessionSelect(session)}
|
||||
onDelete={(e) => {
|
||||
setLoadingChatId(session.chatId)
|
||||
handleDeleteSession(session.chatId, e).finally(() => {
|
||||
handleDeleteSession(session.chatId, {
|
||||
event: e,
|
||||
onBeforeDelete: () => setLoadingChatId(session.chatId),
|
||||
}).finally(() => {
|
||||
setLoadingChatId(null)
|
||||
})
|
||||
}}
|
||||
|
||||
+3
-3
@@ -21,12 +21,12 @@ export interface EmptyStateProps {
|
||||
icon?: ReactNode
|
||||
}
|
||||
|
||||
// Components
|
||||
export const SessionItem = ({
|
||||
session,
|
||||
onClick,
|
||||
onDelete,
|
||||
isLoading,
|
||||
|
||||
isLoading = false,
|
||||
hasUnread = false,
|
||||
}: SessionItemProps) => {
|
||||
const hasUnreadMessages = isUnreadSession(session)
|
||||
@@ -56,8 +56,8 @@ export const SessionItem = ({
|
||||
<button
|
||||
type="button"
|
||||
onClick={onDelete}
|
||||
className="absolute inset-y-0 right-0 flex items-center bg-accent px-2 py-1 text-white opacity-0 shadow-lg backdrop-blur-sm group-data-[highlighted]:text-white group-data-[highlighted]:opacity-100"
|
||||
disabled={isLoading}
|
||||
className="absolute inset-y-0 right-0 flex items-center rounded-md bg-accent px-2 py-1 text-white opacity-0 group-data-[highlighted]:text-white group-data-[highlighted]:opacity-100"
|
||||
>
|
||||
{isLoading ? (
|
||||
<i className="i-mgc-loading-3-cute-re size-4 animate-spin" />
|
||||
|
||||
+10
-3
@@ -63,9 +63,15 @@ export const useChatSessionHandlers = ({ sessions = [] }: UseChatSessionHandlers
|
||||
)
|
||||
|
||||
const handleDeleteSession = useCallback(
|
||||
async (chatId: string, e: React.MouseEvent) => {
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
async (
|
||||
chatId: string,
|
||||
options: {
|
||||
event?: React.MouseEvent
|
||||
onBeforeDelete?: () => void
|
||||
} = {},
|
||||
) => {
|
||||
options.event?.stopPropagation()
|
||||
options.event?.preventDefault()
|
||||
|
||||
const session = sessions?.find((s) => s.chatId === chatId)
|
||||
if (!session) return
|
||||
@@ -77,6 +83,7 @@ export const useChatSessionHandlers = ({ sessions = [] }: UseChatSessionHandlers
|
||||
})
|
||||
|
||||
if (!confirm) return
|
||||
options.onBeforeDelete?.()
|
||||
|
||||
try {
|
||||
// Only delete AI chat sessions through the mutation
|
||||
|
||||
+10
-12
@@ -105,9 +105,9 @@ export const AIChatMessage: React.FC<AIChatMessageProps> = React.memo(
|
||||
|
||||
return (
|
||||
<div onContextMenu={stopPropagation} className="group flex justify-start">
|
||||
<div className="relative flex max-w-full flex-col gap-2 text-text">
|
||||
<div className="relative flex w-full max-w-full flex-col gap-2 text-text">
|
||||
{/* Normal message display */}
|
||||
<div className="text-text">
|
||||
<div className="w-full text-text">
|
||||
<div className="flex cursor-text select-text flex-col gap-2 text-sm">
|
||||
<AIMessageParts message={message} isLastMessage={isLastMessage} />
|
||||
</div>
|
||||
@@ -129,16 +129,14 @@ export const AIChatMessage: React.FC<AIChatMessageProps> = React.memo(
|
||||
<span>Copy</span>
|
||||
</button>
|
||||
|
||||
{message.metadata && (
|
||||
<TokenUsagePill metadata={message.metadata}>
|
||||
<button
|
||||
type="button"
|
||||
className="absolute right-0 flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-secondary transition-colors hover:bg-fill-tertiary"
|
||||
>
|
||||
<i className="i-mgc-information-cute-re size-3" />
|
||||
</button>
|
||||
</TokenUsagePill>
|
||||
)}
|
||||
<TokenUsagePill metadata={originalMessage.metadata}>
|
||||
<button
|
||||
type="button"
|
||||
className="absolute right-0 flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-secondary transition-colors hover:bg-fill-tertiary"
|
||||
>
|
||||
<i className="i-mgc-information-cute-re size-3" />
|
||||
</button>
|
||||
</TokenUsagePill>
|
||||
</div>
|
||||
)}
|
||||
<div className="h-6" />
|
||||
|
||||
+132
-84
@@ -4,8 +4,11 @@ import {
|
||||
TooltipPortal,
|
||||
TooltipTrigger,
|
||||
} from "@follow/components/ui/tooltip/index.js"
|
||||
import { isFreeRole } from "@follow/constants"
|
||||
import { useUserRole } from "@follow/store/user/hooks"
|
||||
import type { BizUIMetadata } from "@folo-services/ai-tools"
|
||||
import * as React from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { formatTokenCountString } from "~/modules/settings/tabs/ai/usage/utils"
|
||||
|
||||
@@ -20,100 +23,145 @@ const formatDuration = (ms: number): string => {
|
||||
return `${ms}ms`
|
||||
}
|
||||
|
||||
export const TokenUsagePill: React.FC<TokenUsagePillProps> = ({ metadata, children }) => {
|
||||
if (!metadata) return null
|
||||
interface ModelInfoSectionProps {
|
||||
metadata: BizUIMetadata
|
||||
}
|
||||
|
||||
const hasReasoningTokens = metadata.reasoningTokens != null && metadata.reasoningTokens > 0
|
||||
const hasCachedInputTokens = metadata.cachedInputTokens != null && metadata.cachedInputTokens > 0
|
||||
const ModelInfoSection: React.FC<ModelInfoSectionProps> = ({ metadata }) => {
|
||||
const { t } = useTranslation("ai")
|
||||
const hasProviderInfo = metadata.provider != null || metadata.providerType != null
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-2 flex flex-col gap-2">
|
||||
<div className="text-xs text-text">{t("token_usage_pill.model_info")}</div>
|
||||
<div className="font-mono text-xs text-text-secondary">
|
||||
{metadata.modelUsed ?? t("token_usage_pill.unknown")}
|
||||
</div>
|
||||
</div>
|
||||
{hasProviderInfo && (
|
||||
<div className="mb-2 flex flex-col gap-2">
|
||||
<div className="text-xs text-text">{t("token_usage_pill.provider_info")}</div>
|
||||
<div className="font-mono text-xs text-text-secondary">
|
||||
<span>{metadata.provider ?? t("token_usage_pill.unknown")}</span>
|
||||
{metadata.providerType && (
|
||||
<span className="ml-2 text-text-tertiary">
|
||||
<span>(</span>
|
||||
<span>
|
||||
{metadata.providerType === "byok"
|
||||
? t("token_usage_pill.byok")
|
||||
: t("token_usage_pill.system")}
|
||||
</span>
|
||||
<span>)</span>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
interface FreeUserTokenUsageProps {
|
||||
metadata: BizUIMetadata
|
||||
}
|
||||
|
||||
const FreeUserTokenUsage: React.FC<FreeUserTokenUsageProps> = ({ metadata }) => {
|
||||
const { t } = useTranslation("ai")
|
||||
const summarizedTokens =
|
||||
metadata.billedTokens ??
|
||||
metadata.totalTokens ??
|
||||
metadata.outputTokens ??
|
||||
metadata.contextTokens ??
|
||||
null
|
||||
|
||||
return (
|
||||
<>
|
||||
<ModelInfoSection metadata={metadata} />
|
||||
<div className="space-y-2 text-xs">
|
||||
<div className="font-medium text-text">{t("token_usage_pill.credits_usage")}</div>
|
||||
<div className="flex items-center justify-between gap-2 rounded-md border border-border px-3 py-2">
|
||||
<span className="text-text-secondary">{t("token_usage_pill.credits")}:</span>
|
||||
<span className="font-mono text-text">
|
||||
{summarizedTokens != null ? formatTokenCountString(summarizedTokens) : "—"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
interface NormalUserTokenUsageProps {
|
||||
metadata: BizUIMetadata
|
||||
}
|
||||
|
||||
const NormalUserTokenUsage: React.FC<NormalUserTokenUsageProps> = ({ metadata }) => {
|
||||
const { t } = useTranslation("ai")
|
||||
const hasBillingMultiplier =
|
||||
metadata.billingMultiplier != null && metadata.billingMultiplier !== 1
|
||||
const hasDuration = metadata.duration != null
|
||||
|
||||
return (
|
||||
<>
|
||||
<ModelInfoSection metadata={metadata} />
|
||||
<div className="space-y-2 text-xs">
|
||||
<div className="font-medium text-text">{t("token_usage_pill.credits_usage")}</div>
|
||||
<div className="grid grid-cols-2 gap-x-4 gap-y-1">
|
||||
{metadata.totalTokens != null && (
|
||||
<div className="flex justify-between gap-2">
|
||||
<span className="text-text-secondary">{t("token_usage_pill.total")}:</span>
|
||||
<span className="font-mono text-text">
|
||||
{formatTokenCountString(metadata.totalTokens)}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{metadata.billedTokens != null && (
|
||||
<div className="flex justify-between gap-2">
|
||||
<span className="text-text-secondary">{t("token_usage_pill.billed")}:</span>
|
||||
<span className="font-mono">{formatTokenCountString(metadata.billedTokens)}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{(hasDuration || hasBillingMultiplier) && (
|
||||
<>
|
||||
<hr className="border-fill-secondary" />
|
||||
<div className="grid grid-cols-2 gap-x-4 gap-y-1">
|
||||
{hasDuration && (
|
||||
<div className="flex justify-between gap-2">
|
||||
<span className="text-text-secondary">{t("token_usage_pill.duration")}:</span>
|
||||
<span className="font-mono text-text">{formatDuration(metadata.duration!)}</span>
|
||||
</div>
|
||||
)}
|
||||
{hasBillingMultiplier && (
|
||||
<div className="flex justify-between gap-2">
|
||||
<span className="text-text-secondary">{t("token_usage_pill.multiplier")}:</span>
|
||||
<span className="font-mono text-text">{metadata.billingMultiplier!}×</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export const TokenUsagePill: React.FC<TokenUsagePillProps> = ({ metadata, children }) => {
|
||||
const userRole = useUserRole()
|
||||
if (!metadata) return null
|
||||
|
||||
const isFreeUser = userRole ? isFreeRole(userRole) : false
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>{children}</TooltipTrigger>
|
||||
<TooltipPortal>
|
||||
<TooltipContent side="top" className="p-2" align="center" sideOffset={8}>
|
||||
<div className="mb-2 flex flex-col gap-2">
|
||||
<div className="text-xs text-text">Model Info</div>
|
||||
<div className="font-mono text-xs text-text-secondary">
|
||||
{metadata.modelUsed ?? "Unknown"}
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2 text-xs">
|
||||
<div className="font-medium text-text">AI Credits Usage</div>
|
||||
<div className="grid grid-cols-2 gap-x-4 gap-y-1">
|
||||
{metadata.totalTokens != null && (
|
||||
<div className="flex justify-between gap-2">
|
||||
<span className="text-text-secondary">Total:</span>
|
||||
<span className="font-mono text-text">
|
||||
{formatTokenCountString(metadata.totalTokens)}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{metadata.billedTokens != null && (
|
||||
<div className="flex justify-between gap-2">
|
||||
<span className="text-text-secondary">Billed:</span>
|
||||
<span className="font-mono text-accent">
|
||||
{formatTokenCountString(metadata.billedTokens)}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{metadata.contextTokens != null && (
|
||||
<div className="flex justify-between gap-2">
|
||||
<span className="text-text-secondary">Context:</span>
|
||||
<span className="font-mono text-text">
|
||||
{formatTokenCountString(metadata.contextTokens)}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{metadata.outputTokens != null && (
|
||||
<div className="flex justify-between gap-2">
|
||||
<span className="text-text-secondary">Output:</span>
|
||||
<span className="font-mono text-text">
|
||||
{formatTokenCountString(metadata.outputTokens)}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{hasReasoningTokens && (
|
||||
<div className="flex justify-between gap-2">
|
||||
<span className="text-text-secondary">Reasoning:</span>
|
||||
<span className="font-mono text-text">
|
||||
{formatTokenCountString(metadata.reasoningTokens!)}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{hasCachedInputTokens && (
|
||||
<div className="flex justify-between gap-2">
|
||||
<span className="text-text-secondary">Cached:</span>
|
||||
<span className="font-mono text-text">
|
||||
{formatTokenCountString(metadata.cachedInputTokens!)}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{(hasDuration || hasBillingMultiplier) && (
|
||||
<>
|
||||
<hr className="border-fill-secondary" />
|
||||
<div className="grid grid-cols-2 gap-x-4 gap-y-1">
|
||||
{hasDuration && (
|
||||
<div className="flex justify-between gap-2">
|
||||
<span className="text-text-secondary">Duration:</span>
|
||||
<span className="font-mono text-text">
|
||||
{formatDuration(metadata.duration!)}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{hasBillingMultiplier && (
|
||||
<div className="flex justify-between gap-2">
|
||||
<span className="text-text-secondary">Multiplier:</span>
|
||||
<span className="font-mono text-text">{metadata.billingMultiplier!}×</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{isFreeUser ? (
|
||||
<FreeUserTokenUsage metadata={metadata} />
|
||||
) : (
|
||||
<NormalUserTokenUsage metadata={metadata} />
|
||||
)}
|
||||
</TooltipContent>
|
||||
</TooltipPortal>
|
||||
</Tooltip>
|
||||
|
||||
-7
@@ -20,11 +20,6 @@ export const BLOCK_STYLES = {
|
||||
icon: "bg-orange/10 text-orange",
|
||||
label: "text-orange",
|
||||
},
|
||||
selectedText: {
|
||||
container: "from-purple/5 to-purple/10 border-purple/20 hover:border-purple/30",
|
||||
icon: "bg-purple/10 text-purple",
|
||||
label: "text-purple",
|
||||
},
|
||||
fileAttachment: {
|
||||
container: "from-pink/5 to-pink/10 border-pink/20 hover:border-pink/30",
|
||||
icon: "bg-pink/10 text-pink",
|
||||
@@ -52,7 +47,6 @@ export const DEFAULT_BLOCK_STYLES = {
|
||||
export const BLOCK_ICONS = {
|
||||
mainEntry: "i-mgc-star-cute-fi",
|
||||
mainFeed: "i-mgc-rss-cute-fi",
|
||||
selectedText: "i-mgc-quill-pen-cute-re",
|
||||
fileAttachment: "i-mgc-file-upload-cute-re",
|
||||
unreadOnly: "i-mgc-round-cute-fi",
|
||||
} as const
|
||||
@@ -63,7 +57,6 @@ export const BLOCK_ICONS = {
|
||||
export const BLOCK_LABELS = {
|
||||
mainEntry: "Current",
|
||||
mainFeed: "Current",
|
||||
selectedText: "Text",
|
||||
fileAttachment: "File",
|
||||
mainView: "View",
|
||||
unreadOnly: "Filter",
|
||||
|
||||
-5
@@ -140,11 +140,6 @@ export function useContextBlockPresentation(block: AIChatContextBlock): ContextB
|
||||
)
|
||||
break
|
||||
}
|
||||
case "selectedText": {
|
||||
displayContent = `"${block.value}"`
|
||||
title = block.value
|
||||
break
|
||||
}
|
||||
case "unreadOnly": {
|
||||
displayContent = "Unread Only"
|
||||
title = "Unread Only"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LexicalRichEditorNodes } from "@follow/components/ui/lexical-rich-editor/nodes.js"
|
||||
|
||||
import { FileAttachmentNode, MentionNode, ShortcutNode } from "./plugins"
|
||||
import { FileAttachmentNode, MentionNode, SelectedTextNode, ShortcutNode } from "./plugins"
|
||||
|
||||
export * from "./plugins"
|
||||
|
||||
@@ -9,4 +9,5 @@ export const LexicalAIEditorNodes = [
|
||||
MentionNode,
|
||||
ShortcutNode,
|
||||
FileAttachmentNode,
|
||||
SelectedTextNode,
|
||||
]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./file-upload"
|
||||
export * from "./mention"
|
||||
export * from "./selection"
|
||||
export * from "./shortcut"
|
||||
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
import type {
|
||||
DOMConversionMap,
|
||||
DOMExportOutput,
|
||||
LexicalEditor,
|
||||
LexicalNode,
|
||||
NodeKey,
|
||||
SerializedLexicalNode,
|
||||
Spread,
|
||||
} from "lexical"
|
||||
import { DecoratorNode } from "lexical"
|
||||
import * as React from "react"
|
||||
|
||||
import { SelectedTextNodeComponent } from "./SelectedTextNodeComponent"
|
||||
|
||||
export type SelectedTextNodePayload = {
|
||||
text: string
|
||||
sourceEntryId?: string
|
||||
timestamp?: number
|
||||
}
|
||||
|
||||
export type SerializedSelectedTextNode = Spread<SelectedTextNodePayload, SerializedLexicalNode>
|
||||
|
||||
export class SelectedTextNode extends DecoratorNode<React.JSX.Element> {
|
||||
__text: string
|
||||
__sourceEntryId?: string
|
||||
__timestamp?: number
|
||||
|
||||
static override getType(): string {
|
||||
return "selected-text"
|
||||
}
|
||||
|
||||
static override clone(node: SelectedTextNode): SelectedTextNode {
|
||||
return new SelectedTextNode(node.__text, node.__sourceEntryId, node.__timestamp, node.__key)
|
||||
}
|
||||
|
||||
constructor(text: string, sourceEntryId?: string, timestamp?: number, key?: NodeKey) {
|
||||
super(key)
|
||||
this.__text = text
|
||||
this.__sourceEntryId = sourceEntryId
|
||||
this.__timestamp = timestamp
|
||||
}
|
||||
|
||||
getText(): string {
|
||||
return this.__text
|
||||
}
|
||||
|
||||
setText(text: string): void {
|
||||
const writable = this.getWritable()
|
||||
writable.__text = text
|
||||
}
|
||||
|
||||
getSourceEntryId(): string | undefined {
|
||||
return this.__sourceEntryId
|
||||
}
|
||||
|
||||
getTimestamp(): number | undefined {
|
||||
return this.__timestamp
|
||||
}
|
||||
|
||||
override createDOM(): HTMLElement {
|
||||
const div = document.createElement("div")
|
||||
div.dataset.selectedTextNode = "true"
|
||||
return div
|
||||
}
|
||||
|
||||
override updateDOM(): false {
|
||||
return false
|
||||
}
|
||||
|
||||
static override importDOM(): DOMConversionMap | null {
|
||||
return null
|
||||
}
|
||||
|
||||
static override importJSON(serializedNode: SerializedSelectedTextNode): SelectedTextNode {
|
||||
const { text, sourceEntryId, timestamp } = serializedNode
|
||||
return $createSelectedTextNode({ text, sourceEntryId, timestamp })
|
||||
}
|
||||
|
||||
override exportJSON(): SerializedSelectedTextNode {
|
||||
return {
|
||||
text: this.__text,
|
||||
sourceEntryId: this.__sourceEntryId,
|
||||
timestamp: this.__timestamp,
|
||||
type: "selected-text",
|
||||
version: 1,
|
||||
}
|
||||
}
|
||||
|
||||
override exportDOM(): DOMExportOutput {
|
||||
const element = document.createElement("div")
|
||||
element.dataset.selectedTextNode = "true"
|
||||
element.textContent = this.__text
|
||||
return { element }
|
||||
}
|
||||
|
||||
override decorate(_editor: LexicalEditor): React.JSX.Element {
|
||||
return (
|
||||
<SelectedTextNodeComponent
|
||||
text={this.__text}
|
||||
sourceEntryId={this.__sourceEntryId}
|
||||
timestamp={this.__timestamp}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
override isInline(): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override isKeyboardSelectable(): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override getTextContent(): string {
|
||||
return `<user-selection>${escapeXML(this.__text)}</user-selection>`
|
||||
}
|
||||
}
|
||||
|
||||
export function $createSelectedTextNode(payload: SelectedTextNodePayload): SelectedTextNode {
|
||||
return new SelectedTextNode(payload.text, payload.sourceEntryId, payload.timestamp)
|
||||
}
|
||||
|
||||
export function $isSelectedTextNode(
|
||||
node: LexicalNode | null | undefined,
|
||||
): node is SelectedTextNode {
|
||||
return node instanceof SelectedTextNode
|
||||
}
|
||||
function escapeXML(text: string): string {
|
||||
return text
|
||||
.replaceAll("&", "&")
|
||||
.replaceAll("<", "<")
|
||||
.replaceAll(">", ">")
|
||||
.replaceAll('"', """)
|
||||
.replaceAll("'", "'")
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { cn } from "@follow/utils"
|
||||
|
||||
interface SelectedTextNodeComponentProps {
|
||||
text: string
|
||||
sourceEntryId?: string
|
||||
timestamp?: number
|
||||
}
|
||||
|
||||
export function SelectedTextNodeComponent({ text }: SelectedTextNodeComponentProps) {
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
"relative select-none rounded-md border px-2 py-1 text-sm font-medium transition-colors",
|
||||
"border-blue/20 bg-blue/10 text-blue",
|
||||
"hover:border-blue/30 hover:bg-blue/20",
|
||||
"mb-2 flex items-start",
|
||||
)}
|
||||
>
|
||||
<i className="i-mingcute-text-2-line size-4 shrink-0 translate-y-0.5" />
|
||||
<span className="ml-2 line-clamp-3 max-w-full whitespace-pre-wrap" title={text}>
|
||||
"{text}"
|
||||
</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext"
|
||||
import { useEffect } from "react"
|
||||
|
||||
import { insertSelectedTextNode } from "./insertSelectedTextNode"
|
||||
import { subscribeSelectedTextInsertion } from "./selectedTextBridge"
|
||||
import { SelectedTextNode } from "./SelectedTextNode"
|
||||
|
||||
export function SelectedTextPlugin() {
|
||||
const [editor] = useLexicalComposerContext()
|
||||
|
||||
useEffect(() => {
|
||||
return subscribeSelectedTextInsertion((payload) => {
|
||||
editor.focus()
|
||||
insertSelectedTextNode(editor, payload)
|
||||
})
|
||||
}, [editor])
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
SelectedTextPlugin.id = "selected-text"
|
||||
SelectedTextPlugin.nodes = [SelectedTextNode]
|
||||
@@ -0,0 +1,5 @@
|
||||
export * from "./insertSelectedTextNode"
|
||||
export * from "./selectedTextBridge"
|
||||
export * from "./SelectedTextNode"
|
||||
export * from "./SelectedTextNodeComponent"
|
||||
export * from "./SelectedTextPlugin"
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
import type { LexicalEditor } from "lexical"
|
||||
import {
|
||||
$createParagraphNode,
|
||||
$createTextNode,
|
||||
$getRoot,
|
||||
$getSelection,
|
||||
$isRangeSelection,
|
||||
} from "lexical"
|
||||
|
||||
import type { SelectedTextNodePayload } from "./SelectedTextNode"
|
||||
import { $createSelectedTextNode } from "./SelectedTextNode"
|
||||
|
||||
export function insertSelectedTextNode(editor: LexicalEditor, payload: SelectedTextNodePayload) {
|
||||
editor.update(() => {
|
||||
let selection = $getSelection()
|
||||
|
||||
if (!$isRangeSelection(selection)) {
|
||||
const root = $getRoot()
|
||||
const paragraph = $createParagraphNode()
|
||||
root.append(paragraph)
|
||||
paragraph.selectEnd()
|
||||
selection = $getSelection()
|
||||
}
|
||||
|
||||
if (!selection) return
|
||||
const selectedNode = $createSelectedTextNode(payload)
|
||||
selection.insertNodes([selectedNode, $createTextNode(" ")])
|
||||
})
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
import type { SelectedTextNodePayload } from "./SelectedTextNode"
|
||||
|
||||
type Listener = (payload: SelectedTextNodePayload) => void
|
||||
|
||||
const listeners = new Set<Listener>()
|
||||
let pendingPayload: SelectedTextNodePayload | null = null
|
||||
|
||||
export function queueSelectedTextInsertion(payload: SelectedTextNodePayload) {
|
||||
pendingPayload = payload
|
||||
if (listeners.size === 0) return
|
||||
|
||||
for (const listener of listeners) {
|
||||
listener(payload)
|
||||
}
|
||||
pendingPayload = null
|
||||
}
|
||||
|
||||
export function subscribeSelectedTextInsertion(listener: Listener) {
|
||||
listeners.add(listener)
|
||||
|
||||
if (pendingPayload) {
|
||||
listener(pendingPayload)
|
||||
pendingPayload = null
|
||||
}
|
||||
|
||||
return () => {
|
||||
listeners.delete(listener)
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
import { db } from "@follow/database/db"
|
||||
import type { AiChatMessagesModel } from "@follow/database/schemas/index"
|
||||
import { aiChatMessagesTable, aiChatTable } from "@follow/database/schemas/index"
|
||||
import { asc, eq, inArray, sql } from "drizzle-orm"
|
||||
import { and, asc, eq, inArray, isNull, sql } from "drizzle-orm"
|
||||
|
||||
import { getI18n } from "~/i18n"
|
||||
import { followClient } from "~/lib/api-client"
|
||||
|
||||
import { AI_CHAT_SPECIAL_ID_PREFIX } from "../constants"
|
||||
import type { BizUIMessage, BizUIMessagePart } from "../store/types"
|
||||
import type { BizUIMessage, BizUIMessagePart, BizUIMetadata } from "../store/types"
|
||||
import { isDataBlockPart, isFileAttachmentBlock } from "../utils/extractor"
|
||||
|
||||
class AIPersistServiceStatic {
|
||||
@@ -49,6 +49,21 @@ class AIPersistServiceStatic {
|
||||
return Boolean(existingMessage?.id === chatId)
|
||||
}
|
||||
|
||||
async hasAssistantMessagesMissingMetadata(chatId: string): Promise<boolean> {
|
||||
const missingMetadataMessage = await db.query.aiChatMessagesTable.findFirst({
|
||||
where: and(
|
||||
eq(aiChatMessagesTable.chatId, chatId),
|
||||
eq(aiChatMessagesTable.role, "assistant"),
|
||||
isNull(aiChatMessagesTable.metadata),
|
||||
),
|
||||
columns: {
|
||||
id: true,
|
||||
},
|
||||
})
|
||||
|
||||
return Boolean(missingMetadataMessage?.id)
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert enhanced database message to BizUIMessage format for compatibility
|
||||
*/
|
||||
@@ -58,6 +73,7 @@ class AIPersistServiceStatic {
|
||||
role: dbMessage.role,
|
||||
createdAt: dbMessage.createdAt,
|
||||
parts: [],
|
||||
metadata: (dbMessage.metadata ?? undefined) as BizUIMetadata | undefined,
|
||||
}
|
||||
|
||||
if (dbMessage.messageParts && dbMessage.messageParts.length > 0) {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { autoBindThis } from "@follow/utils/bind-this"
|
||||
import { createDesktopAPIHeaders } from "@follow/utils/headers"
|
||||
import PKG from "@pkg"
|
||||
import type { ChatRequestOptions, ChatStatus } from "ai"
|
||||
import { merge } from "es-toolkit/compat"
|
||||
import { nanoid } from "nanoid"
|
||||
@@ -217,6 +219,7 @@ export class ChatSliceActions {
|
||||
const finalOptions = merge(
|
||||
{
|
||||
body: { scene: this.get().scene },
|
||||
headers: createDesktopAPIHeaders({ version: PKG.version }),
|
||||
},
|
||||
options,
|
||||
)
|
||||
|
||||
@@ -33,7 +33,6 @@ export class BlockSliceAction {
|
||||
mainView: "mainView",
|
||||
mainEntry: "mainEntry",
|
||||
mainFeed: "mainFeed",
|
||||
selectedText: "selectedText",
|
||||
unreadOnly: "unreadOnly",
|
||||
}
|
||||
get set() {
|
||||
|
||||
@@ -20,12 +20,7 @@ interface BaseContextBlock {
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
export type ValueContextBlockType =
|
||||
| "mainView"
|
||||
| "mainEntry"
|
||||
| "mainFeed"
|
||||
| "selectedText"
|
||||
| "unreadOnly"
|
||||
export type ValueContextBlockType = "mainView" | "mainEntry" | "mainFeed" | "unreadOnly"
|
||||
export interface AbstractValueContextBlock<T extends string> extends BaseContextBlock {
|
||||
type: T
|
||||
value: string
|
||||
|
||||
@@ -9,6 +9,10 @@ export interface AIConfigLike {
|
||||
freeQuota?: FreeQuota
|
||||
}
|
||||
|
||||
export interface RateLimitMessageOptions {
|
||||
hideResetDetails?: boolean
|
||||
}
|
||||
|
||||
const formatResetTime = (windowResetTime: Date) => {
|
||||
const i18n = getI18n()
|
||||
const { t } = i18n
|
||||
@@ -56,9 +60,11 @@ export function computeIsRateLimited(
|
||||
export function computeRateLimitMessage(
|
||||
error: Error | string | undefined,
|
||||
configuration?: AIConfigLike | null,
|
||||
options?: RateLimitMessageOptions,
|
||||
): string | null {
|
||||
const i18n = getI18n()
|
||||
const { t } = i18n
|
||||
const hideResetDetails = options?.hideResetDetails ?? false
|
||||
|
||||
const aiNs = { ns: "ai" } as const
|
||||
if (error) {
|
||||
@@ -84,7 +90,7 @@ export function computeRateLimitMessage(
|
||||
parts.push(t("rate_limit.upgrade_to_get_more", aiNs))
|
||||
}
|
||||
|
||||
if (resetText) {
|
||||
if (resetText && !hideResetDetails) {
|
||||
parts.push(resetText)
|
||||
}
|
||||
|
||||
@@ -101,11 +107,12 @@ export function computeRateLimitMessage(
|
||||
const monthly = configuration.freeQuota.remainingMonthlyRequests
|
||||
if (!daily || !monthly) {
|
||||
const parts: string[] = []
|
||||
parts.push(t("rate_limit.depleted", aiNs))
|
||||
if (!daily && monthly) {
|
||||
parts.push(t("rate_limit.resets_tomorrow", aiNs))
|
||||
} else {
|
||||
parts.push(t("rate_limit.resets_next_month", aiNs))
|
||||
if (!hideResetDetails) {
|
||||
if (!daily && monthly) {
|
||||
parts.push(t("rate_limit.resets_tomorrow", aiNs))
|
||||
} else {
|
||||
parts.push(t("rate_limit.resets_next_month", aiNs))
|
||||
}
|
||||
}
|
||||
parts.push(t("rate_limit.upgrade_to_get_more", aiNs))
|
||||
return parts.join(" · ")
|
||||
@@ -124,7 +131,7 @@ export function computeRateLimitMessage(
|
||||
} else {
|
||||
parts.push(t("rate_limit.credits_left", { ns: "ai", count: remaining }))
|
||||
}
|
||||
if (formattedResetText) {
|
||||
if (formattedResetText && !hideResetDetails) {
|
||||
parts.push(formattedResetText)
|
||||
}
|
||||
if (parts.length < 2) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Folo } from "@follow/components/icons/folo.js"
|
||||
import { Logo } from "@follow/components/icons/logo.js"
|
||||
import { MotionButtonBase } from "@follow/components/ui/button/index.js"
|
||||
import { useIsDark } from "@follow/hooks"
|
||||
import { IN_ELECTRON } from "@follow/shared"
|
||||
import type { LoginRuntime } from "@follow/shared/auth"
|
||||
import { stopPropagation } from "@follow/utils/dom"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
@@ -12,7 +13,6 @@ import { useEffect, useState } from "react"
|
||||
import { Trans, useTranslation } from "react-i18next"
|
||||
|
||||
import { useServerConfigs } from "~/atoms/server-configs"
|
||||
import { GlassButton } from "~/components/ui/button/GlassButton"
|
||||
import { useCurrentModal, useModalStack } from "~/components/ui/modal/stacked/hooks"
|
||||
import { authClient, loginHandler } from "~/lib/auth"
|
||||
import { useAuthProviders } from "~/queries/users"
|
||||
@@ -119,15 +119,15 @@ export const LoginModalContent = (props: LoginModalContentProps) => {
|
||||
<Folo className="size-12" />
|
||||
</m.div>
|
||||
</div>
|
||||
|
||||
<GlassButton
|
||||
variant="flat"
|
||||
className="absolute -right-2 -top-2 bg-material-medium"
|
||||
onClick={modal.dismiss}
|
||||
>
|
||||
<i className="i-mgc-close-cute-re size-4" />
|
||||
</GlassButton>
|
||||
|
||||
{!IN_ELECTRON && (
|
||||
<button
|
||||
type="button"
|
||||
className="absolute -right-2 -top-2 flex size-8 items-center justify-center rounded-lg border-0 bg-transparent hover:bg-fill/20"
|
||||
onClick={modal.dismiss}
|
||||
>
|
||||
<i className="i-mgc-close-cute-re size-4" />
|
||||
</button>
|
||||
)}
|
||||
{isEmail ? (
|
||||
<m.div
|
||||
initial={{ opacity: 0, y: 10 }}
|
||||
|
||||
@@ -66,4 +66,4 @@ export type UnknownCommand = Command<{
|
||||
}>
|
||||
|
||||
export type FollowCommandId = FollowCommand["id"]
|
||||
export type FollowCommand = BasicCommand // | UnknownCommand
|
||||
export type FollowCommand = BasicCommand | UnknownCommand
|
||||
|
||||
@@ -38,7 +38,8 @@ const ViewTag = IN_ELECTRON ? "webview" : "iframe"
|
||||
|
||||
const entrySelector = (state: EntryModel) => {
|
||||
/// keep-sorted
|
||||
const { authorAvatar, authorUrl, description, feedId, inboxHandle, publishedAt, title } = state
|
||||
const { authorAvatar, authorUrl, description, feedId, inboxHandle, publishedAt, tags, title } =
|
||||
state
|
||||
|
||||
const audios = state.attachments?.filter((a) => a.mime_type?.startsWith("audio") && a.url)
|
||||
const video = transformVideoUrl({
|
||||
@@ -62,6 +63,7 @@ const entrySelector = (state: EntryModel) => {
|
||||
firstPhotoUrl,
|
||||
inboxId: inboxHandle,
|
||||
publishedAt,
|
||||
tags: tags ?? null,
|
||||
title,
|
||||
video,
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { useEntry } from "@follow/store/entry/hooks"
|
||||
import { getImageProxyUrl } from "@follow/utils/img-proxy"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useMemo } from "react"
|
||||
|
||||
import { usePreviewMedia } from "~/components/ui/media/hooks"
|
||||
import { Media } from "~/components/ui/media/Media"
|
||||
import { useGetImageProxyUrl } from "~/lib/img-proxy"
|
||||
import { jotaiStore } from "~/lib/jotai"
|
||||
|
||||
import { socialMediaContentWidthAtom } from "../atoms/social-media-content-width"
|
||||
@@ -16,6 +16,7 @@ export const MediaGallery = ({
|
||||
entryId: string
|
||||
containerWidth?: number
|
||||
}) => {
|
||||
const getImageProxyUrl = useGetImageProxyUrl()
|
||||
const entry = useEntry(entryId, (state) => ({ media: state.media }))
|
||||
const media = useMemo(() => entry?.media || [], [entry?.media])
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import { atom } from "jotai"
|
||||
|
||||
export const aiTimelineEnabledAtom = atom(false)
|
||||
+212
@@ -0,0 +1,212 @@
|
||||
.ai-timeline-loading {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
overflow: hidden;
|
||||
border-radius: inherit;
|
||||
}
|
||||
|
||||
.ai-timeline-loading__backdrop {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
rgba(255, 255, 255, 0.02),
|
||||
rgba(255, 92, 0, 0.08),
|
||||
rgba(0, 0, 0, 0.1)
|
||||
);
|
||||
opacity: 0.75;
|
||||
animation: aiTimelineGlassPulse 2.6s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.ai-timeline-loading__glow {
|
||||
position: absolute;
|
||||
inset: 10% 8% 16% 8%;
|
||||
border-radius: 48px;
|
||||
background: radial-gradient(
|
||||
circle at 70% 25%,
|
||||
rgba(255, 92, 0, 0.35),
|
||||
rgba(255, 140, 0, 0.15),
|
||||
transparent 65%
|
||||
);
|
||||
filter: blur(42px);
|
||||
opacity: 0.8;
|
||||
animation: aiTimelineGlow 3.4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.ai-timeline-loading__beam {
|
||||
position: absolute;
|
||||
top: -5%;
|
||||
bottom: -5%;
|
||||
width: 32%;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(
|
||||
120deg,
|
||||
rgba(255, 255, 255, 0.2),
|
||||
rgba(255, 92, 0, 0.15),
|
||||
rgba(255, 92, 0, 0)
|
||||
);
|
||||
filter: blur(18px);
|
||||
opacity: 0;
|
||||
animation: aiTimelineBeam 2.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
|
||||
}
|
||||
|
||||
.ai-timeline-loading__beam--left {
|
||||
left: -15%;
|
||||
animation-delay: 0s;
|
||||
}
|
||||
|
||||
.ai-timeline-loading__beam--right {
|
||||
right: -15%;
|
||||
animation-delay: -1.2s;
|
||||
}
|
||||
|
||||
.ai-timeline-loading__sparkles {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
filter: blur(0.5px);
|
||||
}
|
||||
|
||||
.ai-timeline-loading__sparkles span {
|
||||
position: absolute;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.45);
|
||||
box-shadow:
|
||||
0 0 18px rgba(255, 92, 0, 0.4),
|
||||
0 0 8px rgba(255, 255, 255, 0.3);
|
||||
opacity: 0;
|
||||
animation: aiTimelineSparkle 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.ai-timeline-loading__sparkles span:nth-child(1) {
|
||||
top: 25%;
|
||||
left: 32%;
|
||||
animation-delay: 0s;
|
||||
}
|
||||
|
||||
.ai-timeline-loading__sparkles span:nth-child(2) {
|
||||
top: 55%;
|
||||
left: 62%;
|
||||
animation-delay: -0.9s;
|
||||
}
|
||||
|
||||
.ai-timeline-loading__sparkles span:nth-child(3) {
|
||||
top: 38%;
|
||||
left: 78%;
|
||||
animation-delay: -1.8s;
|
||||
}
|
||||
|
||||
.ai-timeline-loading__badge {
|
||||
position: absolute;
|
||||
right: 1.25rem;
|
||||
bottom: 1.5rem;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(
|
||||
120deg,
|
||||
rgba(16, 16, 16, 0.65),
|
||||
rgba(32, 24, 20, 0.65),
|
||||
rgba(255, 92, 0, 0.25)
|
||||
);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
box-shadow:
|
||||
0 15px 40px rgba(0, 0, 0, 0.35),
|
||||
inset 0 1px 1px rgba(255, 255, 255, 0.15);
|
||||
backdrop-filter: blur(12px) saturate(140%);
|
||||
-webkit-backdrop-filter: blur(12px) saturate(140%);
|
||||
animation: aiTimelineBadgePulse 2.2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.ai-timeline-loading__badge::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: inherit;
|
||||
background: linear-gradient(
|
||||
120deg,
|
||||
rgba(255, 255, 255, 0.05),
|
||||
rgba(255, 92, 0, 0.35),
|
||||
rgba(255, 255, 255, 0.05)
|
||||
);
|
||||
opacity: 0.35;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.ai-timeline-loading__badge span {
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
text-shadow: 0 1px 8px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
@keyframes aiTimelineGlassPulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 0.65;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.85;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes aiTimelineGlow {
|
||||
0%,
|
||||
100% {
|
||||
transform: scale(0.95);
|
||||
opacity: 0.6;
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.05);
|
||||
opacity: 0.85;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes aiTimelineBeam {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateX(-35%) scaleX(0.8);
|
||||
}
|
||||
40% {
|
||||
opacity: 0.4;
|
||||
}
|
||||
70% {
|
||||
opacity: 0.65;
|
||||
transform: translateX(20%) scaleX(1.05);
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
transform: translateX(30%) scaleX(1.2);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes aiTimelineSparkle {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 0;
|
||||
transform: scale(0.4) translate3d(0, 0, 0);
|
||||
}
|
||||
35% {
|
||||
opacity: 0.85;
|
||||
transform: scale(1) translate3d(4px, -6px, 0);
|
||||
}
|
||||
65% {
|
||||
opacity: 0.35;
|
||||
transform: scale(0.6) translate3d(-4px, 6px, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes aiTimelineBadgePulse {
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
box-shadow:
|
||||
0 15px 40px rgba(0, 0, 0, 0.35),
|
||||
inset 0 1px 1px rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-3px);
|
||||
box-shadow:
|
||||
0 20px 45px rgba(0, 0, 0, 0.4),
|
||||
inset 0 1px 1px rgba(255, 255, 255, 0.25);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import "./AITimelineLoadingOverlay.css"
|
||||
|
||||
import { Spring } from "@follow/components/constants/spring.js"
|
||||
import { AnimatePresence, m } from "motion/react"
|
||||
import type { FC } from "react"
|
||||
|
||||
type Props = {
|
||||
visible: boolean
|
||||
label: string
|
||||
}
|
||||
|
||||
export const AITimelineLoadingOverlay: FC<Props> = ({ visible, label }) => (
|
||||
<AnimatePresence>
|
||||
{visible ? (
|
||||
<m.div
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
transition={Spring.presets.smooth}
|
||||
className="ai-timeline-loading"
|
||||
>
|
||||
<div className="ai-timeline-loading__backdrop" />
|
||||
<div className="ai-timeline-loading__glow" />
|
||||
<div className="ai-timeline-loading__beam ai-timeline-loading__beam--left" />
|
||||
<div className="ai-timeline-loading__beam ai-timeline-loading__beam--right" />
|
||||
<div className="ai-timeline-loading__sparkles">
|
||||
<span />
|
||||
<span />
|
||||
<span />
|
||||
</div>
|
||||
|
||||
<div className="ai-timeline-loading__badge flex items-center gap-2 px-4 py-1.5 text-xs font-semibold text-text">
|
||||
<span className="inline-flex size-2 rounded-full bg-orange-400 shadow-[0_0_12px_rgba(251,146,60,0.7)]" />
|
||||
<span className="i-mgc-robot-2-cute-re text-base text-orange-400 dark:text-orange-300" />
|
||||
<span>{label}</span>
|
||||
</div>
|
||||
</m.div>
|
||||
) : null}
|
||||
</AnimatePresence>
|
||||
)
|
||||
@@ -18,14 +18,17 @@ import { nextFrame } from "@follow/utils"
|
||||
import { isBizId } from "@follow/utils/utils"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { debounce } from "es-toolkit/compat"
|
||||
import { useAtomValue } from "jotai"
|
||||
import { useCallback, useEffect, useMemo, useState } from "react"
|
||||
|
||||
import { useGeneralSettingKey } from "~/atoms/settings/general"
|
||||
import { ROUTE_FEED_PENDING } from "~/constants/app"
|
||||
import { useFeature } from "~/hooks/biz/useFeature"
|
||||
import { useRouteParams } from "~/hooks/biz/useRouteParams"
|
||||
import { useAuthQuery } from "~/hooks/common"
|
||||
import { entries } from "~/queries/entries"
|
||||
|
||||
import { aiTimelineEnabledAtom } from "../atoms/ai-timeline"
|
||||
import { useIsPreviewFeed } from "./useIsPreviewFeed"
|
||||
|
||||
const useRemoteEntries = (): UseEntriesReturn => {
|
||||
@@ -36,6 +39,8 @@ const useRemoteEntries = (): UseEntriesReturn => {
|
||||
const hidePrivateSubscriptionsInTimeline = useGeneralSettingKey(
|
||||
"hidePrivateSubscriptionsInTimeline",
|
||||
)
|
||||
const aiTimelineEnabled = useAtomValue(aiTimelineEnabledAtom)
|
||||
const aiEnabled = useFeature("ai")
|
||||
|
||||
const folderIds = useFolderFeedsByFeedId({
|
||||
feedId,
|
||||
@@ -53,6 +58,7 @@ const useRemoteEntries = (): UseEntriesReturn => {
|
||||
hidePrivateSubscriptionsInTimeline: true,
|
||||
}),
|
||||
...(view === FeedViewType.All && { limit: 40 }),
|
||||
...(aiTimelineEnabled && aiEnabled && { aiSort: true }),
|
||||
}
|
||||
|
||||
if (feedId && listId && isBizId(feedId)) {
|
||||
@@ -69,6 +75,8 @@ const useRemoteEntries = (): UseEntriesReturn => {
|
||||
isPreview,
|
||||
view,
|
||||
hidePrivateSubscriptionsInTimeline,
|
||||
aiTimelineEnabled,
|
||||
aiEnabled,
|
||||
])
|
||||
const query = useEntriesQuery(entriesOptions)
|
||||
|
||||
|
||||
@@ -7,8 +7,9 @@ import { unreadSyncService } from "@follow/store/unread/store"
|
||||
import { useIsLoggedIn } from "@follow/store/user/hooks"
|
||||
import { isBizId } from "@follow/utils/utils"
|
||||
import type { Range, Virtualizer } from "@tanstack/react-virtual"
|
||||
import { atom } from "jotai"
|
||||
import { atom, useAtomValue } from "jotai"
|
||||
import { memo, useCallback, useEffect, useMemo, useRef } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { useGeneralSettingKey } from "~/atoms/settings/general"
|
||||
import { Focusable } from "~/components/common/Focusable"
|
||||
@@ -19,6 +20,8 @@ import { useRouteParams, useRouteParamsSelector } from "~/hooks/biz/useRoutePara
|
||||
import { useFeedQuery } from "~/queries/feed"
|
||||
import { useFeedHeaderTitle } from "~/store/feed/hooks"
|
||||
|
||||
import { aiTimelineEnabledAtom } from "./atoms/ai-timeline"
|
||||
import { AITimelineLoadingOverlay } from "./components/ai-timeline-loading/AITimelineLoadingOverlay"
|
||||
import { EntryColumnWrapper } from "./components/entry-column-wrapper/EntryColumnWrapper"
|
||||
import { FooterMarkItem } from "./components/FooterMarkItem"
|
||||
import { useEntriesActions, useEntriesState } from "./context/EntriesContext"
|
||||
@@ -34,6 +37,7 @@ import { EntryRootStateContext } from "./store/EntryColumnContext"
|
||||
|
||||
function EntryColumnContent() {
|
||||
const listRef = useRef<Virtualizer<HTMLElement, Element>>(undefined)
|
||||
const { t } = useTranslation()
|
||||
const state = useEntriesState()
|
||||
|
||||
const actions = useEntriesActions()
|
||||
@@ -111,6 +115,8 @@ function EntryColumnContent() {
|
||||
|
||||
const rangeQueueRef = useRef<Range[]>([])
|
||||
const isRefreshing = state.isFetching && !state.isFetchingNextPage
|
||||
const aiTimelineEnabled = useAtomValue(aiTimelineEnabledAtom)
|
||||
const showAiTimelineLoading = aiTimelineEnabled && state.isLoading && !state.isFetchingNextPage
|
||||
const renderAsRead = useGeneralSettingKey("renderMarkUnread")
|
||||
const handleRangeChange = useCallback(
|
||||
(e: Range) => {
|
||||
@@ -192,6 +198,11 @@ function EntryColumnContent() {
|
||||
/>
|
||||
)}
|
||||
</EntryColumnWrapper>
|
||||
|
||||
<AITimelineLoadingOverlay
|
||||
visible={showAiTimelineLoading}
|
||||
label={t("entry_list_header.ai_timeline_loading")}
|
||||
/>
|
||||
</Focusable>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ export const EntryItemWrapper: FC<
|
||||
> = ({ entryId, view, children, itemClassName, style, isFirstItem }) => {
|
||||
const entry = useEntry(entryId, (state) => {
|
||||
const { feedId, inboxHandle } = state
|
||||
|
||||
const { id, url } = state
|
||||
return { feedId, id, inboxId: inboxHandle, url }
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ import { useFeedById } from "@follow/store/feed/hooks"
|
||||
import { useIsLoggedIn, useWhoami } from "@follow/store/user/hooks"
|
||||
import { stopPropagation } from "@follow/utils/dom"
|
||||
import { clsx, cn, isBizId } from "@follow/utils/utils"
|
||||
import { useAtomValue } from "jotai"
|
||||
import { useAtom, useAtomValue } from "jotai"
|
||||
import type { FC } from "react"
|
||||
import { useCallback } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
@@ -33,6 +33,7 @@ import { FeedIcon } from "~/modules/feed/feed-icon"
|
||||
import { useRefreshFeedMutation } from "~/queries/feed"
|
||||
import { useFeedHeaderIcon, useFeedHeaderTitle } from "~/store/feed/hooks"
|
||||
|
||||
import { aiTimelineEnabledAtom } from "../atoms/ai-timeline"
|
||||
import { MarkAllReadButton } from "../components/mark-all-button"
|
||||
import { useIsPreviewFeed } from "../hooks/useIsPreviewFeed"
|
||||
import { useEntryRootState } from "../store/EntryColumnContext"
|
||||
@@ -48,6 +49,7 @@ export const EntryListHeader: FC<{
|
||||
const { t } = useTranslation()
|
||||
|
||||
const unreadOnly = useGeneralSettingKey("unreadOnly")
|
||||
const [aiTimelineEnabled, setAiTimelineEnabled] = useAtom(aiTimelineEnabledAtom)
|
||||
const aiEnabled = useFeature("ai")
|
||||
|
||||
const { feedId, entryId, view, isCollection } = routerParams
|
||||
@@ -102,6 +104,37 @@ export const EntryListHeader: FC<{
|
||||
}, [sendAIShortcut])
|
||||
const showEntryHeader = isWideMode && !!entryId && entryId !== ROUTE_ENTRY_PENDING
|
||||
const showTimelineSummaryButton = isWideMode && aiEnabled
|
||||
const showAiTimelineToggle = aiEnabled
|
||||
|
||||
const handleAiTimelineButtonClick = useCallback(() => {
|
||||
setAiTimelineEnabled((prev) => !prev)
|
||||
}, [setAiTimelineEnabled])
|
||||
|
||||
const renderAiTimelineButton = () => {
|
||||
if (!showAiTimelineToggle) return null
|
||||
return (
|
||||
<ActionButton
|
||||
tooltip={t("entry_list_header.ai_timeline")}
|
||||
active={aiTimelineEnabled}
|
||||
onClick={handleAiTimelineButtonClick}
|
||||
>
|
||||
{aiTimelineEnabled ? (
|
||||
<i className="i-mgc-refresh-4-ai-cute-re text-purple-600 dark:text-purple-400" />
|
||||
) : (
|
||||
<i className="i-mgc-refresh-4-ai-cute-re text-purple-600 dark:text-purple-400" />
|
||||
)}
|
||||
</ActionButton>
|
||||
)
|
||||
}
|
||||
|
||||
const renderTimelineSummaryButton = () => {
|
||||
if (!showTimelineSummaryButton) return null
|
||||
return (
|
||||
<ActionButton tooltip={t("entry_list_header.timeline_summary")} onClick={summarizeTimeline}>
|
||||
<i className="i-mgc-paint-brush-ai-cute-re text-purple-600 dark:text-purple-400" />
|
||||
</ActionButton>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -129,20 +162,21 @@ export const EntryListHeader: FC<{
|
||||
)}
|
||||
onClick={stopPropagation}
|
||||
>
|
||||
{isWideMode && (showEntryHeader || showTimelineSummaryButton) && (
|
||||
<>
|
||||
{showEntryHeader && <EntryHeader entryId={entryId} />}
|
||||
{showTimelineSummaryButton && (
|
||||
<ActionButton
|
||||
tooltip={t("entry_list_header.timeline_summary")}
|
||||
onClick={summarizeTimeline}
|
||||
>
|
||||
<i className="i-mgc-paint-brush-ai-cute-re text-purple-600 dark:text-purple-400" />
|
||||
</ActionButton>
|
||||
)}
|
||||
<DividerVertical className="mx-2 w-px" />
|
||||
</>
|
||||
)}
|
||||
{isWideMode &&
|
||||
(showEntryHeader || showTimelineSummaryButton || showAiTimelineToggle) && (
|
||||
<>
|
||||
{showEntryHeader && <EntryHeader entryId={entryId} />}
|
||||
{(showAiTimelineToggle || showTimelineSummaryButton) && (
|
||||
<div className="flex items-center gap-2">
|
||||
{aiTimelineEnabled && renderAiTimelineButton()}
|
||||
{renderTimelineSummaryButton()}
|
||||
</div>
|
||||
)}
|
||||
<DividerVertical className="mx-2 w-px" />
|
||||
</>
|
||||
)}
|
||||
|
||||
{!isWideMode && aiTimelineEnabled && renderAiTimelineButton()}
|
||||
|
||||
<AppendTaildingDivider>
|
||||
{view === FeedViewType.Pictures && <SwitchToMasonryButton />}
|
||||
|
||||
+7
-3
@@ -17,6 +17,7 @@ import { Media } from "~/components/ui/media/Media"
|
||||
import { FEED_COLLECTION_LIST } from "~/constants"
|
||||
import { useEntryIsRead } from "~/hooks/biz/useAsRead"
|
||||
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
|
||||
import { EntryTags } from "~/modules/entry/EntryTags"
|
||||
import { EntryTranslation } from "~/modules/entry-column/translation"
|
||||
import type { FeedIconEntry } from "~/modules/feed/feed-icon"
|
||||
import { FeedIcon } from "~/modules/feed/feed-icon"
|
||||
@@ -28,7 +29,8 @@ import type { UniversalItemProps } from "../types"
|
||||
|
||||
const entrySelector = (state: EntryModel) => {
|
||||
/// keep-sorted
|
||||
const { authorAvatar, authorUrl, description, feedId, inboxHandle, publishedAt, title } = state
|
||||
const { authorAvatar, authorUrl, description, feedId, inboxHandle, publishedAt, tags, title } =
|
||||
state
|
||||
|
||||
const audios = state.attachments?.filter((a) => a.mime_type?.startsWith("audio") && a.url)
|
||||
const firstAudio = audios?.[0]
|
||||
@@ -48,6 +50,7 @@ const entrySelector = (state: EntryModel) => {
|
||||
firstPhotoUrl,
|
||||
inboxId: inboxHandle,
|
||||
publishedAt,
|
||||
tags: tags ?? null,
|
||||
title,
|
||||
}
|
||||
}
|
||||
@@ -183,7 +186,7 @@ export function ListItem({
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"flex gap-1 text-[10px] font-bold",
|
||||
"flex min-w-0 items-center gap-1 text-[10px] font-bold",
|
||||
"text-text-secondary",
|
||||
isInCollection && "text-text-secondary",
|
||||
isRead && dimRead && "text-text-tertiary",
|
||||
@@ -196,7 +199,7 @@ export function ListItem({
|
||||
className="space-x-0.5"
|
||||
/>
|
||||
</EllipsisHorizontalTextWithTooltip>
|
||||
<span>·</span>
|
||||
<span className="shrink-0">·</span>
|
||||
<span className="shrink-0">{!!displayTime && <RelativeTime date={displayTime} />}</span>
|
||||
</div>
|
||||
<div
|
||||
@@ -238,6 +241,7 @@ export function ListItem({
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<EntryTags tags={entry.tags} feedId={entry.feedId} size="sm" className="mt-1" />
|
||||
</div>
|
||||
|
||||
{hasAudio && entry.firstAudio && (
|
||||
|
||||
@@ -95,7 +95,6 @@ const EntryContentImpl: Component<EntryContentProps> = ({
|
||||
})
|
||||
return () => {
|
||||
removeBlock(BlockSliceAction.SPECIAL_TYPES.mainEntry)
|
||||
removeBlock(BlockSliceAction.SPECIAL_TYPES.selectedText)
|
||||
}
|
||||
}, [addOrUpdateBlock, entryId, removeBlock])
|
||||
const animationController = useAnimationControls()
|
||||
|
||||
@@ -179,39 +179,13 @@ export const CommandDropdownMenuItem = ({
|
||||
asSubTrigger = false,
|
||||
disabled = false,
|
||||
}: {
|
||||
commandId: FollowCommandId | string
|
||||
commandId: FollowCommandId
|
||||
onClick: () => void
|
||||
active?: boolean
|
||||
asSubTrigger?: boolean
|
||||
disabled?: boolean
|
||||
}) => {
|
||||
const command = useCommand(commandId as any)
|
||||
|
||||
// For custom integration items
|
||||
if (typeof commandId === "string" && commandId.startsWith("integration:custom:")) {
|
||||
const content = (
|
||||
<>
|
||||
<i className="i-mgc-webhook-cute-re mr-2" />
|
||||
Custom Integration
|
||||
</>
|
||||
)
|
||||
|
||||
if (asSubTrigger) {
|
||||
return content
|
||||
}
|
||||
|
||||
return (
|
||||
<DropdownMenuItem
|
||||
key={commandId}
|
||||
className="pl-3"
|
||||
onSelect={disabled ? undefined : onClick}
|
||||
active={active}
|
||||
disabled={disabled}
|
||||
>
|
||||
{content}
|
||||
</DropdownMenuItem>
|
||||
)
|
||||
}
|
||||
const command = useCommand(commandId)
|
||||
|
||||
if (!command) return null
|
||||
|
||||
|
||||
+7
-4
@@ -4,14 +4,16 @@ import {
|
||||
DEFAULT_SUMMARIZE_TIMELINE_SHORTCUT_ID,
|
||||
} from "@follow/shared/settings/defaults"
|
||||
import { stopPropagation } from "@follow/utils/dom"
|
||||
import { useSetAtom } from "jotai"
|
||||
import { useCallback } from "react"
|
||||
import { toast } from "sonner"
|
||||
|
||||
import { useSendAIShortcut } from "~/modules/ai-chat/hooks/useSendAIShortcut"
|
||||
import { aiTimelineEnabledAtom } from "~/modules/entry-column/atoms/ai-timeline"
|
||||
import { useSettingModal } from "~/modules/settings/modal/use-setting-modal-hack"
|
||||
|
||||
export const EntryPlaceholderLogo = () => {
|
||||
const { sendAIShortcut } = useSendAIShortcut()
|
||||
const setAiTimelineEnabled = useSetAtom(aiTimelineEnabledAtom)
|
||||
const settingModalPresent = useSettingModal()
|
||||
const handleSummarizeTimeline = useCallback(() => {
|
||||
void sendAIShortcut({
|
||||
@@ -25,6 +27,9 @@ export const EntryPlaceholderLogo = () => {
|
||||
ensureNewChat: true,
|
||||
})
|
||||
}, [sendAIShortcut])
|
||||
const handleToggleAiTimeline = useCallback(() => {
|
||||
setAiTimelineEnabled((prev) => !prev)
|
||||
}, [setAiTimelineEnabled])
|
||||
|
||||
const buttons = [
|
||||
{
|
||||
@@ -39,9 +44,7 @@ export const EntryPlaceholderLogo = () => {
|
||||
},
|
||||
{
|
||||
label: "Sort the timeline by importance",
|
||||
onClick: () => {
|
||||
toast.success("Coming soon!")
|
||||
},
|
||||
onClick: handleToggleAiTimeline,
|
||||
icon: <i className="i-mgc-refresh-4-ai-cute-re text-base" />,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ import type { FeedIconEntry } from "~/modules/feed/feed-icon"
|
||||
import { FeedIcon } from "~/modules/feed/feed-icon"
|
||||
import { getPreferredTitle } from "~/store/feed/hooks"
|
||||
|
||||
import { EntryTags } from "../../entry/EntryTags"
|
||||
import { EntryTranslation } from "../../entry-column/translation"
|
||||
import { EntryReadHistory } from "./entry-read-history"
|
||||
|
||||
@@ -37,7 +38,8 @@ export const EntryTitle = ({
|
||||
entryId,
|
||||
useShallow((state) => {
|
||||
/// keep-sorted
|
||||
const { author, authorAvatar, authorUrl, feedId, inboxHandle, publishedAt, title } = state
|
||||
const { author, authorAvatar, authorUrl, feedId, inboxHandle, publishedAt, tags, title } =
|
||||
state
|
||||
|
||||
const attachments = state.attachments || []
|
||||
const { duration_in_seconds } =
|
||||
@@ -59,6 +61,7 @@ export const EntryTitle = ({
|
||||
firstPhotoUrl,
|
||||
inboxId: inboxHandle,
|
||||
publishedAt,
|
||||
tags: tags ?? null,
|
||||
title,
|
||||
}
|
||||
}),
|
||||
@@ -183,6 +186,7 @@ export const EntryTitle = ({
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<EntryTags tags={entry.tags} feedId={entry.feedId} className="mt-1" />
|
||||
{/* Recent Readers */}
|
||||
{!noRecentReader && !hideRecentReader && <EntryReadHistory entryId={entryId} />}
|
||||
</div>
|
||||
|
||||
+41
-16
@@ -8,7 +8,12 @@ import { cn } from "@follow/utils"
|
||||
import { ErrorBoundary } from "@sentry/react"
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
||||
|
||||
import { AIChatPanelStyle, useAIChatPanelStyle, useAIPanelVisibility } from "~/atoms/settings/ai"
|
||||
import {
|
||||
AIChatPanelStyle,
|
||||
setAIPanelVisibility,
|
||||
useAIChatPanelStyle,
|
||||
useAIPanelVisibility,
|
||||
} from "~/atoms/settings/ai"
|
||||
import { useUISettingKey } from "~/atoms/settings/ui"
|
||||
import { ShadowDOM } from "~/components/common/ShadowDOM"
|
||||
import type { TocRef } from "~/components/ui/markdown/components/Toc"
|
||||
@@ -16,8 +21,7 @@ import { useInPeekModal } from "~/components/ui/modal/inspire/InPeekModal"
|
||||
import { readableContentMaxWidthClassName } from "~/constants/ui"
|
||||
import { useRenderStyle } from "~/hooks/biz/useRenderStyle"
|
||||
import type { TextSelectionEvent } from "~/lib/simple-text-selection"
|
||||
import { useBlockActions } from "~/modules/ai-chat/store/hooks"
|
||||
import { BlockSliceAction } from "~/modules/ai-chat/store/slices/block.slice"
|
||||
import { queueSelectedTextInsertion } from "~/modules/ai-chat/editor/plugins/selection/selectedTextBridge"
|
||||
import { EntryContentHTMLRenderer } from "~/modules/renderer/html"
|
||||
import { EntryContentMarkdownRenderer } from "~/modules/renderer/markdown"
|
||||
import { WrappedElementProvider } from "~/providers/wrapped-element-provider"
|
||||
@@ -29,6 +33,7 @@ import { EntryRenderError } from "../entry-content/EntryRenderError"
|
||||
import { ReadabilityNotice } from "../entry-content/ReadabilityNotice"
|
||||
import { EntryAttachments } from "../EntryAttachments"
|
||||
import { EntryTitle } from "../EntryTitle"
|
||||
import { TextSelectionToolbar } from "../selection/TextSelectionToolbar"
|
||||
import { MediaTranscript, TranscriptToggle, useTranscription } from "./shared"
|
||||
import { ArticleAudioPlayer } from "./shared/AudioPlayer"
|
||||
import type { EntryLayoutProps } from "./types"
|
||||
@@ -48,30 +53,44 @@ export const ArticleLayout: React.FC<EntryLayoutProps> = ({
|
||||
const feed = useFeedById(entry?.feedId)
|
||||
const isInbox = useIsInbox(entry?.inboxId)
|
||||
const [showTranscript, setShowTranscript] = useState(false)
|
||||
const [textSelection, setTextSelection] = useState<TextSelectionEvent | null>(null)
|
||||
|
||||
const { content } = useEntryContent(entryId)
|
||||
const customCSS = useUISettingKey("customCSS")
|
||||
|
||||
const { addOrUpdateBlock, removeBlock } = useBlockActions()
|
||||
const handleTextSelect = useCallback(
|
||||
(event: TextSelectionEvent) => {
|
||||
addOrUpdateBlock({
|
||||
id: BlockSliceAction.SPECIAL_TYPES.selectedText,
|
||||
type: "selectedText",
|
||||
value: event.selectedText,
|
||||
})
|
||||
},
|
||||
[addOrUpdateBlock],
|
||||
)
|
||||
const handleTextSelect = useCallback((event: TextSelectionEvent) => {
|
||||
setTextSelection(event)
|
||||
}, [])
|
||||
const handleSelectionClear = useCallback(() => {
|
||||
removeBlock(BlockSliceAction.SPECIAL_TYPES.selectedText)
|
||||
}, [removeBlock])
|
||||
setTextSelection(null)
|
||||
}, [])
|
||||
|
||||
const aiChatPanelStyle = useAIChatPanelStyle()
|
||||
const isAIPanelVisible = useAIPanelVisibility()
|
||||
|
||||
const shouldShowAISummary = aiChatPanelStyle === AIChatPanelStyle.Floating || !isAIPanelVisible
|
||||
|
||||
const handleAskAI = useCallback(
|
||||
(selectionEvent?: TextSelectionEvent) => {
|
||||
const pendingSelection = selectionEvent ?? textSelection
|
||||
if (!pendingSelection?.selectedText) return
|
||||
|
||||
queueSelectedTextInsertion({
|
||||
text: pendingSelection.selectedText,
|
||||
sourceEntryId: entryId,
|
||||
timestamp: pendingSelection.timestamp,
|
||||
})
|
||||
setAIPanelVisibility(true)
|
||||
handleSelectionClear()
|
||||
},
|
||||
[entryId, handleSelectionClear, textSelection],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!showTranscript) return
|
||||
handleSelectionClear()
|
||||
}, [showTranscript, handleSelectionClear])
|
||||
|
||||
if (!entry) return null
|
||||
|
||||
return (
|
||||
@@ -120,6 +139,12 @@ export const ArticleLayout: React.FC<EntryLayoutProps> = ({
|
||||
)}
|
||||
</ErrorBoundary>
|
||||
</div>
|
||||
<TextSelectionToolbar
|
||||
selection={textSelection}
|
||||
onRequestClose={handleSelectionClear}
|
||||
onAskAI={handleAskAI}
|
||||
entryId={entryId}
|
||||
/>
|
||||
</WrappedElementProvider>
|
||||
|
||||
<EntryAttachments entryId={entryId} />
|
||||
|
||||
+181
-106
@@ -1,9 +1,10 @@
|
||||
import { Spring } from "@follow/components/constants/spring.js"
|
||||
import { useEntry } from "@follow/store/entry/hooks"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import * as Slider from "@radix-ui/react-slider"
|
||||
import dayjs from "dayjs"
|
||||
import { AnimatePresence, m } from "motion/react"
|
||||
import { useCallback, useMemo } from "react"
|
||||
import { useCallback, useMemo, useState } from "react"
|
||||
|
||||
import { AudioPlayer, useAudioPlayerAtomSelector } from "~/atoms/player"
|
||||
|
||||
@@ -55,6 +56,10 @@ export const ArticleAudioPlayer: React.FC<AudioPlayerProps> = ({ entryId, classN
|
||||
const isPlaying = isCurrentAudio && status === "playing"
|
||||
const isLoading = isCurrentAudio && status === "loading"
|
||||
|
||||
// Slider drag state
|
||||
const [isDragging, setIsDragging] = useState(false)
|
||||
const [dragValue, setDragValue] = useState(0)
|
||||
|
||||
const handlePlayAudio = useCallback(() => {
|
||||
if (!audioAttachment) return
|
||||
|
||||
@@ -96,132 +101,202 @@ export const ArticleAudioPlayer: React.FC<AudioPlayerProps> = ({ entryId, classN
|
||||
const displayHasValidDuration =
|
||||
displayDuration && displayDuration > 0 && displayDuration !== Infinity
|
||||
|
||||
const handleProgressClick = useCallback(
|
||||
(event: React.MouseEvent<HTMLDivElement>) => {
|
||||
const handleSliderValueChange = useCallback(
|
||||
(value: number[]) => {
|
||||
if (!isCurrentAudio || !displayHasValidDuration) return
|
||||
|
||||
const rect = event.currentTarget.getBoundingClientRect()
|
||||
const clickX = event.clientX - rect.left
|
||||
const progressPercent = clickX / rect.width
|
||||
const newTime = progressPercent * displayDuration
|
||||
|
||||
AudioPlayer.seek(newTime)
|
||||
setDragValue(value[0]!)
|
||||
},
|
||||
[isCurrentAudio, displayHasValidDuration, displayDuration],
|
||||
[isCurrentAudio, displayHasValidDuration],
|
||||
)
|
||||
|
||||
const currentTimeDisplay = formatDuration(displayCurrentTime)
|
||||
const durationDisplay = formatDuration(displayDuration)
|
||||
const handleSliderValueCommit = useCallback(
|
||||
(value: number[]) => {
|
||||
if (!isCurrentAudio || !displayHasValidDuration) return
|
||||
AudioPlayer.seek(value[0]!)
|
||||
setIsDragging(false)
|
||||
},
|
||||
[isCurrentAudio, displayHasValidDuration],
|
||||
)
|
||||
|
||||
// Don't render if no audio attachment
|
||||
if (!audioAttachment) {
|
||||
return null
|
||||
}
|
||||
|
||||
const progressPercent = displayHasValidDuration ? (displayCurrentTime / displayDuration) * 100 : 0
|
||||
// Calculate slider value - use drag value when dragging, otherwise use current time
|
||||
const sliderValue = isDragging ? dragValue : displayCurrentTime
|
||||
const currentTimeDisplay = formatDuration(sliderValue)
|
||||
const durationDisplay = formatDuration(displayDuration)
|
||||
|
||||
return (
|
||||
<AnimatePresence>
|
||||
<m.div
|
||||
initial={{ opacity: 0, scale: 0.95 }}
|
||||
animate={{ opacity: 1, scale: 1 }}
|
||||
exit={{ opacity: 0, scale: 0.95 }}
|
||||
initial={{ opacity: 0, y: 8 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
exit={{ opacity: 0, y: 8 }}
|
||||
transition={Spring.presets.smooth}
|
||||
className={cn(
|
||||
"rounded-lg border border-border bg-theme-background p-4 shadow-sm",
|
||||
"my-4 w-full",
|
||||
className,
|
||||
)}
|
||||
className={cn("relative my-4 w-full rounded-2xl border backdrop-blur-2xl", className)}
|
||||
style={{
|
||||
backgroundImage:
|
||||
"linear-gradient(to bottom right, rgba(var(--color-background) / 0.98), rgba(var(--color-background) / 0.95))",
|
||||
borderColor: "hsl(var(--fo-a) / 0.2)",
|
||||
}}
|
||||
>
|
||||
{/* Control buttons and progress bar */}
|
||||
<div className="flex items-center gap-3">
|
||||
{/* Control buttons */}
|
||||
<div className="flex shrink-0 items-center gap-1">
|
||||
{/* Skip Back 10s */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleBack}
|
||||
disabled={!isCurrentAudio}
|
||||
className={cn(
|
||||
"flex size-8 items-center justify-center rounded-full transition-colors hover:bg-theme-item-hover",
|
||||
!isCurrentAudio && "cursor-not-allowed opacity-50",
|
||||
)}
|
||||
title="Back 10s"
|
||||
>
|
||||
<i className="i-mgc-back-2-cute-re size-4" />
|
||||
</button>
|
||||
{/* Inner glow layer */}
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0 rounded-2xl"
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(to bottom right, hsl(var(--fo-a) / 0.05), transparent, hsl(var(--fo-a) / 0.05))",
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Play/Pause Button */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={handlePlayAudio}
|
||||
disabled={!audioAttachment}
|
||||
className={cn(
|
||||
"flex size-10 items-center justify-center rounded-full bg-accent text-white transition-all duration-200 hover:bg-accent/90",
|
||||
"shadow-md hover:shadow-lg",
|
||||
!audioAttachment && "cursor-not-allowed opacity-50",
|
||||
)}
|
||||
title={isPlaying ? "Pause" : "Play"}
|
||||
>
|
||||
{isLoading ? (
|
||||
<i className="i-mgc-loading-3-cute-re size-5 animate-spin" />
|
||||
) : isPlaying ? (
|
||||
<i className="i-mgc-pause-cute-fi size-5" />
|
||||
) : (
|
||||
<i className="i-mgc-play-cute-fi size-5" />
|
||||
)}
|
||||
</button>
|
||||
|
||||
{/* Skip Forward 10s */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleForward}
|
||||
disabled={!isCurrentAudio}
|
||||
className={cn(
|
||||
"flex size-8 items-center justify-center rounded-full transition-colors hover:bg-theme-item-hover",
|
||||
!isCurrentAudio && "cursor-not-allowed opacity-50",
|
||||
)}
|
||||
title="Forward 10s"
|
||||
>
|
||||
<i className="i-mgc-forward-2-cute-re size-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Progress Bar Container */}
|
||||
<div className="flex-1">
|
||||
<div
|
||||
className="group h-2 w-full cursor-pointer rounded-full bg-border"
|
||||
onClick={handleProgressClick}
|
||||
>
|
||||
<div
|
||||
className="relative h-full rounded-full bg-accent transition-all duration-200"
|
||||
style={{ width: `${progressPercent}%` }}
|
||||
{/* Content */}
|
||||
<div className="relative p-5">
|
||||
{/* Control buttons and progress bar */}
|
||||
<div className="flex items-center gap-4">
|
||||
{/* Control buttons */}
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
{/* Skip Back 10s */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleBack}
|
||||
disabled={!isCurrentAudio}
|
||||
className={cn(
|
||||
"group relative flex size-9 items-center justify-center rounded-full border",
|
||||
"transition-all duration-300",
|
||||
!isCurrentAudio && "cursor-not-allowed bg-transparent opacity-40",
|
||||
isCurrentAudio &&
|
||||
"hover:[background:linear-gradient(to_right,hsl(var(--fo-a)/0.08),hsl(var(--fo-a)/0.05))_!important] hover:[border-color:hsl(var(--fo-a)/0.25)_!important]",
|
||||
)}
|
||||
style={{
|
||||
background: !isCurrentAudio
|
||||
? undefined
|
||||
: "linear-gradient(to bottom right, rgba(var(--color-background) / 0.6), rgba(var(--color-background) / 0.4))",
|
||||
borderColor: "hsl(var(--fo-a) / 0.15)",
|
||||
}}
|
||||
title="Back 10s"
|
||||
>
|
||||
{/* Hover indicator */}
|
||||
<div className="absolute right-0 top-1/2 size-4 -translate-y-1/2 translate-x-1/2 opacity-0 transition-opacity group-hover:opacity-100">
|
||||
<div className="size-full rounded-full bg-white" />
|
||||
</div>
|
||||
<i className="i-mgc-back-2-cute-re size-4 text-text-secondary transition-colors group-hover:text-text" />
|
||||
</button>
|
||||
|
||||
{/* Play/Pause Button */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={handlePlayAudio}
|
||||
disabled={!audioAttachment}
|
||||
className={cn(
|
||||
"group relative flex size-12 items-center justify-center rounded-full border",
|
||||
"transition-all duration-300",
|
||||
!audioAttachment && "cursor-not-allowed opacity-50",
|
||||
)}
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(135deg, hsl(var(--fo-a) / 0.9), hsl(var(--fo-a) / 0.75))",
|
||||
borderColor: "hsl(var(--fo-a) / 0.4)",
|
||||
}}
|
||||
title={isPlaying ? "Pause" : "Play"}
|
||||
>
|
||||
{isLoading ? (
|
||||
<i className="i-mgc-loading-3-cute-re size-6 animate-spin text-white" />
|
||||
) : isPlaying ? (
|
||||
<i className="i-mgc-pause-cute-fi size-6 text-white" />
|
||||
) : (
|
||||
<i className="i-mgc-play-cute-fi size-6 text-white" />
|
||||
)}
|
||||
</button>
|
||||
|
||||
{/* Skip Forward 10s */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleForward}
|
||||
disabled={!isCurrentAudio}
|
||||
className={cn(
|
||||
"group relative flex size-9 items-center justify-center rounded-full border",
|
||||
"transition-all duration-300",
|
||||
!isCurrentAudio && "cursor-not-allowed bg-transparent opacity-40",
|
||||
isCurrentAudio &&
|
||||
"hover:[background:linear-gradient(to_right,hsl(var(--fo-a)/0.08),hsl(var(--fo-a)/0.05))_!important] hover:[border-color:hsl(var(--fo-a)/0.25)_!important]",
|
||||
)}
|
||||
style={{
|
||||
background: !isCurrentAudio
|
||||
? undefined
|
||||
: "linear-gradient(to bottom right, rgba(var(--color-background) / 0.6), rgba(var(--color-background) / 0.4))",
|
||||
borderColor: "hsl(var(--fo-a) / 0.15)",
|
||||
}}
|
||||
title="Forward 10s"
|
||||
>
|
||||
<i className="i-mgc-forward-2-cute-re size-4 text-text-secondary transition-colors group-hover:text-text" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Progress Bar Container */}
|
||||
<div className="flex-1">
|
||||
{displayHasValidDuration ? (
|
||||
<Slider.Root
|
||||
className="group relative flex h-2.5 w-full touch-none select-none items-center"
|
||||
min={0}
|
||||
max={displayDuration}
|
||||
step={0.1}
|
||||
value={[sliderValue]}
|
||||
disabled={!isCurrentAudio}
|
||||
onPointerDown={() => {
|
||||
if (isCurrentAudio) {
|
||||
setIsDragging(true)
|
||||
setDragValue(displayCurrentTime)
|
||||
}
|
||||
}}
|
||||
onValueChange={handleSliderValueChange}
|
||||
onValueCommit={handleSliderValueCommit}
|
||||
>
|
||||
<Slider.Track className="relative h-2.5 w-full grow overflow-hidden rounded-full border border-fill bg-fill-secondary">
|
||||
<Slider.Range className="absolute inset-y-0 rounded-full bg-accent" />
|
||||
</Slider.Track>
|
||||
|
||||
<Slider.Thumb
|
||||
className="block size-3.5 rounded-full border-2 border-white bg-accent opacity-0 transition-opacity focus-visible:opacity-100 focus-visible:outline-none group-hover:opacity-100"
|
||||
aria-label="Progress"
|
||||
/>
|
||||
</Slider.Root>
|
||||
) : (
|
||||
<div
|
||||
className="relative h-2.5 w-full overflow-hidden rounded-full border"
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(to right, hsl(var(--fo-a) / 0.1), hsl(var(--fo-a) / 0.08))",
|
||||
borderColor: "hsl(var(--fo-a) / 0.15)",
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Time Display and Download */}
|
||||
<div className="flex shrink-0 items-center gap-3">
|
||||
<div className="flex gap-1.5 text-xs">
|
||||
<span className="font-mono text-text-secondary">{currentTimeDisplay}</span>
|
||||
<span className="text-text-tertiary">/</span>
|
||||
<span className="font-mono text-text-secondary">{durationDisplay}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Time Display and Download */}
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
<div className="flex gap-1 text-xs">
|
||||
<span className="font-mono text-text-secondary">{currentTimeDisplay}</span>
|
||||
<span className="text-text-secondary">/</span>
|
||||
<span className="font-mono text-text-secondary">{durationDisplay}</span>
|
||||
</div>
|
||||
{/* Divider */}
|
||||
<div
|
||||
className="h-12 w-px"
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(to bottom, transparent, hsl(var(--fo-a) / 0.2), transparent)",
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Download Button */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleDownload}
|
||||
className="flex size-7 items-center justify-center rounded-full text-text-secondary transition-colors hover:text-text"
|
||||
title="Download"
|
||||
>
|
||||
<i className="i-mgc-download-2-cute-re size-3.5" />
|
||||
</button>
|
||||
{/* Download Button */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleDownload}
|
||||
className="group relative flex size-8 items-center justify-center rounded-full bg-transparent transition-all duration-300 hover:[background:linear-gradient(to_right,hsl(var(--fo-a)/0.08),hsl(var(--fo-a)/0.05))] hover:[border-color:hsl(var(--fo-a)/0.25)]"
|
||||
title="Download"
|
||||
>
|
||||
<i className="i-mgc-download-2-cute-re size-4 text-text-secondary transition-colors group-hover:text-text" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</m.div>
|
||||
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
import { cn } from "@follow/utils"
|
||||
import type { HTMLMotionProps } from "motion/react"
|
||||
import { m } from "motion/react"
|
||||
|
||||
interface GlassButtonProps extends HTMLMotionProps<"button"> {
|
||||
variant?: "primary" | "secondary"
|
||||
isLoading?: boolean
|
||||
ref?: React.Ref<HTMLButtonElement>
|
||||
}
|
||||
|
||||
export const GlassButton = ({
|
||||
className,
|
||||
variant = "primary",
|
||||
isLoading,
|
||||
children,
|
||||
disabled,
|
||||
ref,
|
||||
...props
|
||||
}: GlassButtonProps) => {
|
||||
const isPrimary = variant === "primary"
|
||||
|
||||
return (
|
||||
<m.button
|
||||
ref={ref}
|
||||
type="button"
|
||||
disabled={disabled || isLoading}
|
||||
className={cn(
|
||||
"relative flex items-center gap-2 overflow-hidden rounded-full border px-4 py-1.5 text-sm font-semibold backdrop-blur-md",
|
||||
"transition-all duration-300",
|
||||
"disabled:cursor-not-allowed disabled:opacity-50",
|
||||
isPrimary
|
||||
? "border-accent/30 text-white"
|
||||
: "border-text/10 bg-fill/5 text-text hover:bg-fill/10",
|
||||
className,
|
||||
)}
|
||||
style={
|
||||
isPrimary
|
||||
? {
|
||||
background: "linear-gradient(135deg, hsl(var(--fo-a) / 0.9), hsl(var(--fo-a) / 0.8))",
|
||||
boxShadow:
|
||||
"0 4px 16px hsl(var(--fo-a) / 0.2), 0 2px 8px hsl(var(--fo-a) / 0.15), inset 0 1px 1px rgba(255, 255, 255, 0.2)",
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
whileHover={
|
||||
!disabled && !isLoading
|
||||
? {
|
||||
scale: 1.05,
|
||||
boxShadow: isPrimary
|
||||
? "0 6px 24px hsl(var(--fo-a) / 0.3), 0 4px 12px hsl(var(--fo-a) / 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.3)"
|
||||
: "0 4px 12px rgba(0,0,0,0.05)",
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
whileTap={!disabled && !isLoading ? { scale: 0.95 } : undefined}
|
||||
{...props}
|
||||
>
|
||||
{/* Hover shine effect for primary */}
|
||||
{isPrimary && (
|
||||
<div className="absolute inset-0 -translate-x-full bg-gradient-to-r from-transparent via-white/20 to-transparent transition-transform duration-700 hover:translate-x-full" />
|
||||
)}
|
||||
{children as React.ReactNode}
|
||||
</m.button>
|
||||
)
|
||||
}
|
||||
|
||||
GlassButton.displayName = "GlassButton"
|
||||
+535
@@ -0,0 +1,535 @@
|
||||
import { Spring } from "@follow/components/constants/spring.js"
|
||||
import { useEntry } from "@follow/store/entry/hooks"
|
||||
import { useFeedById } from "@follow/store/feed/hooks"
|
||||
import { cn } from "@follow/utils"
|
||||
import { m } from "motion/react"
|
||||
import { useCallback, useEffect, useRef, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { toast } from "sonner"
|
||||
|
||||
import { useCurrentModal } from "~/components/ui/modal/stacked/hooks"
|
||||
import { copyImageToClipboard } from "~/lib/clipboard"
|
||||
import { UrlBuilder } from "~/lib/url-builder"
|
||||
|
||||
import { GlassButton } from "./GlassButton"
|
||||
|
||||
type SharePosterModalProps = {
|
||||
selectedText: string
|
||||
entryId: string
|
||||
}
|
||||
|
||||
type Mode = "light" | "dark"
|
||||
|
||||
export function SharePosterModal({ selectedText, entryId }: SharePosterModalProps) {
|
||||
const { t } = useTranslation()
|
||||
const { dismiss } = useCurrentModal()
|
||||
const canvasRef = useRef<HTMLCanvasElement>(null)
|
||||
const [isCopying, setIsCopying] = useState(false)
|
||||
const [authorAvatarImg, setAuthorAvatarImg] = useState<HTMLImageElement | null>(null)
|
||||
const [mode, setMode] = useState<Mode>(
|
||||
document.documentElement.classList.contains("dark") ? "dark" : "light",
|
||||
)
|
||||
|
||||
const entry = useEntry(entryId, (state) => ({
|
||||
title: state.title,
|
||||
feedId: state.feedId,
|
||||
author: state.author,
|
||||
authorAvatar: state.authorAvatar,
|
||||
publishedAt: state.publishedAt,
|
||||
url: state.url,
|
||||
}))
|
||||
|
||||
const feed = useFeedById(entry?.feedId)
|
||||
|
||||
// Load author avatar image
|
||||
useEffect(() => {
|
||||
if (entry?.authorAvatar) {
|
||||
loadImage(entry.authorAvatar).then(setAuthorAvatarImg)
|
||||
} else {
|
||||
setAuthorAvatarImg(null)
|
||||
}
|
||||
}, [entry?.authorAvatar])
|
||||
|
||||
const draw = useCallback(() => {
|
||||
const canvas = canvasRef.current
|
||||
if (!canvas) return
|
||||
|
||||
const ctx = canvas.getContext("2d", {
|
||||
alpha: false, // Better performance for opaque backgrounds
|
||||
desynchronized: false, // Better quality
|
||||
})
|
||||
if (!ctx) return
|
||||
|
||||
// High resolution for crisp text - use higher scale for better quality
|
||||
// Scale 3 provides excellent quality for long text
|
||||
const scale = 3
|
||||
const baseWidth = 720
|
||||
const width = baseWidth * scale
|
||||
|
||||
// --- Config ---
|
||||
const baseConfig = {
|
||||
bg: mode === "dark" ? "#0f0f0f" : "#ffffff",
|
||||
bgGradient:
|
||||
mode === "dark" ? ["#1a1a1a", "#0f0f0f", "#0a0a0a"] : ["#fafafa", "#ffffff", "#f5f5f5"],
|
||||
text: mode === "dark" ? "#f5f5f5" : "#1a1a1a",
|
||||
textSecondary: mode === "dark" ? "#a3a3a3" : "#525252",
|
||||
accent: mode === "dark" ? "#737373" : "#737373",
|
||||
quoteColor: mode === "dark" ? "#404040" : "#e5e5e5",
|
||||
logoColor: mode === "dark" ? "#ff5c00" : "#ff5c00",
|
||||
fontFamilyTitle: "-apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif",
|
||||
fontFamilyBody: "-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif",
|
||||
fontFamilyMeta: "-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif",
|
||||
sizeTitle: 36,
|
||||
sizeBody: 26,
|
||||
sizeMeta: 14,
|
||||
lineHeight: 1.7,
|
||||
titleLineHeight: 1.4,
|
||||
maxBodyLines: 18, // Limit body text to 18 lines
|
||||
}
|
||||
|
||||
const config = {
|
||||
...baseConfig,
|
||||
fontTitle: `600 ${baseConfig.sizeTitle}px ${baseConfig.fontFamilyTitle}`,
|
||||
fontBody: `400 ${baseConfig.sizeBody}px ${baseConfig.fontFamilyBody}`,
|
||||
fontMeta: `500 ${baseConfig.sizeMeta}px ${baseConfig.fontFamilyMeta}`,
|
||||
}
|
||||
|
||||
// --- Measure Height ---
|
||||
const padding = 56
|
||||
const contentWidth = width / scale - padding * 2
|
||||
|
||||
// Measure Body - with truncation
|
||||
ctx.font = config.fontBody
|
||||
const allBodyLines = wrapText(ctx, selectedText, contentWidth)
|
||||
const bodyLines = allBodyLines.slice(0, config.maxBodyLines)
|
||||
const bodyHeight = bodyLines.length * (baseConfig.sizeBody * config.lineHeight)
|
||||
|
||||
// Measure Title
|
||||
let titleHeight = 0
|
||||
if (entry?.title) {
|
||||
ctx.font = config.fontTitle
|
||||
const titleLines = wrapText(ctx, entry.title, contentWidth)
|
||||
titleHeight = titleLines.length * (baseConfig.sizeTitle * config.titleLineHeight) + 24 // + margin
|
||||
}
|
||||
|
||||
// Total Height Calculation
|
||||
const headerHeight = 72
|
||||
const authorHeight = entry?.author ? 48 : 0 // Increased for avatar
|
||||
const footerHeight = 80 // Increased for logo
|
||||
const spacing = 48
|
||||
const quoteSpacing = 32
|
||||
|
||||
const totalContentHeight =
|
||||
padding +
|
||||
headerHeight +
|
||||
quoteSpacing +
|
||||
bodyHeight +
|
||||
spacing +
|
||||
titleHeight +
|
||||
authorHeight +
|
||||
footerHeight +
|
||||
padding
|
||||
const minHeight = 800
|
||||
const finalHeight = Math.max(minHeight, totalContentHeight) * scale
|
||||
|
||||
// Resize canvas
|
||||
canvas.width = width
|
||||
canvas.height = finalHeight
|
||||
|
||||
// Enable high-quality rendering
|
||||
ctx.imageSmoothingEnabled = true
|
||||
ctx.imageSmoothingQuality = "high"
|
||||
|
||||
// Scale context for high DPI rendering
|
||||
ctx.scale(scale, scale)
|
||||
|
||||
const w = width / scale
|
||||
const h = finalHeight / scale
|
||||
|
||||
// --- Background with Gradient ---
|
||||
const gradient = ctx.createLinearGradient(0, 0, 0, h)
|
||||
const bgColors = config.bgGradient
|
||||
gradient.addColorStop(0, bgColors[0] ?? config.bg)
|
||||
gradient.addColorStop(0.5, bgColors[1] ?? config.bg)
|
||||
gradient.addColorStop(1, bgColors[2] ?? config.bg)
|
||||
ctx.fillStyle = gradient
|
||||
ctx.fillRect(0, 0, w, h)
|
||||
|
||||
// Subtle texture overlay
|
||||
ctx.save()
|
||||
ctx.globalAlpha = 0.03
|
||||
for (let i = 0; i < w; i += 4) {
|
||||
for (let j = 0; j < h; j += 4) {
|
||||
if ((i + j) % 8 === 0) {
|
||||
ctx.fillStyle = mode === "dark" ? "#ffffff" : "#000000"
|
||||
ctx.fillRect(i, j, 1, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.restore()
|
||||
|
||||
// --- Layout Drawing ---
|
||||
let currentY = padding + 24
|
||||
|
||||
// 1. Header (Feed Info)
|
||||
ctx.fillStyle = config.textSecondary
|
||||
ctx.globalAlpha = 0.7
|
||||
ctx.font = config.fontMeta
|
||||
ctx.textAlign = "left"
|
||||
ctx.textBaseline = "top"
|
||||
|
||||
const dateStr = entry?.publishedAt
|
||||
? new Date(entry.publishedAt).toLocaleDateString(undefined, {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
})
|
||||
: new Date().toLocaleDateString()
|
||||
|
||||
const headerText = `${feed?.title || "Folo"} • ${dateStr}`
|
||||
ctx.fillText(headerText, padding, currentY)
|
||||
|
||||
currentY += headerHeight
|
||||
|
||||
// 2. Quote Body with improved styling
|
||||
ctx.save()
|
||||
|
||||
// Decorative Quote Mark - larger and more refined
|
||||
ctx.fillStyle = config.quoteColor
|
||||
ctx.globalAlpha = 0.4
|
||||
ctx.font = "bold 64px Georgia, serif"
|
||||
ctx.textAlign = "left"
|
||||
ctx.textBaseline = "top"
|
||||
ctx.fillText("\u201C", padding - 36, currentY - 24)
|
||||
|
||||
ctx.restore()
|
||||
|
||||
// Body text with better spacing
|
||||
ctx.fillStyle = config.text
|
||||
ctx.globalAlpha = 1
|
||||
ctx.font = config.fontBody
|
||||
ctx.textAlign = "left"
|
||||
ctx.textBaseline = "top"
|
||||
|
||||
bodyLines.forEach((line, index) => {
|
||||
// Add slight indentation for continuation lines
|
||||
const indent = index === 0 ? 0 : 24
|
||||
ctx.fillText(line, padding + indent, currentY)
|
||||
currentY += baseConfig.sizeBody * config.lineHeight
|
||||
})
|
||||
|
||||
// Show truncation indicator if text was truncated
|
||||
if (allBodyLines.length > config.maxBodyLines) {
|
||||
currentY += 8
|
||||
ctx.fillStyle = config.textSecondary
|
||||
ctx.globalAlpha = 0.6
|
||||
ctx.font = config.fontMeta
|
||||
ctx.fillText("...", padding, currentY)
|
||||
ctx.globalAlpha = 1
|
||||
}
|
||||
|
||||
currentY += spacing
|
||||
|
||||
// 3. Divider line
|
||||
ctx.save()
|
||||
ctx.strokeStyle = config.quoteColor
|
||||
ctx.globalAlpha = 0.2
|
||||
ctx.lineWidth = 1
|
||||
ctx.beginPath()
|
||||
ctx.moveTo(padding, currentY - spacing / 2)
|
||||
ctx.lineTo(w - padding, currentY - spacing / 2)
|
||||
ctx.stroke()
|
||||
ctx.restore()
|
||||
|
||||
// 4. Entry Title & Author
|
||||
if (entry?.title) {
|
||||
currentY += 8
|
||||
ctx.fillStyle = config.text
|
||||
ctx.globalAlpha = 0.9
|
||||
ctx.font = config.fontTitle
|
||||
const titleLines = wrapText(ctx, entry.title, contentWidth)
|
||||
titleLines.forEach((line) => {
|
||||
ctx.fillText(line, padding, currentY)
|
||||
currentY += baseConfig.sizeTitle * config.titleLineHeight
|
||||
})
|
||||
}
|
||||
|
||||
if (entry?.author) {
|
||||
currentY += 16
|
||||
|
||||
// Draw author avatar if available
|
||||
const avatarSize = 32
|
||||
const avatarX = padding
|
||||
const avatarY = currentY
|
||||
|
||||
if (authorAvatarImg) {
|
||||
// Draw circular avatar
|
||||
ctx.save()
|
||||
ctx.beginPath()
|
||||
ctx.arc(avatarX + avatarSize / 2, avatarY + avatarSize / 2, avatarSize / 2, 0, Math.PI * 2)
|
||||
ctx.clip()
|
||||
ctx.drawImage(authorAvatarImg, avatarX, avatarY, avatarSize, avatarSize)
|
||||
ctx.restore()
|
||||
}
|
||||
|
||||
// Draw author name
|
||||
ctx.fillStyle = config.textSecondary
|
||||
ctx.globalAlpha = 0.8
|
||||
ctx.font = config.fontMeta
|
||||
const authorTextX = authorAvatarImg ? padding + avatarSize + 12 : padding
|
||||
ctx.fillText(`By ${entry.author}`, authorTextX, avatarY + avatarSize / 2 - 7)
|
||||
ctx.globalAlpha = 1
|
||||
}
|
||||
|
||||
// 5. Footer / Branding - Draw Folo logo and text
|
||||
const footerY = h - padding - 24
|
||||
const logoSize = 36
|
||||
const gap = 16
|
||||
const svgScale = logoSize / 24
|
||||
|
||||
// Calculate positions for [Logo] [Folo] aligned to right
|
||||
// Total width = logoSize + gap + logoSize (assuming folo text is also 24x24 scaled)
|
||||
const totalWidth = logoSize + gap + logoSize
|
||||
const startX = w - padding - totalWidth
|
||||
|
||||
const logoX = startX
|
||||
const foloX = startX + logoSize + gap
|
||||
const drawY = footerY - logoSize / 2
|
||||
|
||||
ctx.save()
|
||||
|
||||
// Draw Logo
|
||||
ctx.translate(logoX, drawY)
|
||||
ctx.scale(svgScale, svgScale)
|
||||
|
||||
// Logo Background
|
||||
ctx.fillStyle = config.logoColor
|
||||
const logoBgPath = new Path2D(
|
||||
"M5.382 0h13.236A5.37 5.37 0 0 1 24 5.383v13.235A5.37 5.37 0 0 1 18.618 24H5.382A5.37 5.37 0 0 1 0 18.618V5.383A5.37 5.37 0 0 1 5.382.001Z",
|
||||
)
|
||||
ctx.fill(logoBgPath)
|
||||
|
||||
// Logo F
|
||||
ctx.fillStyle = "#ffffff"
|
||||
const logoFPath = new Path2D(
|
||||
"M13.269 17.31a1.813 1.813 0 1 0-3.626.002 1.813 1.813 0 0 0 3.626-.002m-.535-6.527H7.213a1.813 1.813 0 1 0 0 3.624h5.521a1.813 1.813 0 1 0 0-3.624m4.417-4.712H8.87a1.813 1.813 0 1 0 0 3.625h8.283a1.813 1.813 0 1 0 0-3.624z",
|
||||
)
|
||||
ctx.fill(logoFPath)
|
||||
|
||||
ctx.restore()
|
||||
|
||||
// Draw Folo Text
|
||||
ctx.save()
|
||||
ctx.translate(foloX, drawY)
|
||||
ctx.scale(svgScale, svgScale)
|
||||
|
||||
ctx.fillStyle = config.textSecondary
|
||||
ctx.globalAlpha = 0.6
|
||||
const foloPath = new Path2D(
|
||||
"M.899 16.997c-.567 0-.899-.358-.899-.994v-7.77c0-.637.36-.996 1.01-.996h4.34c.595 0 .927.29.927.788 0 .497-.332.774-.926.774H1.797v2.336H5.06c.595 0 .927.263.927.76 0 .512-.332.775-.927.775H1.797v3.332c0 .636-.318.996-.898.996m9.035.125c-2.101 0-3.553-1.52-3.553-3.664 0-2.17 1.438-3.705 3.553-3.705 2.13 0 3.567 1.534 3.567 3.705 0 2.143-1.452 3.664-3.567 3.664m0-1.493c1.134 0 1.825-.899 1.825-2.185 0-1.3-.691-2.198-1.825-2.198s-1.797.899-1.797 2.198c0 1.286.663 2.185 1.797 2.185m5.266 1.367c-.553 0-.857-.359-.857-.967V7.845c0-.608.304-.968.857-.968s.857.36.857.968v8.185c0 .608-.29.967-.857.967m5.234.125c-2.102 0-3.553-1.52-3.553-3.664 0-2.17 1.438-3.705 3.553-3.705 2.129 0 3.566 1.534 3.566 3.704 0 2.143-1.452 3.664-3.567 3.664m0-1.493c1.134 0 1.825-.899 1.825-2.185 0-1.3-.691-2.198-1.825-2.198s-1.797.899-1.797 2.198c0 1.286.663 2.185 1.797 2.185",
|
||||
)
|
||||
ctx.fill(foloPath)
|
||||
|
||||
ctx.restore()
|
||||
}, [entry, feed, mode, selectedText, authorAvatarImg])
|
||||
|
||||
useEffect(() => {
|
||||
draw()
|
||||
}, [draw])
|
||||
|
||||
const handleCopy = useCallback(async () => {
|
||||
if (!canvasRef.current || isCopying) return
|
||||
|
||||
setIsCopying(true)
|
||||
try {
|
||||
await copyImageToClipboard(canvasRef.current)
|
||||
toast.success(t("entry_content.selection_toolbar.poster_copied"))
|
||||
dismiss()
|
||||
} catch (error) {
|
||||
console.error("Failed to copy image:", error)
|
||||
toast.error(t("entry_content.selection_toolbar.poster_copy_failed"))
|
||||
} finally {
|
||||
setIsCopying(false)
|
||||
}
|
||||
}, [isCopying, t, dismiss])
|
||||
|
||||
const handleShareToX = useCallback(() => {
|
||||
if (!entry) return
|
||||
const text = selectedText.length > 200 ? `${selectedText.slice(0, 200)}...` : selectedText
|
||||
const shareUrl = UrlBuilder.shareEntry(entryId)
|
||||
const intentUrl = `https://x.com/intent/tweet?text=${encodeURIComponent(text)}&url=${encodeURIComponent(shareUrl)}`
|
||||
window.open(intentUrl, "_blank")
|
||||
}, [entry, selectedText, entryId])
|
||||
|
||||
return (
|
||||
<div className="container center size-full" onClick={(e) => e.stopPropagation()}>
|
||||
<div className="relative flex flex-col items-center justify-center gap-6">
|
||||
{/* Preview Card */}
|
||||
<m.div
|
||||
layout
|
||||
className="relative overflow-hidden rounded-2xl shadow-2xl ring-1 ring-black/5 dark:ring-white/10"
|
||||
initial={{ opacity: 0, scale: 0.9, y: 20 }}
|
||||
animate={{ opacity: 1, scale: 1, y: 0 }}
|
||||
exit={{ opacity: 0, scale: 0.9, y: 20 }}
|
||||
transition={Spring.presets.smooth}
|
||||
>
|
||||
<canvas ref={canvasRef} className="size-auto max-h-[65vh] max-w-[90vw] object-contain" />
|
||||
</m.div>
|
||||
|
||||
{/* Floating Toolbar - Glassmorphic Design */}
|
||||
<m.div
|
||||
className={cn(
|
||||
"relative flex items-center gap-3 rounded-full border p-2 backdrop-blur-2xl",
|
||||
"text-text",
|
||||
)}
|
||||
style={{
|
||||
backgroundImage:
|
||||
"linear-gradient(to bottom right, rgba(var(--color-background) / 0.95), rgba(var(--color-background) / 0.9))",
|
||||
borderWidth: "1px",
|
||||
borderStyle: "solid",
|
||||
borderColor: "hsl(var(--fo-a) / 0.2)",
|
||||
boxShadow:
|
||||
"0 8px 32px hsl(var(--fo-a) / 0.08), 0 4px 16px hsl(var(--fo-a) / 0.06), 0 2px 8px rgba(0, 0, 0, 0.1)",
|
||||
}}
|
||||
initial={{ opacity: 0, y: 20 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
exit={{ opacity: 0, y: 20 }}
|
||||
transition={{ ...Spring.presets.smooth, delay: 0.1 }}
|
||||
>
|
||||
{/* Inner glow layer */}
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0 rounded-full"
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(to bottom right, hsl(var(--fo-a) / 0.05), transparent, hsl(var(--fo-a) / 0.05))",
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Content */}
|
||||
<div className="relative z-10 flex items-center gap-3">
|
||||
{/* Mode Toggle - Glassmorphic Button */}
|
||||
<m.button
|
||||
type="button"
|
||||
onClick={() => setMode(mode === "light" ? "dark" : "light")}
|
||||
className={cn(
|
||||
"relative flex size-8 items-center justify-center rounded-full",
|
||||
"text-text-secondary transition-all duration-300",
|
||||
"hover:bg-fill/20 hover:text-text",
|
||||
)}
|
||||
whileTap={{ scale: 0.95 }}
|
||||
title="Toggle Appearance"
|
||||
>
|
||||
<span
|
||||
className={
|
||||
mode === "light"
|
||||
? "i-mingcute-sun-line text-base"
|
||||
: "i-mingcute-moon-line text-base"
|
||||
}
|
||||
/>
|
||||
</m.button>
|
||||
|
||||
{/* Share to X */}
|
||||
<m.button
|
||||
type="button"
|
||||
onClick={handleShareToX}
|
||||
className={cn(
|
||||
"relative flex size-8 items-center justify-center rounded-full",
|
||||
"text-text-secondary transition-all duration-300",
|
||||
"hover:bg-fill/20 hover:text-text",
|
||||
)}
|
||||
whileTap={{ scale: 0.95 }}
|
||||
title="Share to X"
|
||||
>
|
||||
<span className="i-mgc-social-x-cute-li text-base" />
|
||||
</m.button>
|
||||
|
||||
{/* Divider */}
|
||||
<div className="h-4 w-px bg-accent/20" />
|
||||
|
||||
{/* Actions */}
|
||||
<div className="flex items-center gap-2 pl-1">
|
||||
<GlassButton variant="secondary" onClick={() => dismiss()}>
|
||||
{t("words.close", { ns: "common" })}
|
||||
</GlassButton>
|
||||
<GlassButton onClick={handleCopy} isLoading={isCopying}>
|
||||
{isCopying ? (
|
||||
<span className="i-mingcute-loading-line relative z-10 animate-spin" />
|
||||
) : (
|
||||
<span className="i-mingcute-copy-line relative z-10" />
|
||||
)}
|
||||
<span className="relative z-10">
|
||||
{isCopying
|
||||
? t("entry_content.selection_toolbar.copying")
|
||||
: t("entry_content.selection_toolbar.copy_image")}
|
||||
</span>
|
||||
</GlassButton>
|
||||
</div>
|
||||
</div>
|
||||
</m.div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// Helper function to load image from URL
|
||||
function loadImage(url: string): Promise<HTMLImageElement | null> {
|
||||
return new Promise((resolve) => {
|
||||
const img = new Image()
|
||||
img.crossOrigin = "anonymous"
|
||||
img.onload = () => resolve(img)
|
||||
img.onerror = () => resolve(null)
|
||||
img.src = url
|
||||
})
|
||||
}
|
||||
|
||||
function wrapText(ctx: CanvasRenderingContext2D, text: string, maxWidth: number): string[] {
|
||||
const lines: string[] = []
|
||||
|
||||
// Check if text contains Chinese/Japanese/Korean characters
|
||||
const hasCJK = /[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/.test(text)
|
||||
|
||||
if (hasCJK) {
|
||||
// For CJK text, split by character and build lines
|
||||
let currentLine = ""
|
||||
|
||||
for (const char of text) {
|
||||
const testLine = currentLine + char
|
||||
const metrics = ctx.measureText(testLine)
|
||||
|
||||
if (metrics.width > maxWidth && currentLine.length > 0) {
|
||||
lines.push(currentLine)
|
||||
currentLine = char
|
||||
} else {
|
||||
currentLine = testLine
|
||||
}
|
||||
}
|
||||
|
||||
if (currentLine) {
|
||||
lines.push(currentLine)
|
||||
}
|
||||
} else {
|
||||
// For non-CJK text, split by words
|
||||
const words = text.split(/\s+/)
|
||||
let currentLine = words[0] || ""
|
||||
|
||||
for (let i = 1; i < words.length; i++) {
|
||||
const word = words[i]
|
||||
if (!word) continue
|
||||
const testLine = currentLine ? `${currentLine} ${word}` : word
|
||||
const metrics = ctx.measureText(testLine)
|
||||
|
||||
if (metrics.width > maxWidth && currentLine.length > 0) {
|
||||
lines.push(currentLine)
|
||||
currentLine = word
|
||||
} else {
|
||||
currentLine = testLine
|
||||
}
|
||||
}
|
||||
|
||||
if (currentLine) {
|
||||
lines.push(currentLine)
|
||||
}
|
||||
}
|
||||
|
||||
return lines.length > 0 ? lines : [text]
|
||||
}
|
||||
+215
@@ -0,0 +1,215 @@
|
||||
import { Spring } from "@follow/components/constants/spring.js"
|
||||
import { RootPortal } from "@follow/components/ui/portal/index.js"
|
||||
import { cn } from "@follow/utils"
|
||||
import { m } from "motion/react"
|
||||
import type { CSSProperties, MouseEventHandler } from "react"
|
||||
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { PlainModal } from "~/components/ui/modal/stacked/custom-modal"
|
||||
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
|
||||
import { copyToClipboard } from "~/lib/clipboard"
|
||||
import type { TextSelectionEvent } from "~/lib/simple-text-selection"
|
||||
|
||||
import { SharePosterModal } from "./SharePosterModal"
|
||||
|
||||
const styles = {
|
||||
toolbar: {
|
||||
backgroundImage:
|
||||
"linear-gradient(to bottom right, rgba(var(--color-background) / 0.98), rgba(var(--color-background) / 0.95))",
|
||||
boxShadow:
|
||||
"0 8px 24px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.06), 0 4px 16px hsl(var(--fo-a) / 0.08), 0 2px 8px hsl(var(--fo-a) / 0.06), 0 1px 3px rgba(0, 0, 0, 0.04)",
|
||||
} as CSSProperties,
|
||||
innerGlow: {
|
||||
background:
|
||||
"linear-gradient(to bottom right, hsl(var(--fo-a) / 0.02), transparent, hsl(var(--fo-a) / 0.02))",
|
||||
} as CSSProperties,
|
||||
}
|
||||
|
||||
type TextSelectionToolbarProps = {
|
||||
selection: TextSelectionEvent | null
|
||||
onRequestClose: () => void
|
||||
onAskAI?: (selection: TextSelectionEvent) => void
|
||||
entryId?: string
|
||||
}
|
||||
|
||||
const DEFAULT_DIMENSIONS = {
|
||||
width: 220,
|
||||
height: 48,
|
||||
}
|
||||
|
||||
const VIEWPORT_PADDING = 12
|
||||
|
||||
export function TextSelectionToolbar({
|
||||
selection,
|
||||
onRequestClose,
|
||||
onAskAI,
|
||||
entryId,
|
||||
}: TextSelectionToolbarProps) {
|
||||
const { t } = useTranslation()
|
||||
const { present } = useModalStack()
|
||||
const toolbarRef = useRef<HTMLDivElement | null>(null)
|
||||
const [toolbarSize, setToolbarSize] = useState(DEFAULT_DIMENSIONS)
|
||||
const [copied, setCopied] = useState(false)
|
||||
const [viewport, setViewport] = useState(() => getViewport())
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => setViewport(getViewport())
|
||||
window.addEventListener("resize", handleResize)
|
||||
return () => {
|
||||
window.removeEventListener("resize", handleResize)
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!selection) return
|
||||
|
||||
const handleScroll = () => onRequestClose()
|
||||
window.addEventListener("scroll", handleScroll, true)
|
||||
return () => {
|
||||
window.removeEventListener("scroll", handleScroll, true)
|
||||
}
|
||||
}, [selection, onRequestClose])
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (!selection || !toolbarRef.current) return
|
||||
const rect = toolbarRef.current.getBoundingClientRect()
|
||||
setToolbarSize({
|
||||
width: rect.width || DEFAULT_DIMENSIONS.width,
|
||||
height: rect.height || DEFAULT_DIMENSIONS.height,
|
||||
})
|
||||
}, [selection, copied])
|
||||
|
||||
useEffect(() => {
|
||||
if (!copied) return
|
||||
const timer = setTimeout(() => setCopied(false), 1600)
|
||||
return () => clearTimeout(timer)
|
||||
}, [copied])
|
||||
|
||||
const position = useMemo(() => {
|
||||
if (!selection) return null
|
||||
const { rect } = selection
|
||||
const toolbarHeight = toolbarSize.height || DEFAULT_DIMENSIONS.height
|
||||
const toolbarWidth = toolbarSize.width || DEFAULT_DIMENSIONS.width
|
||||
const viewportWidth = viewport.width || toolbarWidth
|
||||
|
||||
let top = rect.top - toolbarHeight - VIEWPORT_PADDING
|
||||
if (top < VIEWPORT_PADDING) {
|
||||
top = rect.bottom + VIEWPORT_PADDING
|
||||
}
|
||||
|
||||
let left = rect.left + rect.width / 2 - toolbarWidth / 2
|
||||
const maxLeft = Math.max(VIEWPORT_PADDING, viewportWidth - toolbarWidth - VIEWPORT_PADDING)
|
||||
left = clamp(left, VIEWPORT_PADDING, maxLeft)
|
||||
|
||||
return { top, left }
|
||||
}, [selection, toolbarSize, viewport])
|
||||
|
||||
const handleCopy = useCallback(async () => {
|
||||
if (!selection) return
|
||||
await copyToClipboard(selection.selectedText)
|
||||
setCopied(true)
|
||||
}, [selection])
|
||||
|
||||
const handleShare = useCallback(() => {
|
||||
if (!selection || !entryId) return
|
||||
present({
|
||||
CustomModalComponent: PlainModal,
|
||||
title: t("entry_content.selection_toolbar.share_poster"),
|
||||
id: "share-poster",
|
||||
content: () => <SharePosterModal selectedText={selection.selectedText} entryId={entryId} />,
|
||||
clickOutsideToDismiss: true,
|
||||
})
|
||||
onRequestClose()
|
||||
}, [selection, entryId, present, onRequestClose, t])
|
||||
|
||||
const handleMouseDown: MouseEventHandler<HTMLDivElement> = (event) => {
|
||||
event.preventDefault()
|
||||
}
|
||||
|
||||
if (!selection || !position) return null
|
||||
|
||||
return (
|
||||
<RootPortal>
|
||||
<m.div
|
||||
ref={toolbarRef}
|
||||
style={{
|
||||
top: position.top,
|
||||
left: position.left,
|
||||
...styles.toolbar,
|
||||
}}
|
||||
className="pointer-events-auto fixed z-[70] rounded-xl border border-border/50 bg-material-ultra-thick p-px backdrop-blur-background"
|
||||
onMouseDown={handleMouseDown}
|
||||
layout="position"
|
||||
initial={{ opacity: 0, y: 4, scale: 0.95 }}
|
||||
animate={{ opacity: 1, y: 0, scale: 1 }}
|
||||
transition={Spring.presets.smooth}
|
||||
>
|
||||
{/* Inner glow layer */}
|
||||
<div className="pointer-events-none absolute inset-0 rounded-xl" style={styles.innerGlow} />
|
||||
<div className="relative flex items-center gap-1 text-[0.85rem] font-medium text-text">
|
||||
<ToolbarButton
|
||||
iconClassName={copied ? "i-mgc-check-cute-re" : "i-mgc-copy-cute-re"}
|
||||
label={
|
||||
copied
|
||||
? t("entry_content.selection_toolbar.copied")
|
||||
: t("entry_content.selection_toolbar.copy")
|
||||
}
|
||||
onClick={handleCopy}
|
||||
active={copied}
|
||||
/>
|
||||
{entryId ? (
|
||||
<ToolbarButton
|
||||
iconClassName="i-mgc-share-forward-cute-re"
|
||||
label={t("entry_content.selection_toolbar.share")}
|
||||
onClick={handleShare}
|
||||
/>
|
||||
) : null}
|
||||
{onAskAI ? (
|
||||
<ToolbarButton
|
||||
iconClassName="i-mingcute-sparkles-2-line"
|
||||
label={t("entry_content.selection_toolbar.ask_ai")}
|
||||
onClick={() => onAskAI(selection)}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</m.div>
|
||||
</RootPortal>
|
||||
)
|
||||
}
|
||||
|
||||
type ToolbarButtonProps = {
|
||||
iconClassName: string
|
||||
label: string
|
||||
onClick?: () => void
|
||||
active?: boolean
|
||||
}
|
||||
|
||||
function ToolbarButton({ iconClassName, label, onClick, active }: ToolbarButtonProps) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
className={cn(
|
||||
"flex shrink-0 items-center gap-1.5 rounded-full px-3 py-1.5 text-sm transition-all duration-200",
|
||||
active
|
||||
? "bg-fill/80 text-text shadow-sm"
|
||||
: "text-text-secondary hover:bg-fill/60 hover:text-text active:scale-95",
|
||||
)}
|
||||
aria-label={label}
|
||||
>
|
||||
<i className={cn("text-base", iconClassName)} />
|
||||
<span>{label}</span>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
const clamp = (value: number, min: number, max: number) => Math.min(Math.max(value, min), max)
|
||||
|
||||
function getViewport() {
|
||||
if (typeof window === "undefined") {
|
||||
return { width: 0, height: 0 }
|
||||
}
|
||||
|
||||
return { width: window.innerWidth, height: window.innerHeight }
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import { ScrollArea } from "@follow/components/ui/scroll-area/ScrollArea.js"
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import type { EntryTagSummary } from "@follow/database/schemas/types"
|
||||
import { useEntryTagsQuery } from "@follow/store/entry/hooks"
|
||||
import { cn } from "@follow/utils"
|
||||
import { useMemo } from "react"
|
||||
import { titleCase } from "title-case"
|
||||
|
||||
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
|
||||
|
||||
import { EntryItemSkeleton } from "../entry-column/EntryItemSkeleton"
|
||||
import { EntryItem } from "../entry-column/item"
|
||||
|
||||
type TagKind = "category" | "topic"
|
||||
|
||||
interface EntryTagsProps {
|
||||
tags?: EntryTagSummary | null
|
||||
feedId?: string | null
|
||||
size?: "sm" | "md"
|
||||
className?: string
|
||||
}
|
||||
|
||||
const normalizeLabel = (label: string) => titleCase(label.replaceAll(/[_-]+/g, " "))
|
||||
|
||||
const chipClassName: Record<NonNullable<EntryTagsProps["size"]>, string> = {
|
||||
sm: "px-2 py-0.5 text-[11px]",
|
||||
md: "px-2.5 py-1 text-xs",
|
||||
}
|
||||
|
||||
type TagItem = { label: string; kind: TagKind }
|
||||
|
||||
const TagEntriesModal = ({ tag, feedId }: { tag: TagItem; feedId?: string | null }) => {
|
||||
const { data, isLoading, isFetching, refetch } = useEntryTagsQuery({
|
||||
feedId,
|
||||
tag:
|
||||
tag.kind === "category"
|
||||
? { kind: "schemaOrgCategory", value: tag.label }
|
||||
: { kind: "mediaTopic", value: tag.label },
|
||||
})
|
||||
|
||||
const entryIds = data ?? []
|
||||
|
||||
return (
|
||||
<div className="-mx-4 -mb-4 w-[min(720px,calc(100vw-2rem))] space-y-4">
|
||||
<div className="flex items-center justify-between gap-2 px-4">
|
||||
<div className="min-w-0 text-sm text-text-secondary">
|
||||
Entries tagged with {normalizeLabel(tag.label)}
|
||||
</div>
|
||||
<Button size="sm" variant="ghost" onClick={() => refetch()} disabled={isFetching}>
|
||||
<i
|
||||
className={cn(
|
||||
"i-mingcute-loading-line mr-1 size-4",
|
||||
isFetching && "animate-spin text-text-secondary",
|
||||
)}
|
||||
/>
|
||||
Refresh
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{isLoading ? (
|
||||
<div className="space-y-2">
|
||||
<EntryItemSkeleton view={FeedViewType.All} count={3} />
|
||||
</div>
|
||||
) : entryIds.length === 0 ? (
|
||||
<div className="flex flex-col items-center justify-center gap-2 py-6 text-sm text-text-secondary">
|
||||
<i className="i-mgc-inbox-cute-re text-xl" />
|
||||
<span>No entries found for this tag.</span>
|
||||
</div>
|
||||
) : (
|
||||
<ScrollArea rootClassName="h-[70vh] w-full" flex viewportClassName="pb-4">
|
||||
{entryIds.map((entryId) => (
|
||||
<EntryItem key={entryId} entryId={entryId} view={FeedViewType.All} />
|
||||
))}
|
||||
</ScrollArea>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export const EntryTags = ({
|
||||
tags,
|
||||
size = "md",
|
||||
className,
|
||||
|
||||
feedId,
|
||||
}: EntryTagsProps) => {
|
||||
const { present } = useModalStack()
|
||||
|
||||
const items = useMemo(() => {
|
||||
if (!tags) return []
|
||||
const list: TagItem[] = []
|
||||
if (tags.schemaOrgCategory) {
|
||||
list.push({ label: tags.schemaOrgCategory, kind: "category" })
|
||||
}
|
||||
if (Array.isArray(tags.mediaTopics)) {
|
||||
for (const topic of tags.mediaTopics) {
|
||||
if (topic) {
|
||||
list.push({ label: topic, kind: "topic" })
|
||||
}
|
||||
}
|
||||
}
|
||||
return list
|
||||
}, [tags])
|
||||
if (!tags) return null
|
||||
if (items.length === 0) return null
|
||||
|
||||
const handleClick = (item: TagItem, event: React.MouseEvent) => {
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
if (!feedId) return
|
||||
present({
|
||||
title: `Tag · ${normalizeLabel(item.label)}`,
|
||||
content: () => <TagEntriesModal tag={item} feedId={feedId} />,
|
||||
clickOutsideToDismiss: true,
|
||||
overlay: true,
|
||||
modal: true,
|
||||
modalClassName: "max-w-[760px]",
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn("flex min-w-0 flex-wrap items-center gap-1.5 text-text-secondary", className)}
|
||||
>
|
||||
{items.map((item, index) => (
|
||||
<button
|
||||
key={`${item.kind}-${item.label}-${index}`}
|
||||
type="button"
|
||||
onClick={(event) => handleClick(item, event)}
|
||||
className={cn(
|
||||
"cursor-pointer truncate rounded-full bg-fill-secondary text-text-secondary transition-colors duration-200 hover:bg-fill-tertiary hover:text-text",
|
||||
chipClassName[size],
|
||||
)}
|
||||
>
|
||||
{item.kind === "category"
|
||||
? `Category · ${normalizeLabel(item.label)}`
|
||||
: normalizeLabel(item.label)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import { useUserById, useWhoami } from "@follow/store/user/hooks"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { replaceImgUrlIfNeed } from "~/lib/img-proxy"
|
||||
import { useReplaceImgUrlIfNeed } from "~/lib/img-proxy"
|
||||
import { usePresentUserProfileModal } from "~/modules/profile/hooks"
|
||||
|
||||
export const FeedCertification = ({
|
||||
@@ -76,6 +76,7 @@ export const FeedCertification = ({
|
||||
}
|
||||
|
||||
const FeedCertificateAvatar = ({ userId }: { userId: string }) => {
|
||||
const replaceImgUrlIfNeed = useReplaceImgUrlIfNeed()
|
||||
const user = useUserById(userId)
|
||||
const presentUserProfile = usePresentUserProfileModal("drawer")
|
||||
if (!user) return null
|
||||
|
||||
@@ -9,6 +9,8 @@ import { m } from "motion/react"
|
||||
import type { ReactNode } from "react"
|
||||
import { useMemo } from "react"
|
||||
|
||||
import { useCanUseImageProxy } from "~/lib/img-proxy"
|
||||
|
||||
const { Avatar, AvatarFallback, AvatarImage } = AvatarPrimitive
|
||||
|
||||
// Size-responsive border radius utility function
|
||||
@@ -27,9 +29,19 @@ type GetIconPropsProps = {
|
||||
fallbackUrl?: string
|
||||
fallback?: boolean
|
||||
size?: number
|
||||
canUseProxy?: boolean
|
||||
}
|
||||
function getIconProps(props: GetIconPropsProps) {
|
||||
const { target, entry, useMedia, siteUrl: propSiteUrl, fallbackUrl, fallback, size = 20 } = props
|
||||
const {
|
||||
target,
|
||||
entry,
|
||||
useMedia,
|
||||
siteUrl: propSiteUrl,
|
||||
fallbackUrl,
|
||||
fallback,
|
||||
size = 20,
|
||||
canUseProxy,
|
||||
} = props
|
||||
const image =
|
||||
(useMedia ? entry?.firstPhotoUrl || entry?.authorAvatar : entry?.authorAvatar) || target?.image
|
||||
const siteUrl = (target as FeedModel)?.siteUrl || fallbackUrl
|
||||
@@ -37,6 +49,7 @@ function getIconProps(props: GetIconPropsProps) {
|
||||
if (propSiteUrl && !target) {
|
||||
const [src] = getFeedIconSrc({
|
||||
siteUrl: propSiteUrl,
|
||||
canUseProxy,
|
||||
})
|
||||
return {
|
||||
type: "image" as const,
|
||||
@@ -52,6 +65,7 @@ function getIconProps(props: GetIconPropsProps) {
|
||||
url: image,
|
||||
width: size * 2,
|
||||
height: size * 2,
|
||||
canUseProxy,
|
||||
}),
|
||||
platformUrl: image,
|
||||
fallbackSrc: "",
|
||||
@@ -66,6 +80,7 @@ function getIconProps(props: GetIconPropsProps) {
|
||||
width: size * 2,
|
||||
height: size * 2,
|
||||
},
|
||||
canUseProxy,
|
||||
})
|
||||
return {
|
||||
type: "image" as const,
|
||||
@@ -96,11 +111,13 @@ const getFeedIconSrc = ({
|
||||
siteUrl,
|
||||
fallback,
|
||||
proxy,
|
||||
canUseProxy,
|
||||
}: {
|
||||
src?: string
|
||||
siteUrl?: string
|
||||
fallback?: boolean
|
||||
proxy?: { height: number; width: number }
|
||||
canUseProxy?: boolean
|
||||
} = {}) => {
|
||||
if (src) {
|
||||
if (proxy) {
|
||||
@@ -109,6 +126,7 @@ const getFeedIconSrc = ({
|
||||
url: src,
|
||||
width: proxy.width,
|
||||
height: proxy.height,
|
||||
canUseProxy,
|
||||
}),
|
||||
"",
|
||||
]
|
||||
@@ -200,7 +218,17 @@ export function FeedIcon({
|
||||
noMargin?: boolean
|
||||
}) {
|
||||
const marginClassName = cn(noMargin ? "" : "mr-2", className)
|
||||
const iconProps = getIconProps({ target, entry, useMedia, siteUrl, fallbackUrl, fallback, size })
|
||||
const canUseProxy = useCanUseImageProxy()
|
||||
const iconProps = getIconProps({
|
||||
target,
|
||||
entry,
|
||||
useMedia,
|
||||
siteUrl,
|
||||
fallbackUrl,
|
||||
fallback,
|
||||
size,
|
||||
canUseProxy,
|
||||
})
|
||||
|
||||
const colors = useMemo(
|
||||
() => getBackgroundGradient(target?.title || (target as FeedModel)?.url || siteUrl || ""),
|
||||
|
||||
@@ -182,13 +182,13 @@ export class CustomIntegrationManager {
|
||||
const processedKey = this.replacePlaceholders(key, context)
|
||||
const processedValue = this.replacePlaceholders(value, context)
|
||||
// Field names are case-insensitive.
|
||||
processedHeaders[processedKey.toLowerCase()] = processedValue
|
||||
processedHeaders[processedKey.toLowerCase().trim()] = processedValue.trim()
|
||||
})
|
||||
|
||||
// Process body without URL encoding
|
||||
let processedBody: string | undefined
|
||||
if (fetchTemplate.body) {
|
||||
const jsonEscape = fetchTemplate.headers["content-type"]?.toLowerCase() === "application/json"
|
||||
const jsonEscape = processedHeaders["content-type"]?.toLowerCase() === "application/json"
|
||||
processedBody = this.replacePlaceholders(fetchTemplate.body, context, { jsonEscape })
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import { useEventCallback } from "usehooks-ts"
|
||||
import { m } from "~/components/common/Motion"
|
||||
import { useFollow } from "~/hooks/biz/useFollow"
|
||||
import { useI18n } from "~/hooks/common"
|
||||
import { replaceImgUrlIfNeed } from "~/lib/img-proxy"
|
||||
import { useReplaceImgUrlIfNeed } from "~/lib/img-proxy"
|
||||
import { FeedIcon } from "~/modules/feed/feed-icon"
|
||||
import { useUserSubscriptionsQuery } from "~/modules/profile/hooks"
|
||||
|
||||
@@ -39,6 +39,7 @@ export const SubscriptionItems = ({
|
||||
userId: string
|
||||
itemStyle: ItemVariant
|
||||
}) => {
|
||||
const replaceImgUrlIfNeed = useReplaceImgUrlIfNeed()
|
||||
const profile = usePrefetchUser(userId)
|
||||
const userInfo = useUserById(userId)
|
||||
const subscriptions = useUserSubscriptionsQuery(userId)
|
||||
|
||||
@@ -137,7 +137,7 @@ const Content: FC<{
|
||||
|
||||
const elementTop = element.offsetTop
|
||||
const scrollerTop = scroller.scrollTop
|
||||
const delta = elementTop - scrollerTop
|
||||
const delta = elementTop - scrollerTop - 20
|
||||
|
||||
scroller.scrollTo({
|
||||
top: delta,
|
||||
|
||||
@@ -20,6 +20,7 @@ const defineSettingItem = createDefineSettingItem("ai", useAISettingValue, setAI
|
||||
export const AI_SETTING_SECTION_IDS = {
|
||||
shortcuts: "settings-ai-shortcuts",
|
||||
tasks: "settings-ai-tasks",
|
||||
timelinePrompt: "settings-ai-timeline-prompt",
|
||||
} as const
|
||||
|
||||
export const SettingAI = () => {
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
import { Spring } from "@follow/components/constants/spring.js"
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import { TextArea } from "@follow/components/ui/input/index.js"
|
||||
import { AnimatePresence } from "motion/react"
|
||||
import { useEffect, useRef, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { toast } from "sonner"
|
||||
|
||||
import { setAISetting, useAISettingValue } from "~/atoms/settings/ai"
|
||||
import { m } from "~/components/common/Motion"
|
||||
|
||||
import { SettingDescription } from "../../control"
|
||||
import { SettingModalContentPortal } from "../../modal/layout"
|
||||
|
||||
export const TimelinePromptSection = () => {
|
||||
const { t } = useTranslation("ai")
|
||||
const aiSettings = useAISettingValue()
|
||||
const promptRef = useRef("")
|
||||
const [isSaving, setIsSaving] = useState(false)
|
||||
const [currentLength, setCurrentLength] = useState(0)
|
||||
const [hasChanges, setHasChanges] = useState(false)
|
||||
const [promptValue, setPromptValue] = useState(aiSettings.aiTimelinePrompt)
|
||||
|
||||
const MAX_CHARACTERS = 500
|
||||
const isOverLimit = currentLength > MAX_CHARACTERS
|
||||
|
||||
useEffect(() => {
|
||||
promptRef.current = aiSettings.aiTimelinePrompt
|
||||
setPromptValue(aiSettings.aiTimelinePrompt)
|
||||
setCurrentLength(aiSettings.aiTimelinePrompt.length)
|
||||
setHasChanges(false)
|
||||
}, [aiSettings.aiTimelinePrompt])
|
||||
|
||||
const handleEditorChange = (value: string) => {
|
||||
promptRef.current = value
|
||||
setPromptValue(value)
|
||||
setCurrentLength(value.length)
|
||||
setHasChanges(value !== aiSettings.aiTimelinePrompt)
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
if (isOverLimit) {
|
||||
toast.error(`Prompt must be ${MAX_CHARACTERS} characters or less`)
|
||||
return
|
||||
}
|
||||
|
||||
if (!promptRef.current) return
|
||||
|
||||
setIsSaving(true)
|
||||
try {
|
||||
setAISetting("aiTimelinePrompt", promptRef.current)
|
||||
toast.success(t("timeline_prompt.saved"))
|
||||
setHasChanges(false)
|
||||
} finally {
|
||||
setIsSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<div className="relative -ml-3">
|
||||
<TextArea
|
||||
value={promptValue}
|
||||
onChange={(event) => handleEditorChange(event.target.value)}
|
||||
placeholder={t("timeline_prompt.prompt.placeholder")}
|
||||
className={`min-h-[80px] resize-none text-sm ${
|
||||
isOverLimit ? "border-red focus:border-red" : ""
|
||||
}`}
|
||||
/>
|
||||
<div
|
||||
className={`absolute bottom-2 right-2 text-xs ${
|
||||
isOverLimit
|
||||
? "text-red"
|
||||
: currentLength > MAX_CHARACTERS * 0.8
|
||||
? "text-yellow"
|
||||
: "text-text-tertiary"
|
||||
}`}
|
||||
>
|
||||
{currentLength}/{MAX_CHARACTERS}
|
||||
</div>
|
||||
</div>
|
||||
<SettingDescription>
|
||||
{t("timeline_prompt.prompt.help")}
|
||||
{isOverLimit && (
|
||||
<span className="mt-1 block text-red">
|
||||
Prompt exceeds {MAX_CHARACTERS} character limit
|
||||
</span>
|
||||
)}
|
||||
</SettingDescription>
|
||||
</div>
|
||||
|
||||
<AnimatePresence>
|
||||
{hasChanges && (
|
||||
<SettingModalContentPortal>
|
||||
<m.div
|
||||
initial={{ opacity: 0, y: 20 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
exit={{ opacity: 0, y: 20 }}
|
||||
transition={Spring.presets.snappy}
|
||||
className="absolute inset-x-0 bottom-3 z-10 flex justify-center px-3"
|
||||
>
|
||||
<div
|
||||
className="relative overflow-hidden rounded-full backdrop-blur-2xl"
|
||||
style={{
|
||||
backgroundImage:
|
||||
"linear-gradient(to bottom right, rgba(var(--color-background) / 0.98), rgba(var(--color-background) / 0.95))",
|
||||
borderWidth: "1px",
|
||||
borderStyle: "solid",
|
||||
borderColor: "hsl(var(--fo-a) / 0.2)",
|
||||
boxShadow:
|
||||
"0 8px 32px hsl(var(--fo-a) / 0.08), 0 4px 16px hsl(var(--fo-a) / 0.06), 0 2px 8px rgba(0, 0, 0, 0.1)",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="absolute inset-0 rounded-2xl"
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(to bottom right, hsl(var(--fo-a) / 0.05), transparent, hsl(var(--fo-a) / 0.05))",
|
||||
}}
|
||||
/>
|
||||
|
||||
<div className="relative flex w-fit max-w-full items-center justify-between gap-3 px-5 py-3">
|
||||
<span className="whitespace-nowrap text-xs text-text-secondary sm:text-sm">
|
||||
Unsaved changes
|
||||
</span>
|
||||
<Button
|
||||
buttonClassName="bg-accent rounded-full"
|
||||
size="sm"
|
||||
onClick={handleSave}
|
||||
disabled={isSaving || isOverLimit}
|
||||
>
|
||||
{isSaving ? "Saving..." : "Save"}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</m.div>
|
||||
</SettingModalContentPortal>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import { getColorScheme, stringToHue } from "@follow/utils/color"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
|
||||
import { useServerConfigs } from "~/atoms/server-configs"
|
||||
import { replaceImgUrlIfNeed } from "~/lib/img-proxy"
|
||||
import { useReplaceImgUrlIfNeed } from "~/lib/img-proxy"
|
||||
import { usePresentUserProfileModal } from "~/modules/profile/hooks"
|
||||
|
||||
import type { LoginProps } from "./LoginButton"
|
||||
@@ -29,6 +29,7 @@ export const UserAvatar = ({
|
||||
enableModal?: boolean
|
||||
} & LoginProps &
|
||||
React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement | null> }) => {
|
||||
const replaceImgUrlIfNeed = useReplaceImgUrlIfNeed()
|
||||
const serverConfig = useServerConfigs()
|
||||
const whoami = useWhoami()
|
||||
const role = useUserRole()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "Folo",
|
||||
"type": "module",
|
||||
"version": "1.1.7",
|
||||
"version": "1.2.1",
|
||||
"private": true,
|
||||
"description": "Follow everything in one place",
|
||||
"author": "Folo Team",
|
||||
@@ -87,5 +87,5 @@
|
||||
"vite-tsconfig-paths": "5.1.4"
|
||||
},
|
||||
"productName": "Folo",
|
||||
"mainHash": "6019029dfdddbdac8acf0f2a64d1ce575d49bff7a1576b9785fcddacee5f3452"
|
||||
"mainHash": "ddce11a91e6a16e28d193a7d4f0f211d2903d5e6d53193fc5fa7a9735c17f0e8"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createBuildSafeHeaders } from "@follow/utils/headers"
|
||||
import { getImageProxyUrl, IMAGE_PROXY_URL } from "@follow/utils/img-proxy"
|
||||
import { IMAGE_PROXY_URL } from "@follow/utils/img-proxy"
|
||||
import ImageEditor from "@react-native-community/image-editor"
|
||||
import * as FileSystem from "expo-file-system"
|
||||
import type { ImageProps, ImageSource } from "expo-image"
|
||||
@@ -8,6 +8,7 @@ import * as Sharing from "expo-sharing"
|
||||
import { useCallback } from "react"
|
||||
import { Image } from "react-native"
|
||||
|
||||
import { getImageProxyUrl } from "@/src/lib/img-proxy"
|
||||
import { isAndroid, isNative } from "@/src/lib/platform"
|
||||
import { proxyEnv } from "@/src/lib/proxy-env"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import {
|
||||
getImageProxyUrl as getImageProxyUrlUtils,
|
||||
replaceImgUrlIfNeed as replaceImgUrlIfNeedUtils,
|
||||
} from "@follow/utils/img-proxy"
|
||||
|
||||
export const getImageProxyUrl = (
|
||||
params: Omit<Parameters<typeof getImageProxyUrlUtils>[0], "canUseProxy">,
|
||||
) => {
|
||||
return getImageProxyUrlUtils({
|
||||
...params,
|
||||
canUseProxy: true,
|
||||
})
|
||||
}
|
||||
|
||||
export const replaceImgUrlIfNeed = (
|
||||
params: Omit<Parameters<typeof replaceImgUrlIfNeedUtils>[0], "canUseProxy">,
|
||||
) => {
|
||||
return replaceImgUrlIfNeedUtils({
|
||||
...params,
|
||||
canUseProxy: true,
|
||||
})
|
||||
}
|
||||
@@ -28,6 +28,7 @@ const getFeedIconSrc = ({
|
||||
url: src,
|
||||
width: proxy.width,
|
||||
height: proxy.height,
|
||||
canUseProxy: true,
|
||||
}),
|
||||
"",
|
||||
]
|
||||
|
||||
@@ -41,6 +41,7 @@ export const LazyImage = ({
|
||||
url: src,
|
||||
width: proxy?.width,
|
||||
height: proxy?.height,
|
||||
canUseProxy: true,
|
||||
})
|
||||
}, [src, proxy?.height, proxy?.width])
|
||||
return (
|
||||
|
||||
+17
-2
@@ -186,8 +186,8 @@
|
||||
"rate_limit.resets_in": "resets in {{value}}",
|
||||
"rate_limit.resets_next_month": "resets at next month",
|
||||
"rate_limit.resets_tomorrow": "resets at tomorrow",
|
||||
"rate_limit.upgrade_plan_button": "Upgrade Plan",
|
||||
"rate_limit.upgrade_to_get_more": "Upgrade plan to get more AI credits.",
|
||||
"rate_limit.upgrade_plan_button": "Free Trial",
|
||||
"rate_limit.upgrade_to_get_more": "Start free trial to get more AI credits.",
|
||||
"schedule.configuration_label": "Configuration",
|
||||
"schedule.date_time_label": "Date & Time",
|
||||
"schedule.date_time_placeholder": "Select date & time",
|
||||
@@ -323,6 +323,10 @@
|
||||
"tasks.validation.title_required": "Title is required",
|
||||
"tasks.view_in_settings": "View scheduled tasks",
|
||||
"timeline.summary.title_template": "{{- datetime}} timeline summary",
|
||||
"timeline_prompt.prompt.help": "Used when AI sorts your timeline. Mention the topics or sources you prefer along with anything you dislike.",
|
||||
"timeline_prompt.prompt.placeholder": "Describe what you want the AI timeline to prioritize or avoid...",
|
||||
"timeline_prompt.saved": "Timeline sorting preferences saved successfully",
|
||||
"timeline_prompt.title": "Timeline Sorting Prompt",
|
||||
"timeline_summary.empty": "Timeline summary will appear here shortly.",
|
||||
"timeline_summary.error": "Unable to generate timeline summary right now.",
|
||||
"timeline_summary.generating": "Summarizing your timeline...",
|
||||
@@ -333,6 +337,17 @@
|
||||
"token_usage.title": "AI Credits Usage",
|
||||
"token_usage.tokens_remaining": "credits remaining",
|
||||
"token_usage.tokens_used": "{{used}} / {{total}} credits used",
|
||||
"token_usage_pill.billed": "Billed",
|
||||
"token_usage_pill.byok": "BYOK",
|
||||
"token_usage_pill.credits": "Credits",
|
||||
"token_usage_pill.credits_usage": "AI Credits Usage",
|
||||
"token_usage_pill.duration": "Duration",
|
||||
"token_usage_pill.model_info": "Model Info",
|
||||
"token_usage_pill.multiplier": "Multiplier",
|
||||
"token_usage_pill.provider_info": "Provider Info",
|
||||
"token_usage_pill.system": "System",
|
||||
"token_usage_pill.total": "Total",
|
||||
"token_usage_pill.unknown": "Unknown",
|
||||
"usage_analysis.active_session": "Active Session",
|
||||
"usage_analysis.current_usage": "Current Usage",
|
||||
"usage_analysis.detailed_description": "Comprehensive overview of your AI usage patterns and insights",
|
||||
|
||||
@@ -283,6 +283,17 @@
|
||||
"timeline_summary.generating": "タイムラインを要約しています...",
|
||||
"timeline_summary.heading": "タイムラインに新しい内容はありますか",
|
||||
"timeline_summary.options.include": "タイムライン要約でチャット",
|
||||
"token_usage_pill.billed": "請求済み",
|
||||
"token_usage_pill.byok": "BYOK",
|
||||
"token_usage_pill.credits": "クレジット",
|
||||
"token_usage_pill.credits_usage": "AI クレジット使用",
|
||||
"token_usage_pill.duration": "持続時間",
|
||||
"token_usage_pill.model_info": "モデル情報",
|
||||
"token_usage_pill.multiplier": "倍数",
|
||||
"token_usage_pill.provider_info": "プロバイダー情報",
|
||||
"token_usage_pill.system": "システム",
|
||||
"token_usage_pill.total": "合計",
|
||||
"token_usage_pill.unknown": "不明",
|
||||
"usage_analysis.active_session": "アクティブセッション",
|
||||
"usage_analysis.current_usage": "現在の使用状況",
|
||||
"usage_analysis.detailed_description": "AI使用パターンとインサイトの包括的概要",
|
||||
|
||||
+17
-2
@@ -181,8 +181,8 @@
|
||||
"rate_limit.resets_in": "将在 {{value}} 后重置",
|
||||
"rate_limit.resets_next_month": "将于下个月重置",
|
||||
"rate_limit.resets_tomorrow": "将于明天重置",
|
||||
"rate_limit.upgrade_plan_button": "升级套餐",
|
||||
"rate_limit.upgrade_to_get_more": "升级套餐以获得更多 AI 额度。",
|
||||
"rate_limit.upgrade_plan_button": "免费试用",
|
||||
"rate_limit.upgrade_to_get_more": "开启免费试用以获得更多 AI 额度。",
|
||||
"schedule.configuration_label": "配置",
|
||||
"schedule.date_time_label": "日期和时间",
|
||||
"schedule.date_time_placeholder": "选择日期和时间",
|
||||
@@ -316,6 +316,10 @@
|
||||
"tasks.validation.title_required": "标题为必填项",
|
||||
"tasks.view_in_settings": "在设置中查看已计划任务",
|
||||
"timeline.summary.title_template": "{{- datetime}} 时间线总结",
|
||||
"timeline_prompt.prompt.help": "这些信息会被用于 AI 时间线排序,写出你喜欢的主题、来源及希望降权的内容。",
|
||||
"timeline_prompt.prompt.placeholder": "描述下你希望 AI 时间线优先展示或避开的内容……",
|
||||
"timeline_prompt.saved": "时间线排序偏好已保存",
|
||||
"timeline_prompt.title": "AI 时间线排序提示",
|
||||
"timeline_summary.empty": "时间线总结即将呈现。",
|
||||
"timeline_summary.error": "暂时无法生成时间线总结。",
|
||||
"timeline_summary.generating": "正在生成时间线总结...",
|
||||
@@ -326,6 +330,17 @@
|
||||
"token_usage.title": "令牌使用情况",
|
||||
"token_usage.tokens_remaining": "剩余令牌",
|
||||
"token_usage.tokens_used": "已使用{{used}} / {{total}}令牌",
|
||||
"token_usage_pill.billed": "计费",
|
||||
"token_usage_pill.byok": "BYOK",
|
||||
"token_usage_pill.credits": "额度",
|
||||
"token_usage_pill.credits_usage": "AI 额度使用",
|
||||
"token_usage_pill.duration": "持续时间",
|
||||
"token_usage_pill.model_info": "模型信息",
|
||||
"token_usage_pill.multiplier": "倍数",
|
||||
"token_usage_pill.provider_info": "提供商信息",
|
||||
"token_usage_pill.system": "系统",
|
||||
"token_usage_pill.total": "总计",
|
||||
"token_usage_pill.unknown": "未知",
|
||||
"usage_analysis.active_session": "活跃会话",
|
||||
"usage_analysis.current_usage": "当前使用情况",
|
||||
"usage_analysis.detailed_description": "全面了解您的 AI 使用模式和洞察",
|
||||
|
||||
@@ -302,6 +302,17 @@
|
||||
"token_usage.title": "令牌使用狀況",
|
||||
"token_usage.tokens_remaining": "剩餘令牌",
|
||||
"token_usage.tokens_used": "已使用 {{used}} / {{total}} 令牌",
|
||||
"token_usage_pill.billed": "計費",
|
||||
"token_usage_pill.byok": "BYOK",
|
||||
"token_usage_pill.credits": "額度",
|
||||
"token_usage_pill.credits_usage": "AI 額度使用",
|
||||
"token_usage_pill.duration": "持續時間",
|
||||
"token_usage_pill.model_info": "模型資訊",
|
||||
"token_usage_pill.multiplier": "倍數",
|
||||
"token_usage_pill.provider_info": "提供商資訊",
|
||||
"token_usage_pill.system": "系統",
|
||||
"token_usage_pill.total": "總計",
|
||||
"token_usage_pill.unknown": "未知",
|
||||
"usage_analysis.active_session": "活躍工作階段",
|
||||
"usage_analysis.current_usage": "目前使用狀況",
|
||||
"usage_analysis.detailed_description": "全面瞭解您的 AI 使用模式和洞察",
|
||||
|
||||
+18
-5
@@ -20,13 +20,13 @@
|
||||
"achievement.product_hunt_vote_description": "You supported Folo on Product Hunt",
|
||||
"activation.activate": "Activate",
|
||||
"activation.description": "During the public testing phase, you need an invitation code to use this feature.",
|
||||
"activation.plan.description": "You are currently using the free plan. Upgrade the plan to unlock more features.",
|
||||
"activation.plan.title": "Upgrade Plan",
|
||||
"activation.plan.upgrade": "Upgrade",
|
||||
"activation.plan.description": "You are currently using the free plan. Start free trial to unlock more features.",
|
||||
"activation.plan.title": "Upgrade Plan (Free Trial)",
|
||||
"activation.plan.upgrade": "Free Trial",
|
||||
"activation.title": "Invitation Code",
|
||||
"ai.summary_not_available": "Summary not available",
|
||||
"ai.summary_upgrade_required_description": "Unlock unlimited AI summaries, translations, and more intelligent features with Pro plan.",
|
||||
"ai.summary_upgrade_required_title": "Upgrade plan to continue using AI summary",
|
||||
"ai.summary_upgrade_required_title": "Start free trial to continue using AI summary",
|
||||
"ai.summary_upgrade_view_plans": "View Plans",
|
||||
"app.copy_logo_svg": "Copy Logo SVG",
|
||||
"app.copy_logo_text_svg": "Copy Logo Text SVG",
|
||||
@@ -174,8 +174,21 @@
|
||||
"entry_content.readability_notice": "This content is provided by Readability. If you find typographical anomalies, please go to the source site to view the original content.",
|
||||
"entry_content.render_error": "Render error:",
|
||||
"entry_content.report_issue": "Report issue",
|
||||
"entry_content.selection_toolbar.ask_ai": "Ask AI",
|
||||
"entry_content.selection_toolbar.copied": "Copied",
|
||||
"entry_content.selection_toolbar.copy": "Copy",
|
||||
"entry_content.selection_toolbar.copy_image": "Copy Image",
|
||||
"entry_content.selection_toolbar.copying": "Copying...",
|
||||
"entry_content.selection_toolbar.generating": "Generating...",
|
||||
"entry_content.selection_toolbar.poster_copied": "Poster copied to clipboard",
|
||||
"entry_content.selection_toolbar.poster_copy_failed": "Failed to copy poster",
|
||||
"entry_content.selection_toolbar.share": "Share",
|
||||
"entry_content.selection_toolbar.share_poster": "Share Poster",
|
||||
"entry_content.web_app_notice": "Maybe web app doesn't support this content type. But you can download the desktop app.",
|
||||
"entry_list.zero_unread": "Zero Unread",
|
||||
"entry_list_header.ai_timeline": "AI timeline",
|
||||
"entry_list_header.ai_timeline_loading": "Reordering timeline with AI...",
|
||||
"entry_list_header.ai_timeline_prompt_required": "Set your AI timeline sorting prompt first",
|
||||
"entry_list_header.grid": "Grid",
|
||||
"entry_list_header.image_only": "Image Only",
|
||||
"entry_list_header.items": "items",
|
||||
@@ -458,7 +471,7 @@
|
||||
"signin.continue_with": "Continue with {{provider}}",
|
||||
"signin.sign_in_to": "Sign in to",
|
||||
"signin.sign_up_to": "Sign up to",
|
||||
"subscription_limit_warning": "Subscription limit reached: <br /><b>{{feedCount}}/{{feedLimit}} feeds</b>, <br /><b>{{rsshubCount}}/{{rsshubLimit}} RSSHub</b>. <br /> Please upgrade plan or clean up unused feeds.",
|
||||
"subscription_limit_warning": "Subscription limit reached: <br /><b>{{feedCount}}/{{feedLimit}} feeds</b>, <br /><b>{{rsshubCount}}/{{rsshubLimit}} RSSHub</b>. <br /> Please start free trial to unlock more quota or clean up unused feeds.",
|
||||
"sync_indicator.disabled": "Due to security reasons, sync is disabled.",
|
||||
"sync_indicator.offline": "Offline",
|
||||
"sync_indicator.synced": "Synced with server",
|
||||
|
||||
@@ -173,8 +173,21 @@
|
||||
"entry_content.readability_notice": "このコンテンツは Readability により提供されています。誤字などを発見した場合は、元のサイトでオリジナルのコンテンツをご覧ください。",
|
||||
"entry_content.render_error": "レンダリングエラー:",
|
||||
"entry_content.report_issue": "問題を報告",
|
||||
"entry_content.selection_toolbar.ask_ai": "AI に質問",
|
||||
"entry_content.selection_toolbar.copied": "コピーしました",
|
||||
"entry_content.selection_toolbar.copy": "コピー",
|
||||
"entry_content.selection_toolbar.copy_image": "画像をコピー",
|
||||
"entry_content.selection_toolbar.copying": "コピー中...",
|
||||
"entry_content.selection_toolbar.generating": "生成中...",
|
||||
"entry_content.selection_toolbar.poster_copied": "ポスターをクリップボードにコピーしました",
|
||||
"entry_content.selection_toolbar.poster_copy_failed": "ポスターのコピーに失敗しました",
|
||||
"entry_content.selection_toolbar.share": "共有",
|
||||
"entry_content.selection_toolbar.share_poster": "ポスターを共有",
|
||||
"entry_content.web_app_notice": "このコンテンツタイプはウェブアプリではサポートされていないかもしれません。デスクトップアプリをダウンロードしてください。",
|
||||
"entry_list.zero_unread": "未読ゼロ",
|
||||
"entry_list_header.ai_timeline": "AIタイムライン",
|
||||
"entry_list_header.ai_timeline_loading": "AI でタイムラインを並び替えています…",
|
||||
"entry_list_header.ai_timeline_prompt_required": "AIタイムラインの並び替えプロンプトを先に設定してください",
|
||||
"entry_list_header.grid": "グリッド",
|
||||
"entry_list_header.image_only": "イメージのみ",
|
||||
"entry_list_header.items": "項目",
|
||||
|
||||
+18
-5
@@ -20,13 +20,13 @@
|
||||
"achievement.product_hunt_vote_description": "在 Product Hunt 上给 Folo 投票",
|
||||
"activation.activate": "激活",
|
||||
"activation.description": "在公测阶段,预览版用户使用此功能会受限。",
|
||||
"activation.plan.description": "您当前正在使用免费版本。升级以解锁更多功能。",
|
||||
"activation.plan.title": "升级计划",
|
||||
"activation.plan.upgrade": "升级",
|
||||
"activation.plan.description": "您当前正在使用免费版本。开启免费试用以解锁更多功能。",
|
||||
"activation.plan.title": "升级套餐(免费试用)",
|
||||
"activation.plan.upgrade": "免费试用",
|
||||
"activation.title": "邀请码",
|
||||
"ai.summary_not_available": "摘要不可用",
|
||||
"ai.summary_upgrade_required_description": "升级到 Pro 计划,解锁无限 AI 摘要、翻译和更多智能功能。",
|
||||
"ai.summary_upgrade_required_title": "升级计划以继续使用 AI 摘要",
|
||||
"ai.summary_upgrade_required_title": "开启免费试用以继续使用 AI 摘要",
|
||||
"ai.summary_upgrade_view_plans": "查看计划",
|
||||
"app.copy_logo_svg": "复制 Logo SVG",
|
||||
"app.copy_logo_text_svg": "复制徽标 SVG 文本",
|
||||
@@ -173,8 +173,21 @@
|
||||
"entry_content.readability_notice": "此内容由 Readability 提供。如果你发现排版异常,请访问源站查看原始内容。",
|
||||
"entry_content.render_error": "渲染错误:",
|
||||
"entry_content.report_issue": "反馈问题",
|
||||
"entry_content.selection_toolbar.ask_ai": "询问 AI",
|
||||
"entry_content.selection_toolbar.copied": "已复制",
|
||||
"entry_content.selection_toolbar.copy": "复制",
|
||||
"entry_content.selection_toolbar.copy_image": "复制图片",
|
||||
"entry_content.selection_toolbar.copying": "复制中...",
|
||||
"entry_content.selection_toolbar.generating": "生成中...",
|
||||
"entry_content.selection_toolbar.poster_copied": "海报已复制到剪贴板",
|
||||
"entry_content.selection_toolbar.poster_copy_failed": "复制海报失败",
|
||||
"entry_content.selection_toolbar.share": "分享",
|
||||
"entry_content.selection_toolbar.share_poster": "分享海报",
|
||||
"entry_content.web_app_notice": "网页版不支持展示此类型,请下载客户端查看。",
|
||||
"entry_list.zero_unread": "全部已读",
|
||||
"entry_list_header.ai_timeline": "AI 时间线",
|
||||
"entry_list_header.ai_timeline_loading": "正在用 AI 重新排序时间线…",
|
||||
"entry_list_header.ai_timeline_prompt_required": "请先设置 AI 时间线排序提示",
|
||||
"entry_list_header.grid": "网格布局",
|
||||
"entry_list_header.image_only": "仅图片",
|
||||
"entry_list_header.items": "内容",
|
||||
@@ -457,7 +470,7 @@
|
||||
"signin.continue_with": "使用 {{provider}} 登录",
|
||||
"signin.sign_in_to": "登录",
|
||||
"signin.sign_up_to": "注册",
|
||||
"subscription_limit_warning": "订阅数量已达上限:<br /><b>{{feedCount}}/{{feedLimit}} 个订阅源</b>,<br /><b>{{rsshubCount}}/{{rsshubLimit}} 个 RSSHub</b>。<br />请升级套餐或清理未使用的订阅源。",
|
||||
"subscription_limit_warning": "订阅数量已达上限:<br /><b>{{feedCount}}/{{feedLimit}} 个订阅源</b>,<br /><b>{{rsshubCount}}/{{rsshubLimit}} 个 RSSHub</b>。<br />请开启免费试用以解锁更多订阅额度,或清理未使用的订阅源。",
|
||||
"sync_indicator.disabled": "出于安全原因,已禁用同步",
|
||||
"sync_indicator.offline": "离线",
|
||||
"sync_indicator.synced": "已同步至云端",
|
||||
|
||||
@@ -171,8 +171,21 @@
|
||||
"entry_content.readability_notice": "此內容由'可讀模式'提供。如果您發現排版異常,請前往網站查看原始內容。",
|
||||
"entry_content.render_error": "渲染錯誤:",
|
||||
"entry_content.report_issue": "報告問題",
|
||||
"entry_content.selection_toolbar.ask_ai": "詢問 AI",
|
||||
"entry_content.selection_toolbar.copied": "已複製",
|
||||
"entry_content.selection_toolbar.copy": "複製",
|
||||
"entry_content.selection_toolbar.copy_image": "複製圖片",
|
||||
"entry_content.selection_toolbar.copying": "複製中...",
|
||||
"entry_content.selection_toolbar.generating": "生成中...",
|
||||
"entry_content.selection_toolbar.poster_copied": "海報已複製到剪貼簿",
|
||||
"entry_content.selection_toolbar.poster_copy_failed": "複製海報失敗",
|
||||
"entry_content.selection_toolbar.share": "分享",
|
||||
"entry_content.selection_toolbar.share_poster": "分享海報",
|
||||
"entry_content.web_app_notice": "Web 應用程式不支援此類型內容。您可以下載桌面應用程式。",
|
||||
"entry_list.zero_unread": "全部已讀",
|
||||
"entry_list_header.ai_timeline": "AI 時間線",
|
||||
"entry_list_header.ai_timeline_loading": "正在用 AI 重新排序時間線…",
|
||||
"entry_list_header.ai_timeline_prompt_required": "請先設定 AI 時間線排序提示",
|
||||
"entry_list_header.grid": "格線佈局",
|
||||
"entry_list_header.image_only": "僅圖片",
|
||||
"entry_list_header.items": "內容",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"ai.summary_not_available": "Summary not available",
|
||||
"ai.summary_upgrade_required_description": "Unlock unlimited AI summaries, translations, and more intelligent features with Pro plan.",
|
||||
"ai.summary_upgrade_required_title": "Upgrade plan to continue using AI summary",
|
||||
"ai.summary_upgrade_required_title": "Start free trial to continue using AI summary",
|
||||
"ai.summary_upgrade_view_plans": "View Plans",
|
||||
"entry.pull_up_to_next_entry": "Pull up to go to the next entry",
|
||||
"entry.release_to_next_entry": "Release to go to the next entry",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"ai.summary_not_available": "摘要不可用",
|
||||
"ai.summary_upgrade_required_description": "升级到 Pro 计划,解锁无限 AI 摘要、翻译和更多智能功能。",
|
||||
"ai.summary_upgrade_required_title": "升级计划以继续使用 AI 摘要",
|
||||
"ai.summary_upgrade_required_title": "开启免费试用以继续使用 AI 摘要",
|
||||
"ai.summary_upgrade_view_plans": "查看计划",
|
||||
"entry.pull_up_to_next_entry": "继续上拉查看下一条内容",
|
||||
"entry.release_to_next_entry": "松开查看下一条内容",
|
||||
|
||||
@@ -583,6 +583,7 @@
|
||||
"plan.features.MAX_SUBSCRIPTIONS": "Feed Subscriptions",
|
||||
"plan.features.PRIORITY_SUPPORT": "Priority Support",
|
||||
"plan.features.PRIVATE_SUBSCRIPTION": "Private Subscriptions",
|
||||
"plan.features.SECURE_IMAGE_PROXY": "Secure Image Proxy",
|
||||
"privacy.privacy": "Privacy",
|
||||
"privacy.terms": "Terms",
|
||||
"profile.avatar.cropInstructions": "Drag the crop area to adjust your avatar",
|
||||
|
||||
@@ -578,6 +578,7 @@
|
||||
"plan.features.MAX_SUBSCRIPTIONS": "フィードサブスクリプション",
|
||||
"plan.features.PRIORITY_SUPPORT": "優先サポート",
|
||||
"plan.features.PRIVATE_SUBSCRIPTION": "プライベートサブスクリプション",
|
||||
"plan.features.SECURE_IMAGE_PROXY": "セキュア画像プロキシ",
|
||||
"privacy.privacy": "プライバシー",
|
||||
"privacy.terms": "利用規約",
|
||||
"profile.avatar.cropInstructions": "ドラッグしてトリミングエリアを調整します",
|
||||
|
||||
@@ -577,6 +577,7 @@
|
||||
"plan.features.MAX_SUBSCRIPTIONS": "订阅源数量",
|
||||
"plan.features.PRIORITY_SUPPORT": "优先支持",
|
||||
"plan.features.PRIVATE_SUBSCRIPTION": "私有订阅",
|
||||
"plan.features.SECURE_IMAGE_PROXY": "安全图片代理",
|
||||
"privacy.privacy": "隐私政策",
|
||||
"privacy.terms": "服务条款",
|
||||
"profile.avatar.cropInstructions": "拖动裁剪区域以调整头像",
|
||||
|
||||
@@ -583,6 +583,7 @@
|
||||
"plan.features.MAX_SUBSCRIPTIONS": "訂閱源數量",
|
||||
"plan.features.PRIORITY_SUPPORT": "優先支援",
|
||||
"plan.features.PRIVATE_SUBSCRIPTION": "私有訂閱",
|
||||
"plan.features.SECURE_IMAGE_PROXY": "安全圖片代理",
|
||||
"privacy.privacy": "隱私政策",
|
||||
"privacy.terms": "服務條款",
|
||||
"profile.avatar.cropInstructions": "拖曳裁切區域以調整你的頭像",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { replaceImgUrlIfNeed } from "@follow/utils/img-proxy"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import * as AvatarPrimitive from "@radix-ui/react-avatar"
|
||||
import * as React from "react"
|
||||
@@ -28,7 +27,6 @@ export const AvatarImage = ({
|
||||
<AvatarPrimitive.Image
|
||||
ref={ref}
|
||||
className={cn("aspect-square size-full", className)}
|
||||
src={replaceImgUrlIfNeed({ url: props.src })}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -14,7 +14,7 @@ const styles = {
|
||||
} as React.CSSProperties,
|
||||
innerGlow: {
|
||||
background:
|
||||
"linear-gradient(to bottom right, hsl(var(--fo-a) / 0.05), transparent, hsl(var(--fo-a) / 0.05))",
|
||||
"linear-gradient(to bottom right, hsl(var(--fo-a) / 0.01), transparent, hsl(var(--fo-a) / 0.01))",
|
||||
} as React.CSSProperties,
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ export const tooltipStyles: {
|
||||
},
|
||||
innerGlow: {
|
||||
background:
|
||||
"linear-gradient(to bottom right, hsl(var(--fo-a) / 0.05), transparent, hsl(var(--fo-a) / 0.05))",
|
||||
"linear-gradient(to bottom right, hsl(var(--fo-a) / 0.01), transparent, hsl(var(--fo-a) / 0.01))",
|
||||
},
|
||||
arrow: {
|
||||
fill: "hsl(var(--fo-a) / 0.2)",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `entries` ADD `tags` text;--> statement-breakpoint
|
||||
@@ -0,0 +1,954 @@
|
||||
{
|
||||
"version": "6",
|
||||
"dialect": "sqlite",
|
||||
"id": "31afa146-88d1-49ab-a139-0d34d54f8526",
|
||||
"prevId": "1ba7c166-20b5-473e-aea4-5fa6e99dff23",
|
||||
"tables": {
|
||||
"ai_chat_messages": {
|
||||
"name": "ai_chat_messages",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"chat_id": {
|
||||
"name": "chat_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"role": {
|
||||
"name": "role",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false,
|
||||
"default": "(unixepoch() * 1000)"
|
||||
},
|
||||
"metadata": {
|
||||
"name": "metadata",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"status": {
|
||||
"name": "status",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false,
|
||||
"default": "'completed'"
|
||||
},
|
||||
"finished_at": {
|
||||
"name": "finished_at",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"message_parts": {
|
||||
"name": "message_parts",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"idx_ai_chat_messages_chat_id_created_at": {
|
||||
"name": "idx_ai_chat_messages_chat_id_created_at",
|
||||
"columns": ["chat_id", "created_at"],
|
||||
"isUnique": false
|
||||
},
|
||||
"idx_ai_chat_messages_status": {
|
||||
"name": "idx_ai_chat_messages_status",
|
||||
"columns": ["status"],
|
||||
"isUnique": false
|
||||
},
|
||||
"idx_ai_chat_messages_chat_id_role": {
|
||||
"name": "idx_ai_chat_messages_chat_id_role",
|
||||
"columns": ["chat_id", "role"],
|
||||
"isUnique": false
|
||||
}
|
||||
},
|
||||
"foreignKeys": {
|
||||
"ai_chat_messages_chat_id_ai_chat_sessions_id_fk": {
|
||||
"name": "ai_chat_messages_chat_id_ai_chat_sessions_id_fk",
|
||||
"tableFrom": "ai_chat_messages",
|
||||
"tableTo": "ai_chat_sessions",
|
||||
"columnsFrom": ["chat_id"],
|
||||
"columnsTo": ["id"],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {}
|
||||
},
|
||||
"ai_chat_sessions": {
|
||||
"name": "ai_chat_sessions",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"title": {
|
||||
"name": "title",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false,
|
||||
"default": "(unixepoch() * 1000)"
|
||||
},
|
||||
"updated_at": {
|
||||
"name": "updated_at",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false,
|
||||
"default": "(unixepoch() * 1000)"
|
||||
},
|
||||
"is_local": {
|
||||
"name": "is_local",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false,
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"idx_ai_chat_sessions_updated_at": {
|
||||
"name": "idx_ai_chat_sessions_updated_at",
|
||||
"columns": ["updated_at"],
|
||||
"isUnique": false
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {}
|
||||
},
|
||||
"collections": {
|
||||
"name": "collections",
|
||||
"columns": {
|
||||
"feed_id": {
|
||||
"name": "feed_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"entry_id": {
|
||||
"name": "entry_id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"view": {
|
||||
"name": "view",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {}
|
||||
},
|
||||
"entries": {
|
||||
"name": "entries",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"title": {
|
||||
"name": "title",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"url": {
|
||||
"name": "url",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"content": {
|
||||
"name": "content",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"source_content": {
|
||||
"name": "source_content",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"readability_updated_at": {
|
||||
"name": "readability_updated_at",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"description": {
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"guid": {
|
||||
"name": "guid",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"author": {
|
||||
"name": "author",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"author_url": {
|
||||
"name": "author_url",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"author_avatar": {
|
||||
"name": "author_avatar",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"inserted_at": {
|
||||
"name": "inserted_at",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"published_at": {
|
||||
"name": "published_at",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"media": {
|
||||
"name": "media",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"categories": {
|
||||
"name": "categories",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"attachments": {
|
||||
"name": "attachments",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"extra": {
|
||||
"name": "extra",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"language": {
|
||||
"name": "language",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"feed_id": {
|
||||
"name": "feed_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"inbox_handle": {
|
||||
"name": "inbox_handle",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"read": {
|
||||
"name": "read",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"sources": {
|
||||
"name": "sources",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"settings": {
|
||||
"name": "settings",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"tags": {
|
||||
"name": "tags",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {}
|
||||
},
|
||||
"feeds": {
|
||||
"name": "feeds",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"title": {
|
||||
"name": "title",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"url": {
|
||||
"name": "url",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"description": {
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"image": {
|
||||
"name": "image",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"error_at": {
|
||||
"name": "error_at",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"site_url": {
|
||||
"name": "site_url",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"owner_user_id": {
|
||||
"name": "owner_user_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"error_message": {
|
||||
"name": "error_message",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"subscription_count": {
|
||||
"name": "subscription_count",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"updates_per_week": {
|
||||
"name": "updates_per_week",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"latest_entry_published_at": {
|
||||
"name": "latest_entry_published_at",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"tip_users": {
|
||||
"name": "tip_users",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"published_at": {
|
||||
"name": "published_at",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {}
|
||||
},
|
||||
"images": {
|
||||
"name": "images",
|
||||
"columns": {
|
||||
"url": {
|
||||
"name": "url",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"colors": {
|
||||
"name": "colors",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false,
|
||||
"default": "(unixepoch() * 1000)"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {}
|
||||
},
|
||||
"inboxes": {
|
||||
"name": "inboxes",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"title": {
|
||||
"name": "title",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"secret": {
|
||||
"name": "secret",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {}
|
||||
},
|
||||
"lists": {
|
||||
"name": "lists",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"title": {
|
||||
"name": "title",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"feed_ids": {
|
||||
"name": "feed_ids",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"description": {
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"view": {
|
||||
"name": "view",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"image": {
|
||||
"name": "image",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"fee": {
|
||||
"name": "fee",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"owner_user_id": {
|
||||
"name": "owner_user_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"subscription_count": {
|
||||
"name": "subscription_count",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"purchase_amount": {
|
||||
"name": "purchase_amount",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {}
|
||||
},
|
||||
"subscriptions": {
|
||||
"name": "subscriptions",
|
||||
"columns": {
|
||||
"feed_id": {
|
||||
"name": "feed_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"list_id": {
|
||||
"name": "list_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"inbox_id": {
|
||||
"name": "inbox_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"view": {
|
||||
"name": "view",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"is_private": {
|
||||
"name": "is_private",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"hide_from_timeline": {
|
||||
"name": "hide_from_timeline",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"title": {
|
||||
"name": "title",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"category": {
|
||||
"name": "category",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"type": {
|
||||
"name": "type",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {}
|
||||
},
|
||||
"summaries": {
|
||||
"name": "summaries",
|
||||
"columns": {
|
||||
"entry_id": {
|
||||
"name": "entry_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"summary": {
|
||||
"name": "summary",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"readability_summary": {
|
||||
"name": "readability_summary",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"language": {
|
||||
"name": "language",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"unq": {
|
||||
"name": "unq",
|
||||
"columns": ["entry_id", "language"],
|
||||
"isUnique": true
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {}
|
||||
},
|
||||
"translations": {
|
||||
"name": "translations",
|
||||
"columns": {
|
||||
"entry_id": {
|
||||
"name": "entry_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"language": {
|
||||
"name": "language",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"title": {
|
||||
"name": "title",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"description": {
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"content": {
|
||||
"name": "content",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"readability_content": {
|
||||
"name": "readability_content",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"translation-unique-index": {
|
||||
"name": "translation-unique-index",
|
||||
"columns": ["entry_id", "language"],
|
||||
"isUnique": true
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {}
|
||||
},
|
||||
"unread": {
|
||||
"name": "unread",
|
||||
"columns": {
|
||||
"subscription_id": {
|
||||
"name": "subscription_id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"count": {
|
||||
"name": "count",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {}
|
||||
},
|
||||
"users": {
|
||||
"name": "users",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"email": {
|
||||
"name": "email",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"handle": {
|
||||
"name": "handle",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"image": {
|
||||
"name": "image",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"is_me": {
|
||||
"name": "is_me",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"email_verified": {
|
||||
"name": "email_verified",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"bio": {
|
||||
"name": "bio",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"website": {
|
||||
"name": "website",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"social_links": {
|
||||
"name": "social_links",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {}
|
||||
}
|
||||
},
|
||||
"views": {},
|
||||
"enums": {},
|
||||
"_meta": {
|
||||
"schemas": {},
|
||||
"tables": {},
|
||||
"columns": {}
|
||||
},
|
||||
"internal": {
|
||||
"indexes": {}
|
||||
}
|
||||
}
|
||||
@@ -253,6 +253,13 @@
|
||||
"when": 1761930812297,
|
||||
"tag": "0035_last_valeria_richards",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 36,
|
||||
"version": "6",
|
||||
"when": 1761930812300,
|
||||
"tag": "0036_entry_tag_summary",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import m0032 from "./0032_orange_prima.sql"
|
||||
import m0033 from "./0033_shiny_sebastian_shaw.sql"
|
||||
import m0034 from "./0034_curly_darkstar.sql"
|
||||
import m0035 from "./0035_last_valeria_richards.sql"
|
||||
import m0036 from "./0036_entry_tag_summary.sql"
|
||||
import journal from "./meta/_journal.json"
|
||||
|
||||
export default {
|
||||
@@ -77,5 +78,6 @@ export default {
|
||||
m0033,
|
||||
m0034,
|
||||
m0035,
|
||||
m0036,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -4,7 +4,13 @@ import type { EntrySettings } from "@follow-app/client-sdk"
|
||||
import { sql } from "drizzle-orm"
|
||||
import { index, integer, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core"
|
||||
|
||||
import type { AttachmentsModel, ExtraModel, ImageColorsResult, MediaModel } from "./types"
|
||||
import type {
|
||||
AttachmentsModel,
|
||||
EntryTagSummary,
|
||||
ExtraModel,
|
||||
ImageColorsResult,
|
||||
MediaModel,
|
||||
} from "./types"
|
||||
|
||||
export const feedsTable = sqliteTable("feeds", {
|
||||
id: text("id").primaryKey(),
|
||||
@@ -101,6 +107,7 @@ export const entriesTable = sqliteTable("entries", {
|
||||
attachments: text("attachments", { mode: "json" }).$type<AttachmentsModel[]>(),
|
||||
extra: text("extra", { mode: "json" }).$type<ExtraModel>(),
|
||||
language: text("language"),
|
||||
tags: text("tags", { mode: "json" }).$type<EntryTagSummary>(),
|
||||
|
||||
feedId: text("feed_id"),
|
||||
|
||||
|
||||
@@ -60,6 +60,11 @@ export type ExtraModel = {
|
||||
title_keyword?: string
|
||||
}
|
||||
|
||||
export type EntryTagSummary = {
|
||||
schemaOrgCategory: string | null
|
||||
mediaTopics: string[]
|
||||
}
|
||||
|
||||
// export { ImageColorsResult } from "react-native-image-colors"
|
||||
|
||||
interface AndroidImageColors {
|
||||
|
||||
@@ -161,6 +161,7 @@ export const defaultIntegrationSettings: IntegrationSettings = {
|
||||
|
||||
export const defaultAISettings: AISettings = {
|
||||
personalizePrompt: "",
|
||||
aiTimelinePrompt: "",
|
||||
shortcuts: [],
|
||||
|
||||
// MCP Services
|
||||
|
||||
@@ -216,6 +216,7 @@ export interface MCPService {
|
||||
|
||||
export interface AISettings {
|
||||
personalizePrompt: string
|
||||
aiTimelinePrompt: string
|
||||
shortcuts: AIShortcut[]
|
||||
|
||||
// MCP Services (stored locally, actual connections managed via server API)
|
||||
|
||||
@@ -63,6 +63,7 @@ export const useEntriesQuery = (
|
||||
isCollection,
|
||||
unreadOnly,
|
||||
hidePrivateSubscriptionsInTimeline,
|
||||
aiSort,
|
||||
} = props || {}
|
||||
|
||||
const fetchUnread = unreadOnly
|
||||
@@ -82,6 +83,7 @@ export const useEntriesQuery = (
|
||||
isCollection,
|
||||
unreadOnly,
|
||||
hidePrivateSubscriptionsInTimeline,
|
||||
aiSort,
|
||||
],
|
||||
[
|
||||
feedId,
|
||||
@@ -93,6 +95,7 @@ export const useEntriesQuery = (
|
||||
isCollection,
|
||||
unreadOnly,
|
||||
hidePrivateSubscriptionsInTimeline,
|
||||
aiSort,
|
||||
],
|
||||
)
|
||||
|
||||
@@ -101,12 +104,13 @@ export const useEntriesQuery = (
|
||||
queryFn: ({ pageParam }) =>
|
||||
entrySyncServices.fetchEntries({
|
||||
...props,
|
||||
limit: aiSort ? 100 : limit,
|
||||
pageParam,
|
||||
read: unreadOnly ? false : undefined,
|
||||
excludePrivate: hidePrivateSubscriptionsInTimeline,
|
||||
}),
|
||||
|
||||
getNextPageParam: (lastPage) => lastPage.data?.at(-1)?.entries.publishedAt,
|
||||
getNextPageParam: (lastPage) => (aiSort ? null : lastPage.data?.at(-1)?.entries.publishedAt),
|
||||
initialPageParam: undefined as undefined | string,
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnReconnect: false,
|
||||
@@ -215,6 +219,37 @@ export const useEntryIdsByListId = (listId: string | undefined) => {
|
||||
return useEntryStore(useCallback((state) => getEntryIdsByListIdSelector(state)(listId), [listId]))
|
||||
}
|
||||
|
||||
export const useEntryTagsQuery = ({
|
||||
feedId,
|
||||
tag,
|
||||
match = "any",
|
||||
withContent,
|
||||
}: {
|
||||
feedId?: string | null
|
||||
tag?: { kind: "schemaOrgCategory" | "mediaTopic"; value: string }
|
||||
match?: "any" | "all"
|
||||
withContent?: boolean
|
||||
}) => {
|
||||
const schemaOrgCategories = tag?.kind === "schemaOrgCategory" ? [tag.value] : undefined
|
||||
const mediaTopics = tag?.kind === "mediaTopic" ? [tag.value] : undefined
|
||||
|
||||
return useQuery({
|
||||
queryKey: ["entry-tags", feedId, tag?.kind, tag?.value, match, withContent],
|
||||
enabled: !!feedId && !!tag?.value,
|
||||
queryFn: () =>
|
||||
entrySyncServices.fetchEntriesByTags({
|
||||
feedId: feedId ?? undefined,
|
||||
match,
|
||||
tags: {
|
||||
schemaOrgCategories,
|
||||
mediaTopics,
|
||||
},
|
||||
withContent,
|
||||
}),
|
||||
select: (res) => res.data?.map((entry) => entry.entries.id) ?? [],
|
||||
})
|
||||
}
|
||||
|
||||
export const useEntryIsInbox = (entryId: string) => {
|
||||
return useEntryStore(useCallback((state) => getEntryIsInboxSelector(state)(entryId), [entryId]))
|
||||
}
|
||||
|
||||
@@ -318,6 +318,26 @@ class EntryActions implements Hydratable, Resetable {
|
||||
await tx.run()
|
||||
}
|
||||
|
||||
updateEntryTagsInSession({ entryId, tags }: { entryId: EntryId; tags: EntryModel["tags"] }) {
|
||||
immerSet((draft) => {
|
||||
const entry = draft.data[entryId]
|
||||
if (!entry) return
|
||||
entry.tags = tags ?? null
|
||||
})
|
||||
}
|
||||
|
||||
async updateEntryTags({ entryId, tags }: { entryId: EntryId; tags: EntryModel["tags"] }) {
|
||||
const tx = createTransaction()
|
||||
const nextTags = tags ?? null
|
||||
tx.store(() => {
|
||||
this.updateEntryTagsInSession({ entryId, tags: nextTags })
|
||||
})
|
||||
|
||||
tx.persist(() => EntryService.patch({ id: entryId, tags: nextTags }))
|
||||
|
||||
await tx.run()
|
||||
}
|
||||
|
||||
markEntryReadStatusInSession({
|
||||
entryIds,
|
||||
ids,
|
||||
@@ -474,6 +494,7 @@ class EntrySyncServices {
|
||||
isCollection,
|
||||
feedIdList,
|
||||
excludePrivate,
|
||||
aiSort,
|
||||
} = props
|
||||
const params = getEntriesParams({
|
||||
feedId,
|
||||
@@ -490,16 +511,25 @@ class EntrySyncServices {
|
||||
limit,
|
||||
isCollection,
|
||||
inboxId: params.inboxId,
|
||||
...(aiSort && { aiSort }),
|
||||
...params,
|
||||
})
|
||||
: await api().entries.list({
|
||||
publishedAfter: pageParam,
|
||||
read,
|
||||
limit,
|
||||
isCollection,
|
||||
excludePrivate,
|
||||
...params,
|
||||
})
|
||||
: await api().entries.list(
|
||||
{
|
||||
publishedAfter: pageParam,
|
||||
read,
|
||||
limit,
|
||||
isCollection,
|
||||
excludePrivate,
|
||||
...(aiSort && { aiSort }),
|
||||
...params,
|
||||
},
|
||||
aiSort
|
||||
? {
|
||||
timeout: 3 * 60 * 1000,
|
||||
}
|
||||
: undefined,
|
||||
)
|
||||
|
||||
// Mark feed unread dirty, so re-fetch the unread data when view feed unread entires in the next time
|
||||
if (read === false) {
|
||||
@@ -524,6 +554,9 @@ class EntrySyncServices {
|
||||
entry.content = entryInDB.content
|
||||
entry.readabilityContent = entryInDB.readabilityContent
|
||||
entry.readabilityUpdatedAt = entryInDB.readabilityUpdatedAt
|
||||
if (!entry.tags && entryInDB.tags) {
|
||||
entry.tags = entryInDB.tags
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,6 +577,56 @@ class EntrySyncServices {
|
||||
return res
|
||||
}
|
||||
|
||||
async fetchEntriesByTags({
|
||||
feedId,
|
||||
tags,
|
||||
match = "any",
|
||||
limit = 30,
|
||||
cursor,
|
||||
withContent,
|
||||
}: {
|
||||
feedId?: string
|
||||
tags: {
|
||||
schemaOrgCategories?: string[]
|
||||
mediaTopics?: string[]
|
||||
}
|
||||
match?: "any" | "all"
|
||||
limit?: number
|
||||
cursor?: string
|
||||
withContent?: boolean
|
||||
}) {
|
||||
const res = await api().entries.tagsQuery({
|
||||
feedId,
|
||||
tags,
|
||||
match,
|
||||
limit,
|
||||
cursor,
|
||||
withContent,
|
||||
})
|
||||
|
||||
const entries = apiMorph.toEntryList(res.data)
|
||||
const entriesInDB = await EntryService.getEntryMany(entries.map((e) => e.id))
|
||||
for (const entry of entries) {
|
||||
const entryInDB = entriesInDB.find((e) => e.id === entry.id)
|
||||
if (entryInDB) {
|
||||
entry.content = entryInDB.content
|
||||
entry.readabilityContent = entryInDB.readabilityContent
|
||||
entry.readabilityUpdatedAt = entryInDB.readabilityUpdatedAt
|
||||
if (!entry.tags && entryInDB.tags) {
|
||||
entry.tags = entryInDB.tags
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await entryActions.upsertMany(entries)
|
||||
|
||||
const dataFeeds = res.data?.map((e) => e.feeds).filter((f) => f.type === "feed")
|
||||
const feeds = dataFeeds?.map((f) => apiMorph.toFeed(f)) ?? []
|
||||
feedActions.upsertMany(feeds)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
async fetchEntryDetail(entryId: EntryId | undefined, isInbox?: boolean) {
|
||||
if (!isBizId(entryId)) return null
|
||||
|
||||
@@ -568,6 +651,15 @@ class EntrySyncServices {
|
||||
readabilityContent: entry.readabilityContent,
|
||||
})
|
||||
}
|
||||
|
||||
const apiTags = entry?.tags ?? null
|
||||
const storedTags = currentEntry?.tags ?? null
|
||||
if (JSON.stringify(storedTags) !== JSON.stringify(apiTags)) {
|
||||
await entryActions.updateEntryTags({
|
||||
entryId,
|
||||
tags: apiTags,
|
||||
})
|
||||
}
|
||||
}
|
||||
return entry
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ export type FetchEntriesProps = {
|
||||
pageParam?: string
|
||||
isCollection?: boolean
|
||||
excludePrivate?: boolean
|
||||
aiSort?: boolean
|
||||
}
|
||||
|
||||
export type FetchEntriesPropsSettings = {
|
||||
|
||||
@@ -49,6 +49,7 @@ class APIMorph {
|
||||
toEntry(data?: InboxEntryGetResponse["data"] | EntryGetByIdResponse["data"]): EntryModel | null {
|
||||
if (!data) return null
|
||||
|
||||
const resolvedTags = "tags" in data.entries ? data.entries.tags : null
|
||||
return {
|
||||
id: data.entries.id,
|
||||
title: data.entries.title,
|
||||
@@ -65,6 +66,7 @@ class APIMorph {
|
||||
media: data.entries.media ?? null,
|
||||
categories: data.entries.categories ?? null,
|
||||
attachments: data.entries.attachments ?? null,
|
||||
tags: resolvedTags,
|
||||
extra: data.entries.extra
|
||||
? {
|
||||
links: data.entries.extra.links ?? undefined,
|
||||
@@ -195,6 +197,7 @@ class APIMorph {
|
||||
toEntryList(data?: InboxListEntry[] | EntryWithFeed[]): EntryModel[] {
|
||||
const entries: EntryModel[] = []
|
||||
for (const item of data ?? []) {
|
||||
const resolvedTags = "tags" in item.entries ? item.entries.tags : null
|
||||
entries.push({
|
||||
id: item.entries.id,
|
||||
title: item.entries.title,
|
||||
@@ -211,6 +214,7 @@ class APIMorph {
|
||||
media: item.entries.media ?? null,
|
||||
categories: item.entries.categories ?? null,
|
||||
attachments: item.entries.attachments ?? null,
|
||||
tags: resolvedTags,
|
||||
extra: item.entries.extra
|
||||
? {
|
||||
links: item.entries.extra.links ?? undefined,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user