release(desktop): Release v0.3.9 (#2988)

This commit is contained in:
DIYgod
2025-03-06 20:31:10 +08:00
committed by GitHub
221 changed files with 6969 additions and 3318 deletions
+1 -1
View File
@@ -42,4 +42,4 @@ jobs:
run: pnpm install
- name: Build web and SSR server
run: |
npm exec turbo run @follow/desktop#build:web @follow/ssr#build
npm exec turbo run Follow#build:web @follow/ssr#build
+7
View File
@@ -0,0 +1,7 @@
# What's new in v0.3.9
## New Features
## Improvements
## Bug Fixes
@@ -92,5 +92,6 @@ export const viteRenderBaseConfig = {
I18N_COMPLETENESS_MAP: JSON.stringify({ ...i18nCompleteness, en: 100 }),
CHANGELOG_CONTENT: JSON.stringify(changelogFile),
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
},
} satisfies UserConfig
+1 -1
View File
@@ -118,7 +118,7 @@
"entry_actions.failed_to_save_to_outline": "保存到 Outline 失败。",
"entry_actions.failed_to_save_to_readeck": "保存到 Readeck 失败。",
"entry_actions.failed_to_save_to_readwise": "保存到 Readwise 失败。",
"entry_actions.mark_as_read": "标记为已读",
"entry_actions.mark_as_read": "标记为已读/未读",
"entry_actions.mark_as_unread": "标记为未读",
"entry_actions.open_in_browser": "在{{which}}打开",
"entry_actions.recent_reader": "最近阅读者:",
+5 -1
View File
@@ -7,6 +7,7 @@
"1003": "Invalid invitation",
"1004": "No permission",
"1005": "Internal error",
"1006": "Email not verified",
"1100": "Trial user max feed subscription exceeded",
"1101": "Trial user max list subscription exceeded",
"1102": "Trial user max inbox subscription exceeded",
@@ -60,5 +61,8 @@
"13003": "RSSHub not found",
"13004": "RSSHub user limit exceeded",
"13005": "RSSHub purchase not found",
"13006": "RSSHub config invalid"
"13006": "RSSHub config invalid",
"14000": "Invalid file",
"14001": "File too large",
"14002": "Upload failed"
}
+9 -4
View File
@@ -1,7 +1,7 @@
{
"name": "@follow/desktop",
"name": "Follow",
"type": "module",
"version": "0.3.8",
"version": "0.3.9",
"private": true,
"description": "Follow everything in one place",
"author": "Follow Team",
@@ -18,6 +18,7 @@
"build:mas": "electron-vite build && electron-forge make --arch=universal --platform=mas",
"build:render": "vite build -c vite.config.electron-render.ts",
"build:web": "rm -rf out/web && cross-env WEB_BUILD=1 vite build",
"bump": "vv",
"dedupe:locales": "eslint --fix locales/**/*.json",
"depcheck": "npx depcheck --quiet",
"dev": "turbo run @follow/web#dev @follow/ssr#dev",
@@ -30,6 +31,10 @@
"start": "electron-vite preview",
"update:main-hash": "tsx plugins/vite/generate-main-hash.ts"
},
"dependencies": {
"react-google-recaptcha": "3.1.0",
"react-google-recaptcha-v3": "1.10.1"
},
"devDependencies": {
"@clack/prompts": "0.10.0",
"@electron-forge/cli": "7.7.0",
@@ -75,7 +80,7 @@
"utf-8-validate": "6.0.5"
},
"productName": "Follow",
"mainHash": "ad1913f95d3411e9bc07a90022c0f40d8f2e67e708eb704f64f1229ed31ac2d9",
"mainHash": "b12c4c0f19198ba7a50c0027bcacf4dbf2a42406b6753f3f18aeebf9627b2d43",
"bump": {
"before": [
"git pull --rebase",
@@ -91,7 +96,7 @@
],
"commit_message": "release(desktop): release v${NEW_VERSION}",
"tag": false,
"changelog": true,
"changelog": false,
"allowed_branches": [
"dev"
]
+43 -21
View File
@@ -1,36 +1,58 @@
import type { Plugin } from "vite"
type Platform = "electron" | "web" | "rn"
type Platform = "electron" | "web"
export function createPlatformSpecificImportPlugin(platform: Platform): Plugin {
return {
name: "platform-specific-import",
enforce: "pre",
async resolveId(source, importer) {
const resolvedPath = await this.resolve(source, importer, {
skipSelf: true,
})
if (!importer) {
return null
}
const allowExts = [".js", ".jsx", ".ts", ".tsx"]
const sharedExts = [".desktop.ts", ".desktop.tsx", ".desktop.js", ".desktop.jsx"]
if (
resolvedPath &&
!resolvedPath.id.includes("node_modules") &&
allowExts.some((ext) => importer?.endsWith(ext)) &&
allowExts.some((ext) => resolvedPath.id?.endsWith(ext))
) {
const lastDotIndex = resolvedPath.id.lastIndexOf(".")
if (!allowExts.some((ext) => importer.endsWith(ext))) return null
const paths = [
`${resolvedPath.id.slice(0, lastDotIndex)}.${platform}${resolvedPath.id.slice(lastDotIndex)}`,
`${resolvedPath.id.slice(0, lastDotIndex)}.desktop${resolvedPath.id.slice(lastDotIndex)}`,
]
if (importer.includes("node_modules")) return null
const [path, query] = source.split("?")
for (const path of paths) {
const resolvedPlatform = await this.resolve(path, importer, {
skipSelf: true,
})
if (resolvedPlatform) {
return resolvedPlatform.id
if (path.startsWith(".") || path.startsWith("/")) {
let priorities: string[] = []
switch (platform) {
case "electron": {
priorities = [
".electron.ts",
".electron.tsx",
".electron.js",
".electron.jsx",
...sharedExts,
...allowExts,
]
break
}
case "web": {
priorities = [".web.ts", ".web.tsx", ".web.js", ".web.jsx", ...sharedExts, ...allowExts]
break
}
// No default
}
for (const ext of priorities) {
const resolvedPath = await this.resolve(
`${path}${ext}${query ? `?${query}` : ""}`,
importer,
{
skipSelf: true,
},
)
if (resolvedPath) {
return resolvedPath.id
}
}
}
-3
View File
@@ -28,13 +28,10 @@
"@eneris/push-receiver": "4.3.0",
"@follow/shared": "workspace:*",
"@follow/utils": "workspace:*",
"@mozilla/readability": "0.5.0",
"@openpanel/web": "1.0.1",
"@sentry/electron": "5.11.0",
"builder-util-runtime": "9.2.10",
"chardet": "2.0.0",
"cookie-es": "1.2.2",
"dompurify": "3.2.4",
"electron-context-menu": "4.0.5",
"electron-log": "5.3.0",
"electron-squirrel-startup": "1.0.1",
+7
View File
@@ -50,3 +50,10 @@ if (process.contextIsolated) {
// @ts-ignore (define in dts)
window.platform = process.platform
}
// Options for react-google-recaptcha
// @ts-ignore (define in dts)
window.recaptchaOptions = {
useRecaptchaNet: true,
enterprise: true,
}
+9 -2
View File
@@ -1,8 +1,9 @@
import { electronApp, optimizer } from "@electron-toolkit/utils"
import { callWindowExpose } from "@follow/shared/bridge"
import { APP_PROTOCOL } from "@follow/shared/constants"
import { env } from "@follow/shared/env"
import { buildSafeHeaders } from "@follow/utils/headers"
import { env } from "@follow/shared/env.desktop"
import { createBuildSafeHeaders } from "@follow/utils/headers"
import { IMAGE_PROXY_URL } from "@follow/utils/img-proxy"
import { parse } from "cookie-es"
import { app, BrowserWindow, session } from "electron"
import squirrelStartup from "electron-squirrel-startup"
@@ -108,6 +109,12 @@ function bootstrap() {
registerUpdater()
registerAppTray()
const buildSafeHeaders = createBuildSafeHeaders(env.VITE_WEB_URL, [
env.VITE_OPENPANEL_API_URL || "",
IMAGE_PROXY_URL,
env.VITE_API_URL,
])
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
details.requestHeaders = buildSafeHeaders({
url: details.url,
+1 -1
View File
@@ -3,7 +3,7 @@ import path from "node:path"
import { getRendererHandlers, registerIpcMain } from "@egoist/tipc/main"
import { PushReceiver } from "@eneris/push-receiver"
import { APP_PROTOCOL } from "@follow/shared/constants"
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import type { MessagingData } from "@follow/shared/hono"
import { app, nativeTheme, Notification, shell } from "electron"
import contextMenu from "electron-context-menu"
+1 -1
View File
@@ -1,5 +1,5 @@
import type { AppType } from "@follow/shared"
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import PKG from "@pkg"
import { hc } from "hono/client"
import { ofetch } from "ofetch"
+1 -1
View File
@@ -1,4 +1,4 @@
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import { OpenPanel } from "@openpanel/web"
import { app } from "electron"
+1 -1
View File
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url"
import { getRendererHandlers } from "@egoist/tipc/main"
import { callWindowExpose } from "@follow/shared/bridge"
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import { app, BrowserWindow, clipboard, dialog, shell } from "electron"
import { BETTER_AUTH_COOKIE_NAME_SESSION_TOKEN } from "~/constants/app"
+1 -1
View File
@@ -2,13 +2,13 @@ import fs from "node:fs"
import path from "node:path"
import { callWindowExpose } from "@follow/shared/bridge"
import { readability } from "@follow/utils/readability"
import { app, BrowserWindow } from "electron"
import { MsEdgeTTS, OUTPUT_FORMAT } from "msedge-tts"
import type { ModelResult } from "vscode-languagedetection"
import { detectCodeStringLanguage } from "~/modules/language-detection"
import { readability } from "../lib/readability"
import { t } from "./_instance"
const tts = new MsEdgeTTS()
@@ -1,7 +1,6 @@
import { RootPortal } from "@follow/components/ui/portal/index.jsx"
import { useTypeScriptHappyCallback } from "@follow/hooks"
import { cn } from "@follow/utils/utils"
import clsx from "clsx"
import { clsx, cn } from "@follow/utils/utils"
import { typescriptHappyForwardRef } from "foxact/typescript-happy-forward-ref"
import type { HTMLMotionProps } from "framer-motion"
import { AnimatePresence } from "framer-motion"
@@ -1,31 +0,0 @@
import { AnimatePresence } from "framer-motion"
import { useAtomValue } from "jotai"
import { modalStackAtom } from "./atom"
import { useModalStack } from "./hooks"
import { ModalInternal } from "./modal"
import { useModalStackCalculationAndEffect } from "./modal-stack.shared"
export const ModalStack = () => {
const { present } = useModalStack()
window.presentModal = present
const stack = useAtomValue(modalStackAtom)
const { topModalIndex, overlayOptions } = useModalStackCalculationAndEffect()
return (
<AnimatePresence mode="popLayout">
{stack.map((item, index) => (
<ModalInternal
key={item.id}
item={item}
index={index}
isTop={index === topModalIndex}
isBottom={index === 0}
overlayOptions={overlayOptions}
/>
))}
</AnimatePresence>
)
}
@@ -1 +1,31 @@
export { ModalStack } from "./modal-stack.desktop"
import { AnimatePresence } from "framer-motion"
import { useAtomValue } from "jotai"
import { modalStackAtom } from "./atom"
import { useModalStack } from "./hooks"
import { ModalInternal } from "./modal"
import { useModalStackCalculationAndEffect } from "./modal-stack.shared"
export const ModalStack = () => {
const { present } = useModalStack()
window.presentModal = present
const stack = useAtomValue(modalStackAtom)
const { topModalIndex, overlayOptions } = useModalStackCalculationAndEffect()
return (
<AnimatePresence mode="popLayout">
{stack.map((item, index) => (
<ModalInternal
key={item.id}
item={item}
index={index}
isTop={index === topModalIndex}
isBottom={index === 0}
overlayOptions={overlayOptions}
/>
))}
</AnimatePresence>
)
}
@@ -1,6 +1,6 @@
import { withResponsiveSyncComponent } from "@follow/components/utils/selector.js"
import { ModalStack as Desktop } from "./modal-stack.desktop"
import { ModalStack as Desktop } from "./modal-stack.electron"
import { ModalStack as Mobile } from "./modal-stack.mobile"
export const ModalStack = withResponsiveSyncComponent(Desktop, Mobile)
@@ -0,0 +1,3 @@
import { env } from "@follow/shared/env.desktop"
export const WEB_URL = env.VITE_WEB_URL
@@ -1,14 +1,21 @@
import { useEffect } from "react"
import { useCallback, useEffect } from "react"
import { useGoogleReCaptcha } from "react-google-recaptcha-v3"
import { useClaimCheck, useClaimWalletDailyRewardMutation } from "~/queries/wallet"
export const useDailyTask = () => {
const { mutateAsync: claimDaily } = useClaimWalletDailyRewardMutation()
const check = useClaimCheck()
const { executeRecaptcha } = useGoogleReCaptcha()
const handleReCaptchaVerify = useCallback(async () => {
if (check.data?.data && executeRecaptcha) {
const token = await executeRecaptcha("useDailyTask")
claimDaily({ tokenV3: token })
}
}, [claimDaily, check.data?.data, executeRecaptcha])
useEffect(() => {
if (check.data?.data) {
claimDaily()
}
}, [claimDaily, check.data?.data])
handleReCaptchaVerify()
}, [handleReCaptchaVerify, check.data?.data])
}
@@ -1,8 +1,7 @@
import { Button } from "@follow/components/ui/button/index.js"
import type { FeedViewType } from "@follow/constants"
import { IN_ELECTRON } from "@follow/shared/constants"
import { env } from "@follow/shared/env"
import { UrlBuilder } from "@follow/utils/url-builder"
import { env } from "@follow/shared/env.desktop"
import { isBizId } from "@follow/utils/utils"
import { useMutation } from "@tanstack/react-query"
import { useMemo } from "react"
@@ -13,6 +12,7 @@ import type { FollowMenuItem, MenuItemInput } from "~/atoms/context-menu"
import { whoami } from "~/atoms/user"
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
import { apiClient } from "~/lib/api-fetch"
import { UrlBuilder } from "~/lib/url-builder"
import { useBoostModal } from "~/modules/boost/hooks"
import { useFeedClaimModal } from "~/modules/claim"
import { FeedForm } from "~/modules/discover/feed-form"
@@ -1,9 +1,9 @@
import { signOut } from "@follow/shared/auth"
import { clearStorage } from "@follow/utils/ns"
import { useCallback } from "react"
import { setWhoami } from "~/atoms/user"
import { QUERY_PERSIST_KEY } from "~/constants"
import { signOut } from "~/lib/auth"
import { tipcClient } from "~/lib/client"
import { clearLocalPersistStoreData } from "~/store/utils/clear"
@@ -1,4 +1,4 @@
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import type { TrackProperties } from "@openpanel/web"
import { getGeneralSettings } from "~/atoms/settings/general"
@@ -1,4 +1,4 @@
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import { OpenPanel } from "@openpanel/web"
export const op = new OpenPanel({
@@ -1,4 +1,4 @@
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import type { BrowserOptions } from "@sentry/react"
import { FetchError } from "ofetch"
@@ -1,4 +1,4 @@
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import { appSessionTraceId } from "@follow/utils/environment"
import { version } from "@pkg"
import { nanoid } from "nanoid"
@@ -1,4 +1,4 @@
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import type { AppType } from "@follow/shared/hono"
import PKG from "@pkg"
import { hc } from "hono/client"
@@ -1,10 +1,11 @@
import { env } from "@follow/shared/env"
import { IN_ELECTRON } from "@follow/shared"
import { env } from "@follow/shared/env.desktop"
import type { authPlugins } from "@follow/shared/hono"
import type { BetterAuthClientPlugin } from "better-auth/client"
import { inferAdditionalFields, twoFactorClient } from "better-auth/client/plugins"
import { createAuthClient } from "better-auth/react"
import { IN_ELECTRON, WEB_URL } from "./constants"
import { WEB_URL } from "~/constants/env"
type AuthPlugin = (typeof authPlugins)[number]
const serverPlugins = [
@@ -0,0 +1,5 @@
import { UrlBuilder as UrlBuilderClass } from "@follow/utils/url-builder"
import { WEB_URL } from "~/constants/env"
export const UrlBuilder = new UrlBuilderClass(WEB_URL)
@@ -2,7 +2,7 @@ import { Card, CardContent, CardHeader } from "@follow/components/ui/card/index.
import { Input } from "@follow/components/ui/input/index.js"
import { Switch } from "@follow/components/ui/switch/index.jsx"
import { Tooltip, TooltipContent, TooltipTrigger } from "@follow/components/ui/tooltip/index.js"
import clsx from "clsx"
import { clsx } from "@follow/utils/utils"
import { useTranslation } from "react-i18next"
import { actionActions, useActionByIndex } from "~/store/action"
@@ -1,6 +1,6 @@
import { ROUTE_ENTRY_PENDING } from "~/constants"
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
import { EntryContent } from "~/modules/entry-content"
import { EntryContent } from "~/modules/entry-content/index.mobile"
import { EntryColumnMobile } from "../entry-column/mobile"
@@ -12,5 +12,6 @@ export const EntryContentMobile = () => {
if (entryId === ROUTE_ENTRY_PENDING) {
return <EntryColumnMobile />
}
return <EntryContent entryId={entryId!} />
}
@@ -3,7 +3,7 @@ import { MotionButtonBase } from "@follow/components/ui/button/index.js"
import { DividerVertical } from "@follow/components/ui/divider/Divider.js"
import { views } from "@follow/constants"
import { stopPropagation } from "@follow/utils/dom"
import clsx from "clsx"
import { clsx } from "@follow/utils/utils"
import { m, useAnimationControls } from "framer-motion"
import { useCallback, useEffect, useRef, useState } from "react"
@@ -1,11 +1,11 @@
import { sendVerificationEmail } from "@follow/shared/auth"
import { WEB_URL } from "@follow/shared/constants"
import { cn } from "@follow/utils/utils"
import { lazy, Suspense, useEffect, useState } from "react"
import { toast } from "sonner"
import { useWhoami } from "~/atoms/user"
import { WEB_URL } from "~/constants/env"
import { useAuthQuery } from "~/hooks/common/useBizQuery"
import { sendVerificationEmail } from "~/lib/auth"
import { settings } from "~/queries/settings"
const LazyNewUserGuideModal = lazy(() =>
@@ -1,109 +0,0 @@
import { getReadonlyRoute } from "@follow/components/atoms/route.js"
import { MotionButtonBase } from "@follow/components/ui/button/index.js"
import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
import { Routes } from "@follow/constants"
import { springScrollTo } from "@follow/utils/scroller"
import { cn, getOS } from "@follow/utils/utils"
import { useEffect, useRef, useState } from "react"
import { useTranslation } from "react-i18next"
import { NavigationType, Outlet, useLocation, useNavigate, useNavigationType } from "react-router"
import { FABContainer, FABPortable } from "~/components/ui/fab"
import { isElectronBuild } from "~/constants"
import { useSubViewTitleValue } from "./hooks"
export function SubviewLayout() {
const navigate = useNavigate()
const prevLocation = useRef(getReadonlyRoute().location).current
const title = useSubViewTitleValue()
const [scrollRef, setRef] = useState(null as HTMLDivElement | null)
const [isTitleSticky, setIsTitleSticky] = useState(false)
const navigationType = useNavigationType()
const location = useLocation()
useEffect(() => {
// Scroll to top search bar when re-navigating to Discover page while already on it
if (
navigationType === NavigationType.Replace &&
location.pathname === Routes.Discover &&
scrollRef
) {
springScrollTo(0, scrollRef)
}
}, [location, navigationType, scrollRef])
useEffect(() => {
const $scroll = scrollRef
if (!$scroll) return
springScrollTo(0, $scroll)
const handler = () => {
setIsTitleSticky($scroll.scrollTop > 120)
}
$scroll.addEventListener("scroll", handler)
return () => {
$scroll.removeEventListener("scroll", handler)
}
}, [scrollRef])
const { t } = useTranslation()
// electron window has pt-[calc(var(--fo-window-padding-top)_-10px)]
const isElectronWindows = isElectronBuild && getOS() === "Windows"
return (
<div className="relative flex size-full">
<div
className={cn(
"absolute inset-x-0 top-0 z-10 p-4",
"grid grid-cols-[1fr_auto_1fr] items-center gap-4",
isTitleSticky && "group border-b bg-zinc-50/80 backdrop-blur-xl dark:bg-neutral-900/90",
isTitleSticky && isElectronWindows && "-top-5",
)}
>
<MotionButtonBase
onClick={() => {
navigate(prevLocation)
}}
className="no-drag-region hover:text-accent inline-flex items-center gap-1 duration-200"
>
<i className="i-mingcute-left-line" />
<span className="text-sm font-medium">{t("words.back", { ns: "common" })}</span>
</MotionButtonBase>
<div>
<div className="font-bold opacity-0 duration-200 group-[.group]:opacity-100">{title}</div>
</div>
<div />
</div>
<ScrollArea.ScrollArea
mask={false}
flex
ref={setRef}
rootClassName="w-full"
viewportClassName="pb-10 pt-28 [&>div]:items-center"
>
<Outlet />
</ScrollArea.ScrollArea>
<FABContainer>
<BackToTopFAB show={isTitleSticky} scrollRef={scrollRef} />
</FABContainer>
</div>
)
}
const BackToTopFAB = ({ show, scrollRef }: { show: boolean; scrollRef: any }) => {
return (
<FABPortable
onClick={() => {
springScrollTo(0, scrollRef)
}}
show={show}
>
<i className="i-mingcute-arow-to-up-line" />
</FABPortable>
)
}
@@ -1 +1,109 @@
export { SubviewLayout } from "./index.desktop"
import { getReadonlyRoute } from "@follow/components/atoms/route.js"
import { MotionButtonBase } from "@follow/components/ui/button/index.js"
import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
import { Routes } from "@follow/constants"
import { springScrollTo } from "@follow/utils/scroller"
import { cn, getOS } from "@follow/utils/utils"
import { useEffect, useRef, useState } from "react"
import { useTranslation } from "react-i18next"
import { NavigationType, Outlet, useLocation, useNavigate, useNavigationType } from "react-router"
import { FABContainer, FABPortable } from "~/components/ui/fab"
import { isElectronBuild } from "~/constants"
import { useSubViewTitleValue } from "./hooks"
export function SubviewLayout() {
const navigate = useNavigate()
const prevLocation = useRef(getReadonlyRoute().location).current
const title = useSubViewTitleValue()
const [scrollRef, setRef] = useState(null as HTMLDivElement | null)
const [isTitleSticky, setIsTitleSticky] = useState(false)
const navigationType = useNavigationType()
const location = useLocation()
useEffect(() => {
// Scroll to top search bar when re-navigating to Discover page while already on it
if (
navigationType === NavigationType.Replace &&
location.pathname === Routes.Discover &&
scrollRef
) {
springScrollTo(0, scrollRef)
}
}, [location, navigationType, scrollRef])
useEffect(() => {
const $scroll = scrollRef
if (!$scroll) return
springScrollTo(0, $scroll)
const handler = () => {
setIsTitleSticky($scroll.scrollTop > 120)
}
$scroll.addEventListener("scroll", handler)
return () => {
$scroll.removeEventListener("scroll", handler)
}
}, [scrollRef])
const { t } = useTranslation()
// electron window has pt-[calc(var(--fo-window-padding-top)_-10px)]
const isElectronWindows = isElectronBuild && getOS() === "Windows"
return (
<div className="relative flex size-full">
<div
className={cn(
"absolute inset-x-0 top-0 z-10 p-4",
"grid grid-cols-[1fr_auto_1fr] items-center gap-4",
isTitleSticky && "group border-b bg-zinc-50/80 backdrop-blur-xl dark:bg-neutral-900/90",
isTitleSticky && isElectronWindows && "-top-5",
)}
>
<MotionButtonBase
onClick={() => {
navigate(prevLocation)
}}
className="no-drag-region hover:text-accent inline-flex items-center gap-1 duration-200"
>
<i className="i-mingcute-left-line" />
<span className="text-sm font-medium">{t("words.back", { ns: "common" })}</span>
</MotionButtonBase>
<div>
<div className="font-bold opacity-0 duration-200 group-[.group]:opacity-100">{title}</div>
</div>
<div />
</div>
<ScrollArea.ScrollArea
mask={false}
flex
ref={setRef}
rootClassName="w-full"
viewportClassName="pb-10 pt-28 [&>div]:items-center"
>
<Outlet />
</ScrollArea.ScrollArea>
<FABContainer>
<BackToTopFAB show={isTitleSticky} scrollRef={scrollRef} />
</FABContainer>
</div>
)
}
const BackToTopFAB = ({ show, scrollRef }: { show: boolean; scrollRef: any }) => {
return (
<FABPortable
onClick={() => {
springScrollTo(0, scrollRef)
}}
show={show}
>
<i className="i-mingcute-arow-to-up-line" />
</FABPortable>
)
}
@@ -1,6 +1,6 @@
import { withResponsiveSyncComponent } from "@follow/components/utils/selector.js"
import { SubviewLayout as SubviewLayoutDesktop } from "./index.desktop"
import { SubviewLayout as SubviewLayoutDesktop } from "./index.electron"
import { SubviewLayout as SubviewLayoutMobile } from "./index.mobile"
export const SubviewLayout = withResponsiveSyncComponent(SubviewLayoutDesktop, SubviewLayoutMobile)
@@ -5,7 +5,7 @@ import {
TooltipPortal,
TooltipTrigger,
} from "@follow/components/ui/tooltip/index.jsx"
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import { useUserRole } from "~/atoms/user"
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
@@ -8,9 +8,7 @@ import {
FormMessage,
} from "@follow/components/ui/form/index.js"
import { Input } from "@follow/components/ui/input/Input.js"
import type { LoginRuntime } from "@follow/shared/auth"
import { loginHandler, signUp, twoFactor } from "@follow/shared/auth"
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import { zodResolver } from "@hookform/resolvers/zod"
import { useForm } from "react-hook-form"
import { useTranslation } from "react-i18next"
@@ -18,6 +16,8 @@ import { toast } from "sonner"
import { z } from "zod"
import { useCurrentModal, useModalStack } from "~/components/ui/modal/stacked/hooks"
import type { LoginRuntime } from "~/lib/auth"
import { loginHandler, signUp, twoFactor } from "~/lib/auth"
import { TOTPForm } from "../profile/two-factor"
@@ -8,13 +8,13 @@ import {
TooltipPortal,
TooltipTrigger,
} from "@follow/components/ui/tooltip/index.js"
import type { LoginRuntime } from "@follow/shared/auth"
import { loginHandler } from "@follow/shared/auth"
import clsx from "clsx"
import { clsx } from "@follow/utils/utils"
import { m } from "framer-motion"
import { useTranslation } from "react-i18next"
import { useCurrentModal } from "~/components/ui/modal/stacked/hooks"
import type { LoginRuntime } from "~/lib/auth"
import { loginHandler } from "~/lib/auth"
import { isInMAS } from "~/lib/utils"
import { useAuthProviders } from "~/queries/users"
@@ -1,5 +1,4 @@
import { IN_ELECTRON } from "@follow/shared/constants"
import { UrlBuilder } from "@follow/utils/url-builder"
import { useTranslation } from "react-i18next"
import { toast } from "sonner"
@@ -7,6 +6,7 @@ import { useModalStack } from "~/components/ui/modal/stacked/hooks"
import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry"
import { getRouteParams } from "~/hooks/biz/useRouteParams"
import { useDeleteSubscription } from "~/hooks/biz/useSubscriptionActions"
import { UrlBuilder } from "~/lib/url-builder"
import { ListForm } from "~/modules/discover/list-form"
import { useRegisterCommandEffect } from "../hooks/use-register-command"
@@ -12,7 +12,7 @@ import {
import { Input } from "@follow/components/ui/input/index.js"
import { FeedViewType } from "@follow/constants"
import type { InboxModel } from "@follow/models/types"
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import { cn } from "@follow/utils/utils"
import { zodResolver } from "@hookform/resolvers/zod"
import { useMutation } from "@tanstack/react-query"
@@ -1,67 +0,0 @@
import { LoadingCircle } from "@follow/components/ui/loading/index.jsx"
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@follow/components/ui/table/index.jsx"
import { memo } from "react"
import { useTranslation } from "react-i18next"
import { useInboxList } from "~/queries/inboxes"
import { useInboxById } from "~/store/inbox"
import { InboxActions, InboxEmail, InboxSecret } from "./inbox-table.shared"
export const InboxTable = () => {
const { t } = useTranslation()
const inboxes = useInboxList()
return (
<Table containerClassName="overflow-auto mb-8">
<TableHeader>
<TableRow>
<TableHead className="pl-0 pr-6">{t("discover.inbox.handle")}</TableHead>
<TableHead className="pl-0 pr-6">{t("discover.inbox.email")}</TableHead>
<TableHead className="pl-0 pr-6">{t("discover.inbox.title")}</TableHead>
<TableHead className="pl-0 pr-6">{t("discover.inbox.secret")}</TableHead>
<TableHead className="center px-0">{t("discover.inbox.actions")}</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{inboxes.isLoading ? (
<TableRow>
<TableCell size="sm" colSpan={5}>
<div className="center w-full">
<LoadingCircle size="large" />
</div>
</TableCell>
</TableRow>
) : (
inboxes.data?.map((inbox) => <Row id={inbox.id} key={inbox.id} />)
)}
</TableBody>
</Table>
)
}
const Row = memo(({ id }: { id: string }) => {
const inbox = useInboxById(id)
if (!inbox) return null
return (
<TableRow key={inbox.id}>
<TableCell size="sm">{inbox.id}</TableCell>
<TableCell size="sm">
<InboxEmail id={inbox.id} />
</TableCell>
<TableCell size="sm">{inbox.title}</TableCell>
<TableCell size="sm">
<InboxSecret secret={inbox.secret} />
</TableCell>
<TableCell size="sm" className="center">
<InboxActions id={inbox.id} />
</TableCell>
</TableRow>
)
})
@@ -1 +1,67 @@
export { InboxTable } from "./inbox-table.desktop"
import { LoadingCircle } from "@follow/components/ui/loading/index.jsx"
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@follow/components/ui/table/index.jsx"
import { memo } from "react"
import { useTranslation } from "react-i18next"
import { useInboxList } from "~/queries/inboxes"
import { useInboxById } from "~/store/inbox"
import { InboxActions, InboxEmail, InboxSecret } from "./inbox-table.shared"
export const InboxTable = () => {
const { t } = useTranslation()
const inboxes = useInboxList()
return (
<Table containerClassName="overflow-auto mb-8">
<TableHeader>
<TableRow>
<TableHead className="pl-0 pr-6">{t("discover.inbox.handle")}</TableHead>
<TableHead className="pl-0 pr-6">{t("discover.inbox.email")}</TableHead>
<TableHead className="pl-0 pr-6">{t("discover.inbox.title")}</TableHead>
<TableHead className="pl-0 pr-6">{t("discover.inbox.secret")}</TableHead>
<TableHead className="center px-0">{t("discover.inbox.actions")}</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{inboxes.isLoading ? (
<TableRow>
<TableCell size="sm" colSpan={5}>
<div className="center w-full">
<LoadingCircle size="large" />
</div>
</TableCell>
</TableRow>
) : (
inboxes.data?.map((inbox) => <Row id={inbox.id} key={inbox.id} />)
)}
</TableBody>
</Table>
)
}
const Row = memo(({ id }: { id: string }) => {
const inbox = useInboxById(id)
if (!inbox) return null
return (
<TableRow key={inbox.id}>
<TableCell size="sm">{inbox.id}</TableCell>
<TableCell size="sm">
<InboxEmail id={inbox.id} />
</TableCell>
<TableCell size="sm">{inbox.title}</TableCell>
<TableCell size="sm">
<InboxSecret secret={inbox.secret} />
</TableCell>
<TableCell size="sm" className="center">
<InboxActions id={inbox.id} />
</TableCell>
</TableRow>
)
})
@@ -1,6 +1,6 @@
import { ActionButton, Button } from "@follow/components/ui/button/index.js"
import { FeedViewType } from "@follow/constants"
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import { useMutation } from "@tanstack/react-query"
import { useTranslation } from "react-i18next"
import { toast } from "sonner"
@@ -1,6 +1,6 @@
import { withResponsiveSyncComponent } from "@follow/components/utils/selector.js"
import { InboxTable as InboxTableDesktop } from "./inbox-table.desktop"
import { InboxTable as InboxTableDesktop } from "./inbox-table.electron"
import { InboxTable as InboxTableMobile } from "./inbox-table.mobile"
export const InboxTable = withResponsiveSyncComponent<ComponentType>(
@@ -1,7 +1,6 @@
import { Card, CardContent, CardHeader, CardTitle } from "@follow/components/ui/card/index.jsx"
import { getDominantColor } from "@follow/utils/color"
import { cn, getUrlIcon } from "@follow/utils/utils"
import clsx from "clsx"
import { clsx, cn, getUrlIcon } from "@follow/utils/utils"
import { upperFirst } from "es-toolkit/compat"
import type { FC } from "react"
import { memo, useEffect, useMemo, useState } from "react"
@@ -9,7 +9,7 @@ import { Masonry } from "@follow/components/ui/masonry/index.js"
import { useScrollViewElement } from "@follow/components/ui/scroll-area/hooks.js"
import { Skeleton } from "@follow/components/ui/skeleton/index.jsx"
import { useRefValue } from "@follow/hooks"
import clsx from "clsx"
import { clsx } from "@follow/utils/utils"
import type { RenderComponentProps } from "masonic"
import { useInfiniteLoader } from "masonic"
import type { FC } from "react"
@@ -1,149 +0,0 @@
import { ActionButton } from "@follow/components/ui/button/index.js"
import { DividerVertical } from "@follow/components/ui/divider/index.js"
import { RotatingRefreshIcon } from "@follow/components/ui/loading/index.jsx"
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
import { FeedViewType, views } from "@follow/constants"
import { useIsOnline } from "@follow/hooks"
import { stopPropagation } from "@follow/utils/dom"
import { cn, isBizId } from "@follow/utils/utils"
import type { FC } from "react"
import * as React from "react"
import { useTranslation } from "react-i18next"
import { setGeneralSetting, useGeneralSettingKey } from "~/atoms/settings/general"
import { useTimelineColumnShow } from "~/atoms/sidebar"
import { useWhoami } from "~/atoms/user"
import { FEED_COLLECTION_LIST, ROUTE_ENTRY_PENDING } from "~/constants"
import { shortcuts } from "~/constants/shortcuts"
import { useRouteParams } from "~/hooks/biz/useRouteParams"
import { EntryHeader } from "~/modules/entry-content/header"
import { useRefreshFeedMutation } from "~/queries/feed"
import { useFeedById, useFeedHeaderTitle } from "~/store/feed"
import { MarkAllReadWithOverlay } from "../components/mark-all-button"
import {
AppendTaildingDivider,
DailyReportButton,
SwitchToMasonryButton,
WideModeButton,
} from "./EntryListHeader.shared"
export const EntryListHeader: FC<{
refetch: () => void
isRefreshing: boolean
hasUpdate: boolean
}> = ({ refetch, isRefreshing, hasUpdate }) => {
const routerParams = useRouteParams()
const { t } = useTranslation()
const unreadOnly = useGeneralSettingKey("unreadOnly")
const { feedId, entryId, view } = routerParams
const headerTitle = useFeedHeaderTitle()
const isInCollectionList = feedId === FEED_COLLECTION_LIST
const titleInfo = !!headerTitle && (
<div className="flex min-w-0 items-center break-all text-lg font-bold leading-tight">
<EllipsisHorizontalTextWithTooltip className="inline-block !w-auto max-w-full">
{headerTitle}
</EllipsisHorizontalTextWithTooltip>
</div>
)
const { mutateAsync: refreshFeed, isPending } = useRefreshFeedMutation(feedId)
const user = useWhoami()
const isOnline = useIsOnline()
const feed = useFeedById(feedId)
const containerRef = React.useRef<HTMLDivElement>(null)
const titleStyleBasedView = ["pl-6", "pl-7", "pl-7", "pl-7", "px-5", "pl-6"]
const feedColumnShow = useTimelineColumnShow()
return (
<div
ref={containerRef}
className={cn(
"mb-2 flex w-full flex-col pr-4 pt-2.5 transition-[padding] duration-300 ease-in-out",
!feedColumnShow && "macos:mt-4 macos:pt-margin-macos-traffic-light-y",
titleStyleBasedView[view],
)}
>
<div className={"flex w-full justify-between"}>
{titleInfo}
<div
className={cn(
"relative z-[1] flex items-center gap-1 self-baseline text-zinc-500",
(isInCollectionList || !headerTitle) && "pointer-events-none opacity-0",
"translate-x-[6px]",
)}
onClick={stopPropagation}
>
{views[view]!.wideMode && entryId && entryId !== ROUTE_ENTRY_PENDING && (
<>
<EntryHeader view={view} entryId={entryId} />
<DividerVertical className="mx-2 w-px" />
</>
)}
<AppendTaildingDivider>
{!views[view]!.wideMode && <WideModeButton />}
{view === FeedViewType.SocialMedia && <DailyReportButton />}
{view === FeedViewType.Pictures && <SwitchToMasonryButton />}
</AppendTaildingDivider>
{isOnline &&
(feed?.ownerUserId === user?.id &&
isBizId(routerParams.feedId!) &&
feed?.type === "feed" ? (
<ActionButton
tooltip="Refresh"
onClick={() => {
refreshFeed()
}}
>
<RotatingRefreshIcon isRefreshing={isPending} />
</ActionButton>
) : (
<ActionButton
tooltip={
hasUpdate
? t("entry_list_header.new_entries_available")
: t("entry_list_header.refetch")
}
onClick={() => {
refetch()
}}
>
<RotatingRefreshIcon
className={cn(hasUpdate && "text-accent")}
isRefreshing={isRefreshing}
/>
</ActionButton>
))}
<ActionButton
tooltip={
!unreadOnly
? t("entry_list_header.show_unread_only")
: t("entry_list_header.show_all")
}
shortcut={shortcuts.entries.toggleUnreadOnly.key}
onClick={() => setGeneralSetting("unreadOnly", !unreadOnly)}
>
{unreadOnly ? (
<i className="i-mgc-round-cute-fi" />
) : (
<i className="i-mgc-round-cute-re" />
)}
</ActionButton>
<MarkAllReadWithOverlay containerRef={containerRef} shortcut />
</div>
</div>
{/* <TimelineTabs /> */}
</div>
)
}
@@ -1 +1,149 @@
export { EntryListHeader } from "./EntryListHeader.desktop"
import { ActionButton } from "@follow/components/ui/button/index.js"
import { DividerVertical } from "@follow/components/ui/divider/index.js"
import { RotatingRefreshIcon } from "@follow/components/ui/loading/index.jsx"
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
import { FeedViewType, views } from "@follow/constants"
import { useIsOnline } from "@follow/hooks"
import { stopPropagation } from "@follow/utils/dom"
import { cn, isBizId } from "@follow/utils/utils"
import type { FC } from "react"
import * as React from "react"
import { useTranslation } from "react-i18next"
import { setGeneralSetting, useGeneralSettingKey } from "~/atoms/settings/general"
import { useTimelineColumnShow } from "~/atoms/sidebar"
import { useWhoami } from "~/atoms/user"
import { FEED_COLLECTION_LIST, ROUTE_ENTRY_PENDING } from "~/constants"
import { shortcuts } from "~/constants/shortcuts"
import { useRouteParams } from "~/hooks/biz/useRouteParams"
import { EntryHeader } from "~/modules/entry-content/header"
import { useRefreshFeedMutation } from "~/queries/feed"
import { useFeedById, useFeedHeaderTitle } from "~/store/feed"
import { MarkAllReadWithOverlay } from "../components/mark-all-button"
import {
AppendTaildingDivider,
DailyReportButton,
SwitchToMasonryButton,
WideModeButton,
} from "./EntryListHeader.shared"
export const EntryListHeader: FC<{
refetch: () => void
isRefreshing: boolean
hasUpdate: boolean
}> = ({ refetch, isRefreshing, hasUpdate }) => {
const routerParams = useRouteParams()
const { t } = useTranslation()
const unreadOnly = useGeneralSettingKey("unreadOnly")
const { feedId, entryId, view } = routerParams
const headerTitle = useFeedHeaderTitle()
const isInCollectionList = feedId === FEED_COLLECTION_LIST
const titleInfo = !!headerTitle && (
<div className="flex min-w-0 items-center break-all text-lg font-bold leading-tight">
<EllipsisHorizontalTextWithTooltip className="inline-block !w-auto max-w-full">
{headerTitle}
</EllipsisHorizontalTextWithTooltip>
</div>
)
const { mutateAsync: refreshFeed, isPending } = useRefreshFeedMutation(feedId)
const user = useWhoami()
const isOnline = useIsOnline()
const feed = useFeedById(feedId)
const containerRef = React.useRef<HTMLDivElement>(null)
const titleStyleBasedView = ["pl-6", "pl-7", "pl-7", "pl-7", "px-5", "pl-6"]
const feedColumnShow = useTimelineColumnShow()
return (
<div
ref={containerRef}
className={cn(
"mb-2 flex w-full flex-col pr-4 pt-2.5 transition-[padding] duration-300 ease-in-out",
!feedColumnShow && "macos:mt-4 macos:pt-margin-macos-traffic-light-y",
titleStyleBasedView[view],
)}
>
<div className={"flex w-full justify-between"}>
{titleInfo}
<div
className={cn(
"relative z-[1] flex items-center gap-1 self-baseline text-zinc-500",
(isInCollectionList || !headerTitle) && "pointer-events-none opacity-0",
"translate-x-[6px]",
)}
onClick={stopPropagation}
>
{views[view]!.wideMode && entryId && entryId !== ROUTE_ENTRY_PENDING && (
<>
<EntryHeader view={view} entryId={entryId} />
<DividerVertical className="mx-2 w-px" />
</>
)}
<AppendTaildingDivider>
{!views[view]!.wideMode && <WideModeButton />}
{view === FeedViewType.SocialMedia && <DailyReportButton />}
{view === FeedViewType.Pictures && <SwitchToMasonryButton />}
</AppendTaildingDivider>
{isOnline &&
(feed?.ownerUserId === user?.id &&
isBizId(routerParams.feedId!) &&
feed?.type === "feed" ? (
<ActionButton
tooltip="Refresh"
onClick={() => {
refreshFeed()
}}
>
<RotatingRefreshIcon isRefreshing={isPending} />
</ActionButton>
) : (
<ActionButton
tooltip={
hasUpdate
? t("entry_list_header.new_entries_available")
: t("entry_list_header.refetch")
}
onClick={() => {
refetch()
}}
>
<RotatingRefreshIcon
className={cn(hasUpdate && "text-accent")}
isRefreshing={isRefreshing}
/>
</ActionButton>
))}
<ActionButton
tooltip={
!unreadOnly
? t("entry_list_header.show_unread_only")
: t("entry_list_header.show_all")
}
shortcut={shortcuts.entries.toggleUnreadOnly.key}
onClick={() => setGeneralSetting("unreadOnly", !unreadOnly)}
>
{unreadOnly ? (
<i className="i-mgc-round-cute-fi" />
) : (
<i className="i-mgc-round-cute-re" />
)}
</ActionButton>
<MarkAllReadWithOverlay containerRef={containerRef} shortcut />
</div>
</div>
{/* <TimelineTabs /> */}
</div>
)
}
@@ -1,6 +1,6 @@
import { withResponsiveSyncComponent } from "@follow/components/utils/selector.js"
import { EntryListHeader as EntryListHeaderDesktop } from "./EntryListHeader.desktop"
import { EntryListHeader as EntryListHeaderDesktop } from "./EntryListHeader.electron"
import { EntryListHeader as EntryListHeaderMobile } from "./EntryListHeader.mobile"
import type { EntryListHeaderProps } from "./EntryListHeader.shared"
@@ -3,9 +3,9 @@ import { useScrollViewElement } from "@follow/components/ui/scroll-area/hooks.js
import type { FeedViewType } from "@follow/constants"
import { useTypeScriptHappyCallback } from "@follow/hooks"
import { LRUCache } from "@follow/utils/lru-cache"
import { clsx } from "@follow/utils/utils"
import type { Range, VirtualItem, Virtualizer } from "@tanstack/react-virtual"
import { defaultRangeExtractor, useVirtualizer } from "@tanstack/react-virtual"
import clsx from "clsx"
import type { HTMLMotionProps } from "framer-motion"
import type { FC, MutableRefObject, ReactNode } from "react"
import {
@@ -1,6 +1,6 @@
import { useMobile } from "@follow/components/hooks/useMobile.js"
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
import { clsx, cn, isSafari } from "@follow/utils/utils"
import { clsx, cn, formatEstimatedMins, isSafari } from "@follow/utils/utils"
import { useMemo } from "react"
import { AudioPlayer, useAudioPlayerAtomSelector } from "~/atoms/player"
@@ -320,24 +320,3 @@ function AudioCover({
</div>
)
}
const formatEstimatedMins = (estimatedMins: number) => {
const minutesInHour = 60
const minutesInDay = minutesInHour * 24
const minutesInMonth = minutesInDay * 30
const months = Math.floor(estimatedMins / minutesInMonth)
const days = Math.floor((estimatedMins % minutesInMonth) / minutesInDay)
const hours = Math.floor((estimatedMins % minutesInDay) / minutesInHour)
const minutes = estimatedMins % minutesInHour
if (months > 0) {
return `${months}M ${days}d`
}
if (days > 0) {
return `${days}d ${hours}h`
}
if (hours > 0) {
return `${hours}h ${minutes}m`
}
return `${estimatedMins} mins`
}
@@ -1,30 +0,0 @@
import { ScrollArea } from "@follow/components/ui/scroll-area/ScrollArea.js"
import { views } from "@follow/constants"
import { clsx } from "clsx"
import { forwardRef } from "react"
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
import type { EntryColumnWrapperProps } from "./wrapper.shared"
import { animationStyles, styles } from "./wrapper.shared"
export const EntryColumnWrapper = forwardRef<HTMLDivElement, EntryColumnWrapperProps>(
({ children, onScroll }, ref) => {
const view = useRouteParamsSelector((state) => state.view)
return (
<div className={clsx(styles, animationStyles, "mt-2")}>
<ScrollArea
scrollbarClassName={clsx(!views[view]!.wideMode ? "w-[5px] p-0" : "", "z-[3]")}
mask={false}
ref={ref}
rootClassName={clsx("h-full", views[view]!.wideMode ? "mt-2" : "")}
viewportClassName="[&>div]:grow flex"
onScroll={onScroll}
>
{children}
</ScrollArea>
</div>
)
},
)
@@ -1 +1,30 @@
export { EntryColumnWrapper } from "./wrapper.desktop"
import { ScrollArea } from "@follow/components/ui/scroll-area/ScrollArea.js"
import { views } from "@follow/constants"
import { clsx } from "clsx"
import { forwardRef } from "react"
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
import type { EntryColumnWrapperProps } from "./wrapper.shared"
import { animationStyles, styles } from "./wrapper.shared"
export const EntryColumnWrapper = forwardRef<HTMLDivElement, EntryColumnWrapperProps>(
({ children, onScroll }, ref) => {
const view = useRouteParamsSelector((state) => state.view)
return (
<div className={clsx(styles, animationStyles, "mt-2")}>
<ScrollArea
scrollbarClassName={clsx(!views[view]!.wideMode ? "w-[5px] p-0" : "", "z-[3]")}
mask={false}
ref={ref}
rootClassName={clsx("h-full", views[view]!.wideMode ? "mt-2" : "")}
viewportClassName="[&>div]:grow flex"
onScroll={onScroll}
>
{children}
</ScrollArea>
</div>
)
},
)
@@ -1,6 +1,6 @@
import { withResponsiveSyncComponent } from "@follow/components/utils/selector.js"
import { EntryColumnWrapper as EntryColumnWrapperDesktop } from "./wrapper.desktop"
import { EntryColumnWrapper as EntryColumnWrapperDesktop } from "./wrapper.electron"
import { EntryColumnWrapper as EntryColumnWrapperMobile } from "./wrapper.mobile"
import type { EntryColumnWrapperProps } from "./wrapper.shared"
@@ -1,100 +0,0 @@
import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
import {
HoverCard,
HoverCardContent,
HoverCardPortal,
HoverCardTrigger,
} from "@radix-ui/react-hover-card"
import clsx from "clsx"
import { useWhoami } from "~/atoms/user"
import { useAuthQuery } from "~/hooks/common"
import { useAppLayoutGridContainerWidth } from "~/providers/app-grid-layout-container-provider"
import { Queries } from "~/queries"
import { useEntryReadHistory } from "~/store/entry"
import { EntryUser, EntryUserRow, getLimit } from "./EntryReadHistory.shared"
export const EntryReadHistory: Component<{ entryId: string }> = ({ entryId }) => {
const me = useWhoami()
const entryHistory = useEntryReadHistory(entryId)
const { data } = useAuthQuery(Queries.entries.entryReadingHistory(entryId), {
refetchInterval: 1000 * 60,
})
const totalCount = data?.total || 0
const appGirdContainerWidth = useAppLayoutGridContainerWidth()
const LIMIT = getLimit(appGirdContainerWidth)
if (!entryHistory) return null
if (!me) return null
if (!entryHistory.userIds) return null
return (
<div
className="animate-in fade-in @md:flex hidden items-center duration-200"
data-hide-in-print
>
{entryHistory.userIds
.filter((id) => id !== me?.id)
.slice(0, LIMIT)
.map((userId, i) => (
<EntryUser userId={userId} i={i} key={userId} />
))}
{!!totalCount && totalCount > LIMIT && (
<HoverCard>
<HoverCardTrigger asChild>
<button
type="button"
style={{
marginLeft: `-${LIMIT * 8}px`,
zIndex: LIMIT + 1,
}}
className="no-drag-region border-border bg-muted ring-background relative flex size-7 items-center justify-center rounded-full border ring-2"
>
<span className="text-muted-foreground text-[10px] font-medium tabular-nums">
+{Math.min(totalCount - LIMIT, 99)}
</span>
</button>
</HoverCardTrigger>
{totalCount > LIMIT && (
<HoverCardPortal>
<HoverCardContent
sideOffset={12}
align="start"
side="right"
className={clsx(
"bg-background z-10 rounded-md border drop-shadow",
"data-[state=open]:animate-in data-[state=closed]:animate-out",
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
"data-[state=closed]:slide-out-to-left-5 data-[state=open]:slide-in-from-left-5",
"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
"transition-all duration-200 ease-in-out",
)}
>
<ScrollArea.ScrollArea
rootClassName="max-h-[300px] max-w-[20ch] flex flex-col"
flex
>
<ul>
{entryHistory.userIds
.filter((id) => id !== me?.id)
.slice(LIMIT)
.map((userId) => (
<EntryUserRow userId={userId} key={userId} />
))}
</ul>
</ScrollArea.ScrollArea>
</HoverCardContent>
</HoverCardPortal>
)}
</HoverCard>
)}
</div>
)
}
@@ -1 +1,100 @@
export { EntryReadHistory } from "./EntryReadHistory.desktop"
import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
import {
HoverCard,
HoverCardContent,
HoverCardPortal,
HoverCardTrigger,
} from "@radix-ui/react-hover-card"
import clsx from "clsx"
import { useWhoami } from "~/atoms/user"
import { useAuthQuery } from "~/hooks/common"
import { useAppLayoutGridContainerWidth } from "~/providers/app-grid-layout-container-provider"
import { Queries } from "~/queries"
import { useEntryReadHistory } from "~/store/entry"
import { EntryUser, EntryUserRow, getLimit } from "./EntryReadHistory.shared"
export const EntryReadHistory: Component<{ entryId: string }> = ({ entryId }) => {
const me = useWhoami()
const entryHistory = useEntryReadHistory(entryId)
const { data } = useAuthQuery(Queries.entries.entryReadingHistory(entryId), {
refetchInterval: 1000 * 60,
})
const totalCount = data?.total || 0
const appGirdContainerWidth = useAppLayoutGridContainerWidth()
const LIMIT = getLimit(appGirdContainerWidth)
if (!entryHistory) return null
if (!me) return null
if (!entryHistory.userIds) return null
return (
<div
className="animate-in fade-in @md:flex hidden items-center duration-200"
data-hide-in-print
>
{entryHistory.userIds
.filter((id) => id !== me?.id)
.slice(0, LIMIT)
.map((userId, i) => (
<EntryUser userId={userId} i={i} key={userId} />
))}
{!!totalCount && totalCount > LIMIT && (
<HoverCard>
<HoverCardTrigger asChild>
<button
type="button"
style={{
marginLeft: `-${LIMIT * 8}px`,
zIndex: LIMIT + 1,
}}
className="no-drag-region border-border bg-muted ring-background relative flex size-7 items-center justify-center rounded-full border ring-2"
>
<span className="text-muted-foreground text-[10px] font-medium tabular-nums">
+{Math.min(totalCount - LIMIT, 99)}
</span>
</button>
</HoverCardTrigger>
{totalCount > LIMIT && (
<HoverCardPortal>
<HoverCardContent
sideOffset={12}
align="start"
side="right"
className={clsx(
"bg-background z-10 rounded-md border drop-shadow",
"data-[state=open]:animate-in data-[state=closed]:animate-out",
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
"data-[state=closed]:slide-out-to-left-5 data-[state=open]:slide-in-from-left-5",
"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
"transition-all duration-200 ease-in-out",
)}
>
<ScrollArea.ScrollArea
rootClassName="max-h-[300px] max-w-[20ch] flex flex-col"
flex
>
<ul>
{entryHistory.userIds
.filter((id) => id !== me?.id)
.slice(LIMIT)
.map((userId) => (
<EntryUserRow userId={userId} key={userId} />
))}
</ul>
</ScrollArea.ScrollArea>
</HoverCardContent>
</HoverCardPortal>
)}
</HoverCard>
)}
</div>
)
}
@@ -1,6 +1,6 @@
import { withResponsiveSyncComponent } from "@follow/components/utils/selector.js"
import { EntryReadHistory as EntryReadHistoryDesktop } from "./EntryReadHistory.desktop"
import { EntryReadHistory as EntryReadHistoryDesktop } from "./EntryReadHistory.electron"
import { EntryReadHistory as EntryReadHistoryMobile } from "./EntryReadHistory.mobile"
export const EntryReadHistory = withResponsiveSyncComponent(
@@ -1,6 +1,6 @@
import { withResponsiveSyncComponent } from "@follow/components/utils/selector.js"
import { EntryHeader as EntryHeaderDesktop } from "./header.desktop"
import { EntryHeader as EntryHeaderDesktop } from "./header.electron"
import { EntryHeader as EntryHeaderMobile } from "./header.mobile"
import type { EntryHeaderProps } from "./header.shared"
@@ -3,6 +3,6 @@ import { withResponsiveComponent } from "@follow/components/utils/selector.js"
import type { EntryContentProps } from "./index.shared"
export const EntryContent = withResponsiveComponent<ComponentType<EntryContentProps>>(
() => import("./index.desktop").then((m) => ({ default: m.EntryContent })),
() => import("./index.electron").then((m) => ({ default: m.EntryContent })),
() => import("./index.mobile").then((m) => ({ default: m.EntryContent })),
)
@@ -1,9 +1,9 @@
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/EllipsisWithTooltip.js"
import type { FeedOrListRespModel } from "@follow/models/types"
import { env } from "@follow/shared/env"
import { UrlBuilder } from "@follow/utils/url-builder"
import { env } from "@follow/shared/env.desktop"
import { cn } from "@follow/utils/utils"
import { UrlBuilder } from "~/lib/url-builder"
import { FeedIcon } from "~/modules/feed/feed-icon"
import { FeedTitle } from "~/modules/feed/feed-title"
@@ -1,8 +1,7 @@
import { MotionButtonBase } from "@follow/components/ui/button/index.js"
import { KbdCombined } from "@follow/components/ui/kbd/Kbd.js"
import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
import { cn } from "@follow/utils/utils"
import clsx from "clsx"
import { clsx, cn } from "@follow/utils/utils"
import { m, useDragControls } from "framer-motion"
import { useCallback, useEffect } from "react"
import { useTranslation } from "react-i18next"
@@ -11,8 +11,7 @@ import {
import { Tooltip, TooltipContent, TooltipTrigger } from "@follow/components/ui/tooltip/index.jsx"
import type { FeedViewType } from "@follow/constants"
import { useInputComposition } from "@follow/hooks"
import { cn } from "@follow/utils/utils"
import clsx from "clsx"
import { clsx, cn } from "@follow/utils/utils"
import { Command } from "cmdk"
import type { FC } from "react"
import * as React from "react"
@@ -1,5 +1,8 @@
import { Button } from "@follow/components/ui/button/index.js"
import { Tooltip, TooltipContent, TooltipTrigger } from "@follow/components/ui/tooltip/index.jsx"
import { env } from "@follow/shared/env.desktop"
import { useRef } from "react"
import ReCAPTCHA from "react-google-recaptcha"
import { Trans, useTranslation } from "react-i18next"
import { useServerConfigs } from "~/atoms/server-configs"
@@ -14,17 +17,31 @@ export const ClaimDailyReward = () => {
const serverConfigs = useServerConfigs()
const recaptchaRef = useRef<ReCAPTCHA>(null)
return (
<Tooltip>
<TooltipTrigger asChild>
<Button
variant="primary"
isLoading={mutation.isPending}
onClick={() => mutation.mutate()}
disabled={!canClaim}
>
{canClaim ? t("wallet.claim.button.claim") : t("wallet.claim.button.claimed")}
</Button>
<>
{env.VITE_RECAPTCHA_V2_SITE_KEY && (
<ReCAPTCHA
ref={recaptchaRef}
sitekey={env.VITE_RECAPTCHA_V2_SITE_KEY}
size="invisible"
/>
)}
<Button
variant="primary"
isLoading={mutation.isPending}
onClick={async () => {
const token = await recaptchaRef.current?.executeAsync()
mutation.mutate({ tokenV2: token })
}}
disabled={!canClaim}
>
{canClaim ? t("wallet.claim.button.claim") : t("wallet.claim.button.claimed")}
</Button>
</>
</TooltipTrigger>
<TooltipContent>
{canClaim ? (
@@ -1,96 +0,0 @@
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@follow/components/ui/table/index.jsx"
import {
Tooltip,
TooltipContent,
TooltipPortal,
TooltipTrigger,
} from "@follow/components/ui/tooltip/index.jsx"
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
import type { TransactionTypes } from "@follow/models"
import { cn } from "@follow/utils/utils"
import { useTranslation } from "react-i18next"
import { useWhoami } from "~/atoms/user"
import { RelativeTime } from "~/components/ui/datetime"
import { getBlockchainExplorerUrl } from "~/lib/utils"
import { useWalletTransactions } from "~/queries/wallet"
import type { TxTableProps } from "./tx-table.shared"
import { BalanceRenderer, TypeRenderer, UserRenderer } from "./tx-table.shared"
export const TxTable = ({ className, type }: ComponentType<TxTableProps>) => {
const { t } = useTranslation("settings")
const user = useWhoami()
const transactions = useWalletTransactions({
fromOrToUserId: user?.id,
type: type === "all" ? undefined : (type as (typeof TransactionTypes)[number]),
})
return (
<div className={cn("w-fit min-w-0 grow overflow-x-auto", className)}>
<Table className="w-full table-fixed">
<TableHeader className="bg-theme-background sticky top-0">
<TableRow className="[&_*]:!pl-0 [&_*]:!font-semibold">
<TableHead>{t("wallet.transactions.type")}</TableHead>
<TableHead>{t("wallet.transactions.amount")}</TableHead>
<TableHead>{t("wallet.transactions.from")}</TableHead>
<TableHead>{t("wallet.transactions.to")}</TableHead>
<TableHead>{t("wallet.transactions.date")}</TableHead>
<TableHead>{t("wallet.transactions.tx")}</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{transactions.data?.map((row) => (
<TableRow key={row.hash}>
<TableCell align="left" size="sm">
<TypeRenderer type={row.type} />
</TableCell>
<TableCell align="left" size="sm">
<BalanceRenderer
sign={row.fromUserId === user?.id ? "-" : "+"}
amount={row.powerToken}
tax={row.tax}
/>
</TableCell>
<TableCell align="left" size="sm">
<UserRenderer user={row.fromUser} />
</TableCell>
<TableCell align="left" size="sm">
<UserRenderer user={row.toUser} />
</TableCell>
<TableCell align="left" size="sm">
<EllipsisHorizontalTextWithTooltip>
<RelativeTime date={row.createdAt} dateFormatTemplate="l" />
</EllipsisHorizontalTextWithTooltip>
</TableCell>
<TableCell align="left" size="sm">
<Tooltip>
<TooltipTrigger>
<a
target="_blank"
href={`${getBlockchainExplorerUrl()}/tx/${row.hash}`}
className="underline"
>
{row.hash.slice(0, 10)}...
</a>
</TooltipTrigger>
<TooltipPortal>
<TooltipContent>{row.hash}</TooltipContent>
</TooltipPortal>
</Tooltip>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
)
}
@@ -1 +1,96 @@
export { TxTable } from "./tx-table.desktop"
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@follow/components/ui/table/index.jsx"
import {
Tooltip,
TooltipContent,
TooltipPortal,
TooltipTrigger,
} from "@follow/components/ui/tooltip/index.jsx"
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
import type { TransactionTypes } from "@follow/models"
import { cn } from "@follow/utils/utils"
import { useTranslation } from "react-i18next"
import { useWhoami } from "~/atoms/user"
import { RelativeTime } from "~/components/ui/datetime"
import { getBlockchainExplorerUrl } from "~/lib/utils"
import { useWalletTransactions } from "~/queries/wallet"
import type { TxTableProps } from "./tx-table.shared"
import { BalanceRenderer, TypeRenderer, UserRenderer } from "./tx-table.shared"
export const TxTable = ({ className, type }: ComponentType<TxTableProps>) => {
const { t } = useTranslation("settings")
const user = useWhoami()
const transactions = useWalletTransactions({
fromOrToUserId: user?.id,
type: type === "all" ? undefined : (type as (typeof TransactionTypes)[number]),
})
return (
<div className={cn("w-fit min-w-0 grow overflow-x-auto", className)}>
<Table className="w-full table-fixed">
<TableHeader className="bg-theme-background sticky top-0">
<TableRow className="[&_*]:!pl-0 [&_*]:!font-semibold">
<TableHead>{t("wallet.transactions.type")}</TableHead>
<TableHead>{t("wallet.transactions.amount")}</TableHead>
<TableHead>{t("wallet.transactions.from")}</TableHead>
<TableHead>{t("wallet.transactions.to")}</TableHead>
<TableHead>{t("wallet.transactions.date")}</TableHead>
<TableHead>{t("wallet.transactions.tx")}</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{transactions.data?.map((row) => (
<TableRow key={row.hash}>
<TableCell align="left" size="sm">
<TypeRenderer type={row.type} />
</TableCell>
<TableCell align="left" size="sm">
<BalanceRenderer
sign={row.fromUserId === user?.id ? "-" : "+"}
amount={row.powerToken}
tax={row.tax}
/>
</TableCell>
<TableCell align="left" size="sm">
<UserRenderer user={row.fromUser} />
</TableCell>
<TableCell align="left" size="sm">
<UserRenderer user={row.toUser} />
</TableCell>
<TableCell align="left" size="sm">
<EllipsisHorizontalTextWithTooltip>
<RelativeTime date={row.createdAt} dateFormatTemplate="l" />
</EllipsisHorizontalTextWithTooltip>
</TableCell>
<TableCell align="left" size="sm">
<Tooltip>
<TooltipTrigger>
<a
target="_blank"
href={`${getBlockchainExplorerUrl()}/tx/${row.hash}`}
className="underline"
>
{row.hash.slice(0, 10)}...
</a>
</TooltipTrigger>
<TooltipPortal>
<TooltipContent>{row.hash}</TooltipContent>
</TooltipPortal>
</Tooltip>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
)
}
@@ -1,6 +1,6 @@
import { withResponsiveSyncComponent } from "@follow/components/utils/selector.js"
import { TxTable as TxTableDesktop } from "./tx-table.desktop"
import { TxTable as TxTableDesktop } from "./tx-table.electron"
import { TxTable as TxTableMobile } from "./tx-table.mobile"
import type { TxTableProps } from "./tx-table.shared"
@@ -1,12 +1,12 @@
import { Button } from "@follow/components/ui/button/index.js"
import { authProvidersConfig } from "@follow/constants"
import { linkSocial, unlinkAccount } from "@follow/shared/auth"
import { IN_ELECTRON } from "@follow/shared/constants"
import { cn } from "@follow/utils/utils"
import { useMutation } from "@tanstack/react-query"
import { useTranslation } from "react-i18next"
import { toast } from "sonner"
import { linkSocial, unlinkAccount } from "~/lib/auth"
import { auth, useSocialAccounts } from "~/queries/auth"
import { useAuthProviders } from "~/queries/users"
@@ -9,7 +9,6 @@ import {
} from "@follow/components/ui/form/index.js"
import { Input } from "@follow/components/ui/input/Input.js"
import { Label } from "@follow/components/ui/label/index.js"
import { changeEmail, sendVerificationEmail } from "@follow/shared/auth"
import { cn } from "@follow/utils/utils"
import { zodResolver } from "@hookform/resolvers/zod"
import { useMutation } from "@tanstack/react-query"
@@ -23,6 +22,7 @@ import { setWhoami, useWhoami } from "~/atoms/user"
import { AnimatedCommandButton } from "~/components/ui/button/base"
import { CopyButton } from "~/components/ui/button/CopyButton"
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
import { changeEmail, sendVerificationEmail } from "~/lib/auth"
const formSchema = z.object({
email: z.string().email(),
@@ -111,7 +111,6 @@ function EmailManagementForm() {
const updateEmailMutation = useMutation({
mutationFn: async (values: z.infer<typeof formSchema>) => {
await new Promise((resolve) => setTimeout(resolve, 1000))
const res = await changeEmail({ newEmail: values.email })
if (res.error) {
throw new Error(res.error.message)
@@ -10,7 +10,6 @@ import {
FormMessage,
} from "@follow/components/ui/form/index.jsx"
import { Input } from "@follow/components/ui/input/index.js"
import { updateUser } from "@follow/shared/auth"
import { cn } from "@follow/utils/utils"
import { zodResolver } from "@hookform/resolvers/zod"
import { useMutation } from "@tanstack/react-query"
@@ -20,6 +19,7 @@ import { toast } from "sonner"
import { z } from "zod"
import { setWhoami, useWhoami } from "~/atoms/user"
import { updateUser } from "~/lib/auth"
import { toastFetchError } from "~/lib/error-parser"
const formSchema = z.object({
@@ -9,7 +9,6 @@ import {
} from "@follow/components/ui/form/index.jsx"
import { Input, InputOTP, InputOTPGroup, InputOTPSlot } from "@follow/components/ui/input/index.js"
import { Label } from "@follow/components/ui/label/index.js"
import { twoFactor } from "@follow/shared/auth"
import { zodResolver } from "@hookform/resolvers/zod"
import { useMutation } from "@tanstack/react-query"
import { m, useAnimation } from "framer-motion"
@@ -22,6 +21,7 @@ import { z } from "zod"
import { setWhoami, useWhoami } from "~/atoms/user"
import { useCurrentModal, useModalStack } from "~/components/ui/modal/stacked/hooks"
import { twoFactor } from "~/lib/auth"
import { getFetchErrorInfo } from "~/lib/error-parser"
import { useHasPassword } from "~/queries/auth"
@@ -8,8 +8,7 @@ import {
} from "@follow/components/ui/form/index.jsx"
import { Input } from "@follow/components/ui/input/index.js"
import { Label } from "@follow/components/ui/label/index.js"
import { changePassword } from "@follow/shared/auth"
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import { zodResolver } from "@hookform/resolvers/zod"
import { useMutation } from "@tanstack/react-query"
import { useForm } from "react-hook-form"
@@ -18,6 +17,7 @@ import { toast } from "sonner"
import { z } from "zod"
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
import { changePassword } from "~/lib/auth"
import { useHasPassword } from "~/queries/auth"
const passwordSchema = z.string().min(8).max(128)
@@ -1,309 +0,0 @@
import { FollowIcon } from "@follow/components/icons/follow.jsx"
import { Avatar, AvatarFallback, AvatarImage } from "@follow/components/ui/avatar/index.jsx"
import { ActionButton, Button } from "@follow/components/ui/button/index.js"
import { LoadingCircle } from "@follow/components/ui/loading/index.jsx"
import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
import { nextFrame, stopPropagation } from "@follow/utils/dom"
import { getStorageNS } from "@follow/utils/ns"
import { UrlBuilder } from "@follow/utils/url-builder"
import { clsx, cn } from "@follow/utils/utils"
import { throttle } from "es-toolkit/compat"
import { useAnimationControls } from "framer-motion"
import { useAtom } from "jotai"
import { atomWithStorage } from "jotai/utils"
import type { FC } from "react"
import { Fragment, useEffect, useMemo, useRef, useState } from "react"
import { useTranslation } from "react-i18next"
import { m } from "~/components/common/Motion"
import { useCurrentModal } from "~/components/ui/modal/stacked/hooks"
import { useFollow } from "~/hooks/biz/useFollow"
import { useAuthQuery } from "~/hooks/common"
import { apiClient } from "~/lib/api-fetch"
import { defineQuery } from "~/lib/defineQuery"
import { replaceImgUrlIfNeed } from "~/lib/img-proxy"
import { useUserSubscriptionsQuery } from "~/modules/profile/hooks"
import { useUserById } from "~/store/user"
import type { SubscriptionModalContentProps } from "./user-profile-modal.shared"
import { SubscriptionItems } from "./user-profile-modal.shared"
type ItemVariant = "loose" | "compact"
const itemVariantAtom = atomWithStorage(
getStorageNS("item-variant"),
"loose" as ItemVariant,
undefined,
{
getOnInit: true,
},
)
export const UserProfileModalContent: FC<SubscriptionModalContentProps> = ({ userId, variant }) => {
const { t } = useTranslation()
const user = useAuthQuery(
defineQuery(["profiles", userId], async () => {
const res = await apiClient.profiles.$get({
query: { id: userId! },
})
return res.data
}),
)
const storeUser = useUserById(userId)
const userInfo = user.data
? {
avatar: user.data.image,
name: user.data.name,
handle: user.data.handle,
id: user.data.id,
}
: storeUser
? {
avatar: storeUser.image,
name: storeUser.name,
handle: storeUser.handle,
id: storeUser.id,
}
: null
const follow = useFollow()
const subscriptions = useUserSubscriptionsQuery(user.data?.id)
const modal = useCurrentModal()
const controller = useAnimationControls()
useEffect(() => {
nextFrame(() => controller.start("enter"))
}, [controller])
const winHeight = useState(() => window.innerHeight)[0]
const [scrollerRef, setScrollerRef] = useState<HTMLDivElement | null>(null)
const [isHeaderSimple, setHeaderSimple] = useState(false)
const currentVisibleRef = useRef<Set<string>>()
useEffect(() => {
const $ref = scrollerRef
if (!$ref) return
const initialHeaderHeight = 136
const scrollHandler = throttle(() => {
const currentH = $ref.scrollTop
setHeaderSimple((current) => {
if (!current) {
return currentH > initialHeaderHeight
} else {
if (currentH === 0) return false
}
return current
})
}, 16)
$ref.addEventListener("scroll", scrollHandler)
const currentVisible = new Set<string>()
const ob = new IntersectionObserver((en) => {
en.forEach((entry) => {
const id = (entry.target as HTMLElement).dataset.feedId as string
if (!id) return
if (entry.isIntersecting) {
currentVisible.add(id)
} else {
currentVisible.delete(id)
}
})
if (currentVisible.size === 0) return
currentVisibleRef.current = currentVisible
})
$ref.querySelectorAll("[data-feed-id]").forEach((el) => {
ob.observe(el)
})
return () => {
$ref.removeEventListener("scroll", scrollHandler)
ob.disconnect()
}
}, [scrollerRef, subscriptions])
const modalVariant = useMemo(() => {
switch (variant) {
case "drawer": {
return {
enter: {
x: 0,
opacity: 1,
},
initial: {
x: 700,
opacity: 0.9,
},
exit: {
x: 750,
opacity: 0,
},
}
}
case "dialog": {
return {
enter: {
y: 0,
opacity: 1,
},
initial: {
y: "100%",
opacity: 0.9,
},
exit: {
y: winHeight,
},
}
}
}
}, [variant, winHeight])
const [itemStyle, setItemStyle] = useAtom(itemVariantAtom)
return (
<div
className={variant === "drawer" ? "h-full" : "center container h-full"}
onPointerDown={variant === "dialog" ? modal.dismiss : undefined}
onClick={stopPropagation}
>
<m.div
onPointerDown={stopPropagation}
tabIndex={-1}
initial="initial"
animate={controller}
variants={modalVariant}
transition={{
type: "spring",
mass: 0.4,
tension: 100,
friction: 1,
}}
exit="exit"
layout="size"
className={cn(
"bg-theme-background relative flex flex-col items-center overflow-hidden rounded-xl border p-8 pb-0",
variant === "drawer"
? "shadow-drawer-to-left h-full w-[60ch] max-w-full"
: "h-[80vh] w-[800px] max-w-full shadow lg:max-h-[calc(100vh-10rem)]",
)}
>
<div className="absolute right-2 top-2 z-10 flex items-center gap-2 text-[20px] opacity-80">
<ActionButton
tooltip={t("user_profile.toggle_item_style")}
onClick={() => {
const currentVisible = currentVisibleRef.current
const topOfCurrent = currentVisible?.values().next().value
setItemStyle((current) => (current === "loose" ? "compact" : "loose"))
if (!topOfCurrent) return
nextFrame(() => {
scrollerRef?.querySelector(`[data-feed-id="${topOfCurrent}"]`)?.scrollIntoView()
})
}}
>
<i
className={cn(
itemStyle === "loose" ? "i-mgc-list-check-3-cute-re" : "i-mgc-list-check-cute-re",
)}
/>
</ActionButton>
<ActionButton
tooltip={t("user_profile.share")}
onClick={() => {
if (!user.data) return
window.open(UrlBuilder.profile(user.data.handle ?? user.data.id))
}}
>
<i className="i-mgc-share-3-cute-re" />
</ActionButton>
<ActionButton tooltip={t("user_profile.close")} onClick={modal.dismiss}>
<i className="i-mgc-close-cute-re" />
</ActionButton>
</div>
{userInfo && (
<Fragment>
<div
className={cn(
"center f-motion-reduce:duration-700 m-12 mb-4 flex shrink-0 flex-col",
isHeaderSimple ? "mt-3 flex-row" : "flex-col",
)}
>
<Avatar
asChild
className={cn("aspect-square", isHeaderSimple ? "size-12" : "size-16")}
>
<m.span layout transition={{ duration: 0.35 }}>
<AvatarImage
className="animate-in fade-in-0 duration-200"
asChild
src={replaceImgUrlIfNeed(userInfo.avatar || undefined)}
>
<m.img layout transition={{ duration: 0.35 }} />
</AvatarImage>
<AvatarFallback>{userInfo.name?.slice(0, 2)}</AvatarFallback>
</m.span>
</Avatar>
<m.div
layout
transition={{ duration: 0.35 }}
className={cn(
"relative flex cursor-text select-text flex-col items-center",
isHeaderSimple ? "ml-8 items-start" : "",
)}
>
<m.div
className={cn(
"mb-1 flex items-center text-2xl font-bold",
isHeaderSimple ? "" : "mt-4",
)}
>
<m.h1 layout>{userInfo.name}</m.h1>
</m.div>
<m.div
className={cn(
"text-sm text-zinc-500",
userInfo.handle ? "visible" : "hidden select-none",
)}
layout
>
@{userInfo.handle}
</m.div>
<Button
buttonClassName={cn(
isHeaderSimple ? "absolute -right-full top-4 rounded-full p-2" : "mt-4",
)}
onClick={() => {
follow({
url: `rsshub://follow/profile/${userInfo.id}`,
isList: false,
})
}}
>
<FollowIcon className={clsx("size-3", !isHeaderSimple ? "mr-1" : "")} />
{isHeaderSimple ? "" : t("feed_form.follow")}
</Button>
</m.div>
</div>
<ScrollArea.ScrollArea
ref={setScrollerRef}
rootClassName="grow max-w-full px-5 w-full"
viewportClassName="[&>div]:space-y-4 pb-4"
>
<SubscriptionItems userId={userId} itemStyle={itemStyle} />
</ScrollArea.ScrollArea>
</Fragment>
)}
{!userInfo && <LoadingCircle size="large" className="center h-full" />}
</m.div>
</div>
)
}
@@ -1 +1,309 @@
export { UserProfileModalContent } from "./user-profile-modal.desktop"
import { FollowIcon } from "@follow/components/icons/follow.jsx"
import { Avatar, AvatarFallback, AvatarImage } from "@follow/components/ui/avatar/index.jsx"
import { ActionButton, Button } from "@follow/components/ui/button/index.js"
import { LoadingCircle } from "@follow/components/ui/loading/index.jsx"
import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
import { nextFrame, stopPropagation } from "@follow/utils/dom"
import { getStorageNS } from "@follow/utils/ns"
import { clsx, cn } from "@follow/utils/utils"
import { throttle } from "es-toolkit/compat"
import { useAnimationControls } from "framer-motion"
import { useAtom } from "jotai"
import { atomWithStorage } from "jotai/utils"
import type { FC } from "react"
import { Fragment, useEffect, useMemo, useRef, useState } from "react"
import { useTranslation } from "react-i18next"
import { m } from "~/components/common/Motion"
import { useCurrentModal } from "~/components/ui/modal/stacked/hooks"
import { useFollow } from "~/hooks/biz/useFollow"
import { useAuthQuery } from "~/hooks/common"
import { apiClient } from "~/lib/api-fetch"
import { defineQuery } from "~/lib/defineQuery"
import { replaceImgUrlIfNeed } from "~/lib/img-proxy"
import { UrlBuilder } from "~/lib/url-builder"
import { useUserSubscriptionsQuery } from "~/modules/profile/hooks"
import { useUserById } from "~/store/user"
import type { SubscriptionModalContentProps } from "./user-profile-modal.shared"
import { SubscriptionItems } from "./user-profile-modal.shared"
type ItemVariant = "loose" | "compact"
const itemVariantAtom = atomWithStorage(
getStorageNS("item-variant"),
"loose" as ItemVariant,
undefined,
{
getOnInit: true,
},
)
export const UserProfileModalContent: FC<SubscriptionModalContentProps> = ({ userId, variant }) => {
const { t } = useTranslation()
const user = useAuthQuery(
defineQuery(["profiles", userId], async () => {
const res = await apiClient.profiles.$get({
query: { id: userId! },
})
return res.data
}),
)
const storeUser = useUserById(userId)
const userInfo = user.data
? {
avatar: user.data.image,
name: user.data.name,
handle: user.data.handle,
id: user.data.id,
}
: storeUser
? {
avatar: storeUser.image,
name: storeUser.name,
handle: storeUser.handle,
id: storeUser.id,
}
: null
const follow = useFollow()
const subscriptions = useUserSubscriptionsQuery(user.data?.id)
const modal = useCurrentModal()
const controller = useAnimationControls()
useEffect(() => {
nextFrame(() => controller.start("enter"))
}, [controller])
const winHeight = useState(() => window.innerHeight)[0]
const [scrollerRef, setScrollerRef] = useState<HTMLDivElement | null>(null)
const [isHeaderSimple, setHeaderSimple] = useState(false)
const currentVisibleRef = useRef<Set<string>>()
useEffect(() => {
const $ref = scrollerRef
if (!$ref) return
const initialHeaderHeight = 136
const scrollHandler = throttle(() => {
const currentH = $ref.scrollTop
setHeaderSimple((current) => {
if (!current) {
return currentH > initialHeaderHeight
} else {
if (currentH === 0) return false
}
return current
})
}, 16)
$ref.addEventListener("scroll", scrollHandler)
const currentVisible = new Set<string>()
const ob = new IntersectionObserver((en) => {
en.forEach((entry) => {
const id = (entry.target as HTMLElement).dataset.feedId as string
if (!id) return
if (entry.isIntersecting) {
currentVisible.add(id)
} else {
currentVisible.delete(id)
}
})
if (currentVisible.size === 0) return
currentVisibleRef.current = currentVisible
})
$ref.querySelectorAll("[data-feed-id]").forEach((el) => {
ob.observe(el)
})
return () => {
$ref.removeEventListener("scroll", scrollHandler)
ob.disconnect()
}
}, [scrollerRef, subscriptions])
const modalVariant = useMemo(() => {
switch (variant) {
case "drawer": {
return {
enter: {
x: 0,
opacity: 1,
},
initial: {
x: 700,
opacity: 0.9,
},
exit: {
x: 750,
opacity: 0,
},
}
}
case "dialog": {
return {
enter: {
y: 0,
opacity: 1,
},
initial: {
y: "100%",
opacity: 0.9,
},
exit: {
y: winHeight,
},
}
}
}
}, [variant, winHeight])
const [itemStyle, setItemStyle] = useAtom(itemVariantAtom)
return (
<div
className={variant === "drawer" ? "h-full" : "center container h-full"}
onPointerDown={variant === "dialog" ? modal.dismiss : undefined}
onClick={stopPropagation}
>
<m.div
onPointerDown={stopPropagation}
tabIndex={-1}
initial="initial"
animate={controller}
variants={modalVariant}
transition={{
type: "spring",
mass: 0.4,
tension: 100,
friction: 1,
}}
exit="exit"
layout="size"
className={cn(
"bg-theme-background relative flex flex-col items-center overflow-hidden rounded-xl border p-8 pb-0",
variant === "drawer"
? "shadow-drawer-to-left h-full w-[60ch] max-w-full"
: "h-[80vh] w-[800px] max-w-full shadow lg:max-h-[calc(100vh-10rem)]",
)}
>
<div className="absolute right-2 top-2 z-10 flex items-center gap-2 text-[20px] opacity-80">
<ActionButton
tooltip={t("user_profile.toggle_item_style")}
onClick={() => {
const currentVisible = currentVisibleRef.current
const topOfCurrent = currentVisible?.values().next().value
setItemStyle((current) => (current === "loose" ? "compact" : "loose"))
if (!topOfCurrent) return
nextFrame(() => {
scrollerRef?.querySelector(`[data-feed-id="${topOfCurrent}"]`)?.scrollIntoView()
})
}}
>
<i
className={cn(
itemStyle === "loose" ? "i-mgc-list-check-3-cute-re" : "i-mgc-list-check-cute-re",
)}
/>
</ActionButton>
<ActionButton
tooltip={t("user_profile.share")}
onClick={() => {
if (!user.data) return
window.open(UrlBuilder.profile(user.data.handle ?? user.data.id))
}}
>
<i className="i-mgc-share-3-cute-re" />
</ActionButton>
<ActionButton tooltip={t("user_profile.close")} onClick={modal.dismiss}>
<i className="i-mgc-close-cute-re" />
</ActionButton>
</div>
{userInfo && (
<Fragment>
<div
className={cn(
"center f-motion-reduce:duration-700 m-12 mb-4 flex shrink-0 flex-col",
isHeaderSimple ? "mt-3 flex-row" : "flex-col",
)}
>
<Avatar
asChild
className={cn("aspect-square", isHeaderSimple ? "size-12" : "size-16")}
>
<m.span layout transition={{ duration: 0.35 }}>
<AvatarImage
className="animate-in fade-in-0 duration-200"
asChild
src={replaceImgUrlIfNeed(userInfo.avatar || undefined)}
>
<m.img layout transition={{ duration: 0.35 }} />
</AvatarImage>
<AvatarFallback>{userInfo.name?.slice(0, 2)}</AvatarFallback>
</m.span>
</Avatar>
<m.div
layout
transition={{ duration: 0.35 }}
className={cn(
"relative flex cursor-text select-text flex-col items-center",
isHeaderSimple ? "ml-8 items-start" : "",
)}
>
<m.div
className={cn(
"mb-1 flex items-center text-2xl font-bold",
isHeaderSimple ? "" : "mt-4",
)}
>
<m.h1 layout>{userInfo.name}</m.h1>
</m.div>
<m.div
className={cn(
"text-sm text-zinc-500",
userInfo.handle ? "visible" : "hidden select-none",
)}
layout
>
@{userInfo.handle}
</m.div>
<Button
buttonClassName={cn(
isHeaderSimple ? "absolute -right-full top-4 rounded-full p-2" : "mt-4",
)}
onClick={() => {
follow({
url: `rsshub://follow/profile/${userInfo.id}`,
isList: false,
})
}}
>
<FollowIcon className={clsx("size-3", !isHeaderSimple ? "mr-1" : "")} />
{isHeaderSimple ? "" : t("feed_form.follow")}
</Button>
</m.div>
</div>
<ScrollArea.ScrollArea
ref={setScrollerRef}
rootClassName="grow max-w-full px-5 w-full"
viewportClassName="[&>div]:space-y-4 pb-4"
>
<SubscriptionItems userId={userId} itemStyle={itemStyle} />
</ScrollArea.ScrollArea>
</Fragment>
)}
{!userInfo && <LoadingCircle size="large" className="center h-full" />}
</m.div>
</div>
)
}
@@ -1,6 +1,6 @@
import { withResponsiveSyncComponent } from "@follow/components/utils/selector.js"
import { UserProfileModalContent as UserProfileModalContentDesktop } from "./user-profile-modal.desktop"
import { UserProfileModalContent as UserProfileModalContentDesktop } from "./user-profile-modal.electron"
import { UserProfileModalContent as UserProfileModalContentMobile } from "./user-profile-modal.mobile"
import type { SubscriptionModalContentProps } from "./user-profile-modal.shared"
@@ -13,7 +13,7 @@ import { Input } from "@follow/components/ui/input/Input.js"
import { Label } from "@follow/components/ui/label/index.jsx"
import { Radio, RadioGroup } from "@follow/components/ui/radio-group/index.js"
import { Slider } from "@follow/components/ui/slider/index.js"
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import { zodResolver } from "@hookform/resolvers/zod"
import { useQuery } from "@tanstack/react-query"
import { useForm } from "react-hook-form"
@@ -10,10 +10,10 @@ import {
TableRow,
} from "@follow/components/ui/table/index.jsx"
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
import { UrlBuilder } from "@follow/utils/url-builder"
import { useTranslation } from "react-i18next"
import { useAuthQuery } from "~/hooks/common"
import { UrlBuilder } from "~/lib/url-builder"
import { FeedIcon } from "~/modules/feed/feed-icon"
import { Balance } from "~/modules/wallet/balance"
import { Queries } from "~/queries"
@@ -18,7 +18,6 @@ import {
TooltipTrigger,
} from "@follow/components/ui/tooltip/index.jsx"
import { views } from "@follow/constants"
import { UrlBuilder } from "@follow/utils/url-builder"
import { cn } from "@follow/utils/utils"
import { useMutation } from "@tanstack/react-query"
import { useMemo } from "react"
@@ -26,6 +25,7 @@ import { toast } from "sonner"
import { useCurrentModal, useModalStack } from "~/components/ui/modal/stacked/hooks"
import { useAuthQuery, useI18n } from "~/hooks/common"
import { UrlBuilder } from "~/lib/url-builder"
import { Balance } from "~/modules/wallet/balance"
import { Queries } from "~/queries"
import { listActions, useOwnedLists } from "~/store/list"
@@ -22,7 +22,6 @@ import {
} from "@follow/components/ui/table/index.jsx"
import { views } from "@follow/constants"
import type { FeedModel } from "@follow/models/types"
import { UrlBuilder } from "@follow/utils/url-builder"
import { isBizId } from "@follow/utils/utils"
import { zodResolver } from "@hookform/resolvers/zod"
import { useMutation } from "@tanstack/react-query"
@@ -38,6 +37,7 @@ import { useCurrentModal } from "~/components/ui/modal/stacked/hooks"
import { useAddFeedToFeedList, useRemoveFeedFromFeedList } from "~/hooks/biz/useFeedActions"
import { apiClient } from "~/lib/api-fetch"
import { createErrorToaster } from "~/lib/error-parser"
import { UrlBuilder } from "~/lib/url-builder"
import { FeedCertification } from "~/modules/feed/feed-certification"
import { FeedIcon } from "~/modules/feed/feed-icon"
import { ViewSelectorRadioGroup } from "~/modules/shared/ViewSelectorRadioGroup"
@@ -9,7 +9,6 @@ import {
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
import type { FeedViewType } from "@follow/constants"
import { nextFrame } from "@follow/utils/dom"
import { UrlBuilder } from "@follow/utils/url-builder"
import { cn, isKeyForMultiSelectPressed } from "@follow/utils/utils"
import dayjs from "dayjs"
import { memo, useCallback, useContext, useState } from "react"
@@ -22,6 +21,7 @@ import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry"
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
import { useContextMenu } from "~/hooks/common/useContextMenu"
import { getNewIssueUrl } from "~/lib/issues"
import { UrlBuilder } from "~/lib/url-builder"
import { FeedIcon } from "~/modules/feed/feed-icon"
import { FeedTitle } from "~/modules/feed/feed-title"
import { getPreferredTitle, useFeedById } from "~/store/feed"
@@ -1,262 +0,0 @@
import { useDraggable } from "@dnd-kit/core"
import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
import { cn, isKeyForMultiSelectPressed } from "@follow/utils/utils"
import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react"
import { useTranslation } from "react-i18next"
import Selecto from "react-selecto"
import { useEventListener } from "usehooks-ts"
import { useAuthQuery } from "~/hooks/common"
import { Queries } from "~/queries"
import {
useCategoryOpenStateByView,
useFeedsGroupedData,
useInboxesGroupedData,
useListsGroupedData,
} from "~/store/subscription"
import {
resetSelectedFeedIds,
setFeedAreaScrollProgressValue,
useSelectedFeedIdsState,
} from "./atom"
import { DraggableContext } from "./context"
import { EmptyFeedList, ListHeader, StarredItem } from "./FeedList.shared"
import { useShouldFreeUpSpace } from "./hook"
import { SortableFeedList, SortByAlphabeticalInbox, SortByAlphabeticalList } from "./sort-by"
const FeedListImpl = forwardRef<HTMLDivElement, { className?: string; view: number }>(
({ className, view }, ref) => {
const feedsData = useFeedsGroupedData(view)
const listsData = useListsGroupedData(view)
const inboxesData = useInboxesGroupedData(view)
const categoryOpenStateData = useCategoryOpenStateByView(view)
const hasData =
Object.keys(feedsData).length > 0 ||
Object.keys(listsData).length > 0 ||
Object.keys(inboxesData).length > 0
const { t } = useTranslation()
// Data prefetch
useAuthQuery(Queries.lists.list())
const hasListData = Object.keys(listsData).length > 0
const hasInboxData = Object.keys(inboxesData).length > 0
const scrollerRef = useRef<HTMLDivElement>(null)
const selectoRef = useRef<Selecto>(null)
const [selectedFeedIds, setSelectedFeedIds] = useSelectedFeedIdsState()
const [currentStartFeedId, setCurrentStartFeedId] = useState<string | null>(null)
useEffect(() => {
if (selectedFeedIds.length <= 1) {
setCurrentStartFeedId(null)
}
}, [selectedFeedIds])
const { attributes, listeners, setNodeRef, transform } = useDraggable({
id: "selected-feed",
disabled: selectedFeedIds.length === 0,
})
const style = useMemo(
() =>
transform
? ({
transform: `translate3d(${transform.x}px, ${transform.y}px, 0)`,
transitionDuration: "0",
transition: "none",
} as React.CSSProperties)
: undefined,
[transform],
)
const draggableContextValue = useMemo(
() => ({
attributes,
listeners,
style: {
...style,
willChange: "transform",
},
}),
[attributes, listeners, style],
)
useImperativeHandle(ref, () => scrollerRef.current!)
useEventListener(
"scroll",
() => {
const round = (num: number) => Math.round(num * 1e2) / 1e2
const getPositions = () => {
const el = scrollerRef.current
if (!el) return
return {
x: round(el.scrollLeft / (el.scrollWidth - el.clientWidth)),
y: round(el.scrollTop / (el.scrollHeight - el.clientHeight)),
}
}
const newScrollValues = getPositions()
if (!newScrollValues) return
const { y } = newScrollValues
setFeedAreaScrollProgressValue(y)
},
scrollerRef,
{ capture: false, passive: true },
)
const shouldFreeUpSpace = useShouldFreeUpSpace()
return (
<div className={cn(className, "font-medium")}>
<ListHeader view={view} />
<Selecto
className="!border-theme-accent-400 !bg-theme-accent-400/60"
ref={selectoRef}
rootContainer={document.body}
dragContainer={"#feeds-area"}
dragCondition={(e) => {
const inputEvent = e.inputEvent as MouseEvent
const target = inputEvent.target as HTMLElement
const closest = target.closest("[data-feed-id]") as HTMLElement | null
const dataFeedId = closest?.dataset.feedId
if (
dataFeedId &&
selectedFeedIds.includes(dataFeedId) &&
!isKeyForMultiSelectPressed(inputEvent)
)
return false
return true
}}
onDragStart={(e) => {
if (!isKeyForMultiSelectPressed(e.inputEvent as MouseEvent)) {
resetSelectedFeedIds()
}
}}
selectableTargets={["[data-feed-id]"]}
continueSelect
hitRate={1}
onSelect={(e) => {
const allChanged = [...e.added, ...e.removed]
.map((el) => el.dataset.feedId)
.filter((id) => id !== undefined)
const added = allChanged.filter((id) => !selectedFeedIds.includes(id))
const removed = allChanged.filter((id) => selectedFeedIds.includes(id))
if (isKeyForMultiSelectPressed(e.inputEvent as MouseEvent)) {
const allVisible = Array.from(document.querySelectorAll("[data-feed-id]")).map(
(el) => (el as HTMLElement).dataset.feedId,
)
const currentSelected =
added.length === 1 ? added[0] : removed.length === 1 ? removed[0] : null
const currentIndex = currentSelected ? allVisible.indexOf(currentSelected) : -1
// command or ctrl with click, update start feed id
if (!(e.inputEvent as MouseEvent).shiftKey && currentSelected) {
setCurrentStartFeedId(currentSelected)
}
// shift with click, select all between
if ((e.inputEvent as MouseEvent).shiftKey && currentSelected) {
const firstSelected = currentStartFeedId ?? selectedFeedIds[0]
if (firstSelected) {
const firstIndex = allVisible.indexOf(firstSelected)
const order =
firstIndex < currentIndex
? [firstIndex, currentIndex]
: [currentIndex, firstIndex]
const between = allVisible.slice(order[0], order[1]! + 1) as string[]
setSelectedFeedIds((prev) => {
// with intersection, we need to update selected ids as between
// otherwise, we need to add between to selected ids
const hasIntersection = between.slice(1, -1).some((id) => prev.includes(id))
return [
...(hasIntersection ? prev.filter((id) => between.includes(id)) : prev),
...between,
]
})
return
}
}
}
setSelectedFeedIds((prev) => {
return [...prev.filter((id) => !removed.includes(id)), ...added]
})
}}
scrollOptions={{
container: scrollerRef.current as HTMLElement,
throttleTime: 30,
threshold: 0,
}}
onScroll={(e) => {
scrollerRef.current?.scrollBy(e.direction[0]! * 10, e.direction[1]! * 10)
}}
/>
<ScrollArea.ScrollArea
ref={scrollerRef}
onScroll={() => {
selectoRef.current?.checkScroll()
}}
mask={false}
flex
viewportClassName={cn("!px-3", shouldFreeUpSpace && "!overflow-visible")}
rootClassName={cn("h-full", shouldFreeUpSpace && "overflow-visible")}
>
<StarredItem view={view} />
{hasListData && (
<>
<div className="text-theme-vibrancyFg mt-1 flex h-6 w-full shrink-0 items-center rounded-md px-2.5 text-xs font-semibold transition-colors">
{t("words.lists")}
</div>
<SortByAlphabeticalList view={view} data={listsData} />
</>
)}
{hasInboxData && (
<>
<div className="text-theme-vibrancyFg mt-1 flex h-6 w-full shrink-0 items-center rounded-md px-2.5 text-xs font-semibold transition-colors">
{t("words.inbox")}
</div>
<SortByAlphabeticalInbox view={view} data={inboxesData} />
</>
)}
{(hasListData || hasInboxData) && (
<div
className={cn(
"text-theme-vibrancyFg mb-1 flex h-6 w-full shrink-0 items-center rounded-md px-2.5 text-xs font-semibold transition-colors",
Object.keys(feedsData).length === 0 ? "mt-0" : "mt-1",
)}
>
{t("words.feeds")}
</div>
)}
<DraggableContext.Provider value={draggableContextValue}>
<div className="space-y-px" id="feeds-area" ref={setNodeRef}>
{hasData ? (
<SortableFeedList
view={view}
data={feedsData}
categoryOpenStateData={categoryOpenStateData}
/>
) : (
<EmptyFeedList />
)}
</div>
</DraggableContext.Provider>
</ScrollArea.ScrollArea>
</div>
)
},
)
FeedListImpl.displayName = "FeedListImpl"
export const FeedList = memo(FeedListImpl)
@@ -1 +1,262 @@
export { FeedList } from "./FeedList.desktop"
import { useDraggable } from "@dnd-kit/core"
import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
import { cn, isKeyForMultiSelectPressed } from "@follow/utils/utils"
import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react"
import { useTranslation } from "react-i18next"
import Selecto from "react-selecto"
import { useEventListener } from "usehooks-ts"
import { useAuthQuery } from "~/hooks/common"
import { Queries } from "~/queries"
import {
useCategoryOpenStateByView,
useFeedsGroupedData,
useInboxesGroupedData,
useListsGroupedData,
} from "~/store/subscription"
import {
resetSelectedFeedIds,
setFeedAreaScrollProgressValue,
useSelectedFeedIdsState,
} from "./atom"
import { DraggableContext } from "./context"
import { EmptyFeedList, ListHeader, StarredItem } from "./FeedList.shared"
import { useShouldFreeUpSpace } from "./hook"
import { SortableFeedList, SortByAlphabeticalInbox, SortByAlphabeticalList } from "./sort-by"
const FeedListImpl = forwardRef<HTMLDivElement, { className?: string; view: number }>(
({ className, view }, ref) => {
const feedsData = useFeedsGroupedData(view)
const listsData = useListsGroupedData(view)
const inboxesData = useInboxesGroupedData(view)
const categoryOpenStateData = useCategoryOpenStateByView(view)
const hasData =
Object.keys(feedsData).length > 0 ||
Object.keys(listsData).length > 0 ||
Object.keys(inboxesData).length > 0
const { t } = useTranslation()
// Data prefetch
useAuthQuery(Queries.lists.list())
const hasListData = Object.keys(listsData).length > 0
const hasInboxData = Object.keys(inboxesData).length > 0
const scrollerRef = useRef<HTMLDivElement>(null)
const selectoRef = useRef<Selecto>(null)
const [selectedFeedIds, setSelectedFeedIds] = useSelectedFeedIdsState()
const [currentStartFeedId, setCurrentStartFeedId] = useState<string | null>(null)
useEffect(() => {
if (selectedFeedIds.length <= 1) {
setCurrentStartFeedId(null)
}
}, [selectedFeedIds])
const { attributes, listeners, setNodeRef, transform } = useDraggable({
id: "selected-feed",
disabled: selectedFeedIds.length === 0,
})
const style = useMemo(
() =>
transform
? ({
transform: `translate3d(${transform.x}px, ${transform.y}px, 0)`,
transitionDuration: "0",
transition: "none",
} as React.CSSProperties)
: undefined,
[transform],
)
const draggableContextValue = useMemo(
() => ({
attributes,
listeners,
style: {
...style,
willChange: "transform",
},
}),
[attributes, listeners, style],
)
useImperativeHandle(ref, () => scrollerRef.current!)
useEventListener(
"scroll",
() => {
const round = (num: number) => Math.round(num * 1e2) / 1e2
const getPositions = () => {
const el = scrollerRef.current
if (!el) return
return {
x: round(el.scrollLeft / (el.scrollWidth - el.clientWidth)),
y: round(el.scrollTop / (el.scrollHeight - el.clientHeight)),
}
}
const newScrollValues = getPositions()
if (!newScrollValues) return
const { y } = newScrollValues
setFeedAreaScrollProgressValue(y)
},
scrollerRef,
{ capture: false, passive: true },
)
const shouldFreeUpSpace = useShouldFreeUpSpace()
return (
<div className={cn(className, "font-medium")}>
<ListHeader view={view} />
<Selecto
className="!border-theme-accent-400 !bg-theme-accent-400/60"
ref={selectoRef}
rootContainer={document.body}
dragContainer={"#feeds-area"}
dragCondition={(e) => {
const inputEvent = e.inputEvent as MouseEvent
const target = inputEvent.target as HTMLElement
const closest = target.closest("[data-feed-id]") as HTMLElement | null
const dataFeedId = closest?.dataset.feedId
if (
dataFeedId &&
selectedFeedIds.includes(dataFeedId) &&
!isKeyForMultiSelectPressed(inputEvent)
)
return false
return true
}}
onDragStart={(e) => {
if (!isKeyForMultiSelectPressed(e.inputEvent as MouseEvent)) {
resetSelectedFeedIds()
}
}}
selectableTargets={["[data-feed-id]"]}
continueSelect
hitRate={1}
onSelect={(e) => {
const allChanged = [...e.added, ...e.removed]
.map((el) => el.dataset.feedId)
.filter((id) => id !== undefined)
const added = allChanged.filter((id) => !selectedFeedIds.includes(id))
const removed = allChanged.filter((id) => selectedFeedIds.includes(id))
if (isKeyForMultiSelectPressed(e.inputEvent as MouseEvent)) {
const allVisible = Array.from(document.querySelectorAll("[data-feed-id]")).map(
(el) => (el as HTMLElement).dataset.feedId,
)
const currentSelected =
added.length === 1 ? added[0] : removed.length === 1 ? removed[0] : null
const currentIndex = currentSelected ? allVisible.indexOf(currentSelected) : -1
// command or ctrl with click, update start feed id
if (!(e.inputEvent as MouseEvent).shiftKey && currentSelected) {
setCurrentStartFeedId(currentSelected)
}
// shift with click, select all between
if ((e.inputEvent as MouseEvent).shiftKey && currentSelected) {
const firstSelected = currentStartFeedId ?? selectedFeedIds[0]
if (firstSelected) {
const firstIndex = allVisible.indexOf(firstSelected)
const order =
firstIndex < currentIndex
? [firstIndex, currentIndex]
: [currentIndex, firstIndex]
const between = allVisible.slice(order[0], order[1]! + 1) as string[]
setSelectedFeedIds((prev) => {
// with intersection, we need to update selected ids as between
// otherwise, we need to add between to selected ids
const hasIntersection = between.slice(1, -1).some((id) => prev.includes(id))
return [
...(hasIntersection ? prev.filter((id) => between.includes(id)) : prev),
...between,
]
})
return
}
}
}
setSelectedFeedIds((prev) => {
return [...prev.filter((id) => !removed.includes(id)), ...added]
})
}}
scrollOptions={{
container: scrollerRef.current as HTMLElement,
throttleTime: 30,
threshold: 0,
}}
onScroll={(e) => {
scrollerRef.current?.scrollBy(e.direction[0]! * 10, e.direction[1]! * 10)
}}
/>
<ScrollArea.ScrollArea
ref={scrollerRef}
onScroll={() => {
selectoRef.current?.checkScroll()
}}
mask={false}
flex
viewportClassName={cn("!px-3", shouldFreeUpSpace && "!overflow-visible")}
rootClassName={cn("h-full", shouldFreeUpSpace && "overflow-visible")}
>
<StarredItem view={view} />
{hasListData && (
<>
<div className="text-theme-vibrancyFg mt-1 flex h-6 w-full shrink-0 items-center rounded-md px-2.5 text-xs font-semibold transition-colors">
{t("words.lists")}
</div>
<SortByAlphabeticalList view={view} data={listsData} />
</>
)}
{hasInboxData && (
<>
<div className="text-theme-vibrancyFg mt-1 flex h-6 w-full shrink-0 items-center rounded-md px-2.5 text-xs font-semibold transition-colors">
{t("words.inbox")}
</div>
<SortByAlphabeticalInbox view={view} data={inboxesData} />
</>
)}
{(hasListData || hasInboxData) && (
<div
className={cn(
"text-theme-vibrancyFg mb-1 flex h-6 w-full shrink-0 items-center rounded-md px-2.5 text-xs font-semibold transition-colors",
Object.keys(feedsData).length === 0 ? "mt-0" : "mt-1",
)}
>
{t("words.feeds")}
</div>
)}
<DraggableContext.Provider value={draggableContextValue}>
<div className="space-y-px" id="feeds-area" ref={setNodeRef}>
{hasData ? (
<SortableFeedList
view={view}
data={feedsData}
categoryOpenStateData={categoryOpenStateData}
/>
) : (
<EmptyFeedList />
)}
</div>
</DraggableContext.Provider>
</ScrollArea.ScrollArea>
</div>
)
},
)
FeedListImpl.displayName = "FeedListImpl"
export const FeedList = memo(FeedListImpl)
@@ -1,6 +1,6 @@
import { withResponsiveSyncComponent } from "@follow/components/utils/selector.js"
import { FeedList as FeedListDesktop } from "./FeedList.desktop"
import { FeedList as FeedListDesktop } from "./FeedList.electron"
import { FeedList as FeedListMobile } from "./FeedList.mobile"
export const FeedList = withResponsiveSyncComponent(FeedListDesktop, FeedListMobile)
@@ -1,5 +1,5 @@
import { IN_ELECTRON } from "@follow/shared/constants"
import clsx from "clsx"
import { clsx } from "@follow/utils/utils"
export const feedColumnStyles = {
item: clsx(
@@ -8,7 +8,6 @@ import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
import type { FeedModel, Models } from "@follow/models"
import { stopPropagation } from "@follow/utils/dom"
import { UrlBuilder } from "@follow/utils/url-builder"
import { cn } from "@follow/utils/utils"
import { useQuery } from "@tanstack/react-query"
import type { FC } from "react"
@@ -18,6 +17,7 @@ import { getTrendingAggregates } from "~/api/trending"
import { DrawerModalLayout } from "~/components/ui/modal/stacked/custom-modal"
import { useCurrentModal, useModalStack } from "~/components/ui/modal/stacked/hooks"
import { useFollow } from "~/hooks/biz/useFollow"
import { UrlBuilder } from "~/lib/url-builder"
import { FeedIcon } from "~/modules/feed/feed-icon"
import { usePresentUserProfileModal } from "../profile/hooks"
@@ -1,274 +0,0 @@
import { MdiMeditation } from "@follow/components/icons/Meditation.js"
import { ActionButton } from "@follow/components/ui/button/index.js"
import { RootPortal } from "@follow/components/ui/portal/index.js"
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/EllipsisWithTooltip.js"
import { UserRole } from "@follow/constants"
import { useMeasure } from "@follow/hooks"
import { UrlBuilder } from "@follow/utils/url-builder"
import { cn } from "@follow/utils/utils"
import { repository } from "@pkg"
import type { FC } from "react"
import { forwardRef, memo, useCallback, useLayoutEffect, useState } from "react"
import { useTranslation } from "react-i18next"
import { useNavigate } from "react-router"
import rsshubLogoUrl from "~/assets/rsshub-icon.png?url"
import { useIsZenMode, useSetZenMode } from "~/atoms/settings/ui"
import { useUserRole } from "~/atoms/user"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "~/components/ui/dropdown-menu/dropdown-menu"
import { useSignOut } from "~/hooks/biz/useSignOut"
import { useAchievementModal } from "~/modules/achievement/hooks"
import { usePresentUserProfileModal } from "~/modules/profile/hooks"
import { useSettingModal } from "~/modules/settings/modal/use-setting-modal-hack"
import { useSession } from "~/queries/auth"
import { useWallet } from "~/queries/wallet"
import { useActivationModal } from "../activation"
import { ActivityPoints } from "../wallet/activity-points"
import { Level } from "../wallet/level"
import type { LoginProps } from "./LoginButton"
import { LoginButton } from "./LoginButton"
import { PowerButton } from "./ProfileButton.shared"
import { UserAvatar } from "./UserAvatar"
const rsshubLogo = new URL(rsshubLogoUrl, import.meta.url).href
export type ProfileButtonProps = LoginProps & {
animatedAvatar?: boolean
}
export const ProfileButton: FC<ProfileButtonProps> = memo((props) => {
const { status, session } = useSession()
const { user } = session || {}
const signOut = useSignOut()
const settingModalPresent = useSettingModal()
const presentUserProfile = usePresentUserProfileModal("dialog")
const presentAchievement = useAchievementModal()
const { t } = useTranslation()
const [dropdown, setDropdown] = useState(false)
const navigate = useNavigate()
const role = useUserRole()
const wallet = useWallet()
const { isLoading: isLoadingWallet } = wallet
const myWallet = wallet.data?.[0]
const presentActivationModal = useActivationModal()
const zenModeSetting = useIsZenMode()
const setZenMode = useSetZenMode()
if (status !== "authenticated") {
return <LoginButton {...props} />
}
return (
<>
<DropdownMenu onOpenChange={setDropdown}>
<DropdownMenuTrigger
asChild
className="focus-visible:bg-theme-item-hover !outline-none data-[state=open]:bg-transparent"
>
{props.animatedAvatar ? (
<TransitionAvatar stage={dropdown ? "zoom-in" : ""} />
) : (
<UserAvatar hideName className="size-6 p-0 [&_*]:border-0" />
)}
</DropdownMenuTrigger>
<DropdownMenuContent
className="min-w-[180px] overflow-visible px-1 pt-6"
side="bottom"
align="center"
>
<DropdownMenuLabel>
<div className="text-center leading-none">
<EllipsisHorizontalTextWithTooltip className="mx-auto max-w-[20ch] truncate text-lg">
{user?.name}
</EllipsisHorizontalTextWithTooltip>
{!!user?.handle && (
<a href={UrlBuilder.profile(user.handle)} target="_blank" className="block">
<EllipsisHorizontalTextWithTooltip className="mt-0.5 truncate text-xs font-medium text-zinc-500">
@{user.handle}
</EllipsisHorizontalTextWithTooltip>
</a>
)}
</div>
</DropdownMenuLabel>
<DropdownMenuItem
onClick={() => {
navigate("/power")
}}
>
<div className="flex w-full items-center justify-between gap-6 px-1.5 font-semibold">
<PowerButton isLoading={isLoadingWallet} myWallet={myWallet} />
<Level level={myWallet?.level?.level || 0} isLoading={isLoadingWallet} />
<ActivityPoints
className="text-sm"
points={myWallet?.level?.prevActivityPoints || 0}
isLoading={isLoadingWallet}
/>
</div>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
className="pl-3"
onClick={() => {
presentUserProfile(user?.id)
}}
icon={<i className="i-mgc-user-3-cute-re" />}
>
{t("user_button.profile")}
</DropdownMenuItem>
<DropdownMenuItem
className="pl-3"
onClick={() => {
if (role !== UserRole.Trial) {
presentAchievement()
} else {
presentActivationModal()
}
}}
icon={<i className="i-mgc-trophy-cute-re" />}
>
{t("user_button.achievement")}
</DropdownMenuItem>
<DropdownMenuSeparator />
{!zenModeSetting && (
<DropdownMenuItem
className="pl-3"
onClick={() => {
setZenMode(true)
}}
icon={<MdiMeditation className="size-4" />}
>
{t("user_button.zen_mode")}
</DropdownMenuItem>
)}
<DropdownMenuItem
className="pl-3"
onClick={() => {
navigate("/action")
}}
icon={<i className="i-mgc-magic-2-cute-re" />}
>
{t("words.actions")}
</DropdownMenuItem>
<DropdownMenuItem
className="pl-3"
onClick={() => {
navigate("/rsshub")
}}
icon={<img src={rsshubLogo} className="size-3 grayscale" />}
>
{t("words.rsshub")}
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
className="pl-3"
onClick={() => {
settingModalPresent()
}}
icon={<i className="i-mgc-settings-7-cute-re" />}
>
{t("user_button.preferences")}
</DropdownMenuItem>
<DropdownMenuSeparator />
{!window.electron && (
<>
<DropdownMenuItem
className="pl-3"
onClick={() => {
window.open(`${repository.url}/releases`)
}}
icon={<i className="i-mgc-download-2-cute-re" />}
>
{t("user_button.download_desktop_app")}
</DropdownMenuItem>
<DropdownMenuSeparator />
</>
)}
<DropdownMenuItem
className="pl-3"
onClick={signOut}
icon={<i className="i-mgc-exit-cute-re" />}
>
{t("user_button.log_out")}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</>
)
})
ProfileButton.displayName = "ProfileButton"
const TransitionAvatar = forwardRef<
HTMLButtonElement,
{
stage: "zoom-in" | ""
} & React.HTMLAttributes<HTMLButtonElement>
>(({ stage, ...props }, forwardRef) => {
const [ref, { x, y }, forceRefresh] = useMeasure()
const [avatarHovered, setAvatarHovered] = useState(false)
const zoomIn = stage === "zoom-in"
const [currentZoomIn, setCurrentZoomIn] = useState(false)
useLayoutEffect(() => {
if (zoomIn) {
setCurrentZoomIn(true)
}
}, [zoomIn])
return (
<>
<ActionButton
{...props}
ref={forwardRef}
onMouseEnter={useCallback(() => {
forceRefresh()
setAvatarHovered(true)
}, [forceRefresh])}
onMouseLeave={useCallback(() => {
setAvatarHovered(false)
}, [])}
>
<UserAvatar ref={ref} className="h-6 p-0 [&_*]:border-0" hideName />
</ActionButton>
{x !== 0 && y !== 0 && (avatarHovered || zoomIn || currentZoomIn) && (
<RootPortal>
<UserAvatar
style={{
left: x - (zoomIn ? 16 : 0),
top: y,
}}
className={cn(
"pointer-events-none fixed -bottom-6 p-0 duration-200 [&_*]:border-0",
"transform-gpu will-change-[left,top,height]",
zoomIn ? "z-[99] h-14" : "z-[-1] h-6",
)}
hideName
onTransitionEnd={() => {
if (!zoomIn && currentZoomIn) {
setCurrentZoomIn(false)
}
}}
/>
</RootPortal>
)}
</>
)
})
@@ -1 +1,274 @@
export { ProfileButton, type ProfileButtonProps } from "./ProfileButton.desktop"
import { MdiMeditation } from "@follow/components/icons/Meditation.js"
import { ActionButton } from "@follow/components/ui/button/index.js"
import { RootPortal } from "@follow/components/ui/portal/index.js"
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/EllipsisWithTooltip.js"
import { UserRole } from "@follow/constants"
import { useMeasure } from "@follow/hooks"
import { cn } from "@follow/utils/utils"
import { repository } from "@pkg"
import type { FC } from "react"
import { forwardRef, memo, useCallback, useLayoutEffect, useState } from "react"
import { useTranslation } from "react-i18next"
import { useNavigate } from "react-router"
import rsshubLogoUrl from "~/assets/rsshub-icon.png?url"
import { useIsZenMode, useSetZenMode } from "~/atoms/settings/ui"
import { useUserRole } from "~/atoms/user"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "~/components/ui/dropdown-menu/dropdown-menu"
import { useSignOut } from "~/hooks/biz/useSignOut"
import { UrlBuilder } from "~/lib/url-builder"
import { useAchievementModal } from "~/modules/achievement/hooks"
import { usePresentUserProfileModal } from "~/modules/profile/hooks"
import { useSettingModal } from "~/modules/settings/modal/use-setting-modal-hack"
import { useSession } from "~/queries/auth"
import { useWallet } from "~/queries/wallet"
import { useActivationModal } from "../activation"
import { ActivityPoints } from "../wallet/activity-points"
import { Level } from "../wallet/level"
import type { LoginProps } from "./LoginButton"
import { LoginButton } from "./LoginButton"
import { PowerButton } from "./ProfileButton.shared"
import { UserAvatar } from "./UserAvatar"
const rsshubLogo = new URL(rsshubLogoUrl, import.meta.url).href
export type ProfileButtonProps = LoginProps & {
animatedAvatar?: boolean
}
export const ProfileButton: FC<ProfileButtonProps> = memo((props) => {
const { status, session } = useSession()
const { user } = session || {}
const signOut = useSignOut()
const settingModalPresent = useSettingModal()
const presentUserProfile = usePresentUserProfileModal("dialog")
const presentAchievement = useAchievementModal()
const { t } = useTranslation()
const [dropdown, setDropdown] = useState(false)
const navigate = useNavigate()
const role = useUserRole()
const wallet = useWallet()
const { isLoading: isLoadingWallet } = wallet
const myWallet = wallet.data?.[0]
const presentActivationModal = useActivationModal()
const zenModeSetting = useIsZenMode()
const setZenMode = useSetZenMode()
if (status !== "authenticated") {
return <LoginButton {...props} />
}
return (
<>
<DropdownMenu onOpenChange={setDropdown}>
<DropdownMenuTrigger
asChild
className="focus-visible:bg-theme-item-hover !outline-none data-[state=open]:bg-transparent"
>
{props.animatedAvatar ? (
<TransitionAvatar stage={dropdown ? "zoom-in" : ""} />
) : (
<UserAvatar hideName className="size-6 p-0 [&_*]:border-0" />
)}
</DropdownMenuTrigger>
<DropdownMenuContent
className="min-w-[180px] overflow-visible px-1 pt-6"
side="bottom"
align="center"
>
<DropdownMenuLabel>
<div className="text-center leading-none">
<EllipsisHorizontalTextWithTooltip className="mx-auto max-w-[20ch] truncate text-lg">
{user?.name}
</EllipsisHorizontalTextWithTooltip>
{!!user?.handle && (
<a href={UrlBuilder.profile(user.handle)} target="_blank" className="block">
<EllipsisHorizontalTextWithTooltip className="mt-0.5 truncate text-xs font-medium text-zinc-500">
@{user.handle}
</EllipsisHorizontalTextWithTooltip>
</a>
)}
</div>
</DropdownMenuLabel>
<DropdownMenuItem
onClick={() => {
navigate("/power")
}}
>
<div className="flex w-full items-center justify-between gap-6 px-1.5 font-semibold">
<PowerButton isLoading={isLoadingWallet} myWallet={myWallet} />
<Level level={myWallet?.level?.level || 0} isLoading={isLoadingWallet} />
<ActivityPoints
className="text-sm"
points={myWallet?.level?.prevActivityPoints || 0}
isLoading={isLoadingWallet}
/>
</div>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
className="pl-3"
onClick={() => {
presentUserProfile(user?.id)
}}
icon={<i className="i-mgc-user-3-cute-re" />}
>
{t("user_button.profile")}
</DropdownMenuItem>
<DropdownMenuItem
className="pl-3"
onClick={() => {
if (role !== UserRole.Trial) {
presentAchievement()
} else {
presentActivationModal()
}
}}
icon={<i className="i-mgc-trophy-cute-re" />}
>
{t("user_button.achievement")}
</DropdownMenuItem>
<DropdownMenuSeparator />
{!zenModeSetting && (
<DropdownMenuItem
className="pl-3"
onClick={() => {
setZenMode(true)
}}
icon={<MdiMeditation className="size-4" />}
>
{t("user_button.zen_mode")}
</DropdownMenuItem>
)}
<DropdownMenuItem
className="pl-3"
onClick={() => {
navigate("/action")
}}
icon={<i className="i-mgc-magic-2-cute-re" />}
>
{t("words.actions")}
</DropdownMenuItem>
<DropdownMenuItem
className="pl-3"
onClick={() => {
navigate("/rsshub")
}}
icon={<img src={rsshubLogo} className="size-3 grayscale" />}
>
{t("words.rsshub")}
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
className="pl-3"
onClick={() => {
settingModalPresent()
}}
icon={<i className="i-mgc-settings-7-cute-re" />}
>
{t("user_button.preferences")}
</DropdownMenuItem>
<DropdownMenuSeparator />
{!window.electron && (
<>
<DropdownMenuItem
className="pl-3"
onClick={() => {
window.open(`${repository.url}/releases`)
}}
icon={<i className="i-mgc-download-2-cute-re" />}
>
{t("user_button.download_desktop_app")}
</DropdownMenuItem>
<DropdownMenuSeparator />
</>
)}
<DropdownMenuItem
className="pl-3"
onClick={signOut}
icon={<i className="i-mgc-exit-cute-re" />}
>
{t("user_button.log_out")}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</>
)
})
ProfileButton.displayName = "ProfileButton"
const TransitionAvatar = forwardRef<
HTMLButtonElement,
{
stage: "zoom-in" | ""
} & React.HTMLAttributes<HTMLButtonElement>
>(({ stage, ...props }, forwardRef) => {
const [ref, { x, y }, forceRefresh] = useMeasure()
const [avatarHovered, setAvatarHovered] = useState(false)
const zoomIn = stage === "zoom-in"
const [currentZoomIn, setCurrentZoomIn] = useState(false)
useLayoutEffect(() => {
if (zoomIn) {
setCurrentZoomIn(true)
}
}, [zoomIn])
return (
<>
<ActionButton
{...props}
ref={forwardRef}
onMouseEnter={useCallback(() => {
forceRefresh()
setAvatarHovered(true)
}, [forceRefresh])}
onMouseLeave={useCallback(() => {
setAvatarHovered(false)
}, [])}
>
<UserAvatar ref={ref} className="h-6 p-0 [&_*]:border-0" hideName />
</ActionButton>
{x !== 0 && y !== 0 && (avatarHovered || zoomIn || currentZoomIn) && (
<RootPortal>
<UserAvatar
style={{
left: x - (zoomIn ? 16 : 0),
top: y,
}}
className={cn(
"pointer-events-none fixed -bottom-6 p-0 duration-200 [&_*]:border-0",
"transform-gpu will-change-[left,top,height]",
zoomIn ? "z-[99] h-14" : "z-[-1] h-6",
)}
hideName
onTransitionEnd={() => {
if (!zoomIn && currentZoomIn) {
setCurrentZoomIn(false)
}
}}
/>
</RootPortal>
)}
</>
)
})
@@ -2,8 +2,7 @@ import { Divider } from "@follow/components/ui/divider/Divider.js"
import { PresentSheet } from "@follow/components/ui/sheet/Sheet.js"
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/EllipsisWithTooltip.js"
import { UserRole } from "@follow/constants"
import { UrlBuilder } from "@follow/utils/url-builder"
import clsx from "clsx"
import { clsx } from "@follow/utils/utils"
import type { FC } from "react"
import { useTranslation } from "react-i18next"
import { Link } from "react-router"
@@ -11,6 +10,7 @@ import { Link } from "react-router"
import rsshubLogoUrl from "~/assets/rsshub-icon.png?url"
import { useUserRole, useWhoami } from "~/atoms/user"
import { useSignOut } from "~/hooks/biz/useSignOut"
import { UrlBuilder } from "~/lib/url-builder"
import { useWallet } from "~/queries/wallet"
import { useAchievementModal } from "../achievement/hooks"
@@ -19,7 +19,7 @@ import { usePresentUserProfileModal } from "../profile/hooks"
import { useSettingModal } from "../settings/modal/use-setting-modal-hack"
import { ActivityPoints } from "../wallet/activity-points"
import { Level } from "../wallet/level"
import type { ProfileButtonProps } from "./ProfileButton.desktop"
import type { ProfileButtonProps } from "./ProfileButton.electron"
import { PowerButton } from "./ProfileButton.shared"
import { UserAvatar } from "./UserAvatar"
@@ -1,7 +1,7 @@
import { withResponsiveSyncComponent } from "@follow/components/utils/selector.js"
import { ProfileButton as ProfileButtonDesktop } from "./ProfileButton.desktop"
import type { ProfileButtonProps } from "./ProfileButton.electron"
import { ProfileButton as ProfileButtonDesktop } from "./ProfileButton.electron"
import { ProfileButton as ProfileButtonMobile } from "./ProfileButton.mobile"
export const ProfileButton = withResponsiveSyncComponent<ProfileButtonProps>(
@@ -1,9 +1,9 @@
import { Button } from "@follow/components/ui/button/index.js"
import { Divider } from "@follow/components/ui/divider/Divider.js"
import { Label } from "@follow/components/ui/label/index.js"
import { signOut } from "@follow/shared/auth"
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
import { signOut } from "~/lib/auth"
import { isInMAS } from "~/lib/utils"
import { AccountManagement } from "~/modules/profile/account-management"
import { EmailManagement } from "~/modules/profile/email-management"
@@ -1,5 +1,5 @@
import { registerGlobalContext } from "@follow/shared/bridge"
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import { useEffect, useLayoutEffect } from "react"
import { useTranslation } from "react-i18next"
import { toast } from "sonner"
@@ -3,11 +3,13 @@ import { EventProvider } from "@follow/components/providers/event-provider.js"
import { StableRouterProvider } from "@follow/components/providers/stable-router-provider.js"
import { Toaster } from "@follow/components/ui/toast/index.jsx"
import { IN_ELECTRON } from "@follow/shared/constants"
import { env } from "@follow/shared/env.desktop"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"
import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client"
import { Provider } from "jotai"
import type { FC, PropsWithChildren } from "react"
import { Suspense } from "react"
import { GoogleReCaptchaProvider } from "react-google-recaptcha-v3"
import { HotkeysProvider } from "react-hotkeys-hook"
import { HotKeyScopeMap } from "~/constants/hotkeys"
@@ -32,40 +34,42 @@ import { SettingSync } from "./setting-sync"
import { UserProvider } from "./user-provider"
export const RootProviders: FC<PropsWithChildren> = ({ children }) => (
<MotionProvider>
<PersistQueryClientProvider persistOptions={persistConfig} client={queryClient}>
<HotkeysProvider initiallyActiveScopes={HotKeyScopeMap.Home}>
<Provider store={jotaiStore}>
<I18nProvider>
<Toaster />
<EventProvider />
<GoogleReCaptchaProvider reCaptchaKey={env.VITE_RECAPTCHA_V3_SITE_KEY} useEnterprise={true}>
<MotionProvider>
<PersistQueryClientProvider persistOptions={persistConfig} client={queryClient}>
<HotkeysProvider initiallyActiveScopes={HotKeyScopeMap.Home}>
<Provider store={jotaiStore}>
<I18nProvider>
<Toaster />
<EventProvider />
<UserProvider />
<ServerConfigsProvider />
<UserProvider />
<ServerConfigsProvider />
<StableRouterProvider />
<SettingSync />
<FollowCommandManager />
{import.meta.env.DEV && <Devtools />}
<StableRouterProvider />
<SettingSync />
<FollowCommandManager />
{import.meta.env.DEV && <Devtools />}
{children}
{children}
<Suspense>
<LazyExtensionExposeProvider />
<LazyModalStackProvider />
<LazyContextMenuProvider />
<LazyLottieRenderContainer />
<LazyExternalJumpInProvider />
<LazyReloadPrompt />
{!window.__RN__ && <LazyPWAPrompt />}
</Suspense>
</I18nProvider>
</Provider>
</HotkeysProvider>
<Suspense>
<LazyExtensionExposeProvider />
<LazyModalStackProvider />
<LazyContextMenuProvider />
<LazyLottieRenderContainer />
<LazyExternalJumpInProvider />
<LazyReloadPrompt />
{!window.__RN__ && <LazyPWAPrompt />}
</Suspense>
</I18nProvider>
</Provider>
</HotkeysProvider>
<InvalidateQueryProvider />
</PersistQueryClientProvider>
</MotionProvider>
<InvalidateQueryProvider />
</PersistQueryClientProvider>
</MotionProvider>
</GoogleReCaptchaProvider>
)
const Devtools = () =>
@@ -1,4 +1,4 @@
import { env } from "@follow/shared/env"
import { env } from "@follow/shared/env.desktop"
import { initializeApp } from "firebase/app"
import { getMessaging, getToken } from "firebase/messaging"
@@ -1,8 +1,8 @@
import { getAccountInfo, getSession } from "@follow/shared/auth"
import type { AuthSession } from "@follow/shared/hono"
import type { FetchError } from "ofetch"
import { useAuthQuery } from "~/hooks/common"
import { getAccountInfo, getSession } from "~/lib/auth"
import { defineQuery } from "~/lib/defineQuery"
export const auth = {
@@ -1,7 +1,7 @@
import { getProviders } from "@follow/shared/auth"
import { useQuery } from "@tanstack/react-query"
import { apiClient } from "~/lib/api-fetch"
import { getProviders } from "~/lib/auth"
import { defineQuery } from "~/lib/defineQuery"
export const users = {
@@ -91,7 +91,8 @@ export const useClaimWalletDailyRewardMutation = () => {
return useMutation({
mutationKey: ["claimWalletDailyReward"],
mutationFn: () => apiClient.wallets.transactions.claim_daily.$post(),
mutationFn: ({ tokenV2, tokenV3 }: { tokenV2?: string; tokenV3?: string }) =>
apiClient.wallets.transactions.claim_daily.$post({ json: { t2: tokenV2, t3: tokenV3 } }),
async onError(err) {
toastFetchError(err)
},

Some files were not shown because too many files have changed in this diff Show More