refactor: upgrade react 19 and react native 0.79 (#3661)
* update Signed-off-by: Innei <tukon479@gmail.com> * chore: update Babel and Metro configurations - Added `unstable_transformImportMeta` option to Babel preset for improved JSX handling. - Disabled `unstable_enablePackageExports` in Metro configuration for better package resolution. Signed-off-by: Innei <tukon479@gmail.com> * chore: add react-native-ios-utilities patch and update dependencies - Introduced a patch for `react-native-ios-utilities` to enhance functionality. - Updated `expo`, `react-native`, and `react-native-reanimated` versions in the example app for improved compatibility. - Added `react-native-ios-utilities` to the project dependencies in `package.json`. Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * chore: auto-fix linting and formatting issues * refactor: improve route parameter handling and entry fetching logic - Updated `useRouteParams` to utilize `useReadonlyRoute` for better state management. - Enhanced `useEntriesByView` to separate remote and local entry fetching, improving data handling and error management. - Introduced debouncing for pagination in local entries and added toast notifications for error handling. - Cleaned up entry ID retrieval to ensure uniqueness and prevent duplicates. Signed-off-by: Innei <tukon479@gmail.com> * refactor: simplify Masonry component return statement - Updated the return statement in the Masonry component to use JSX syntax for better readability and consistency. Signed-off-by: Innei <tukon479@gmail.com> * refactor: update import from RootPortalProvider to RootPortalContext - Changed the import statement in Sheet.tsx to reflect the updated context provider name for better clarity and consistency in the codebase. Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * refactor: update ref types in component props - Changed ref prop types from React.RefObject to React.Ref for better type compatibility across various components, enhancing overall code consistency and maintainability. Signed-off-by: Innei <tukon479@gmail.com> * feat: add Xcode build server configuration and enhance desktop app routing - Introduced a new configuration file for the Xcode build server to streamline iOS builds. - Updated Vite configuration to include a new proxy route for sharing functionality. - Added a new Jotai atom for managing preview state in the application. - Removed deprecated error fallback component to clean up the codebase. - Implemented a new render style hook for consistent styling across components. - Enhanced entry column components with improved error handling and layout adjustments. - Updated various components to utilize the new render style and improved accessibility. Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * fix: ensure plugins array is initialized and update TypeScript configuration - Initialized the plugins array in the mobile app configuration to prevent potential runtime errors. - Updated TypeScript configuration to enhance module resolution and improve code organization with clearer path definitions. Signed-off-by: Innei <tukon479@gmail.com> * update lint Signed-off-by: Innei <tukon479@gmail.com> * refactor: update TypeScript types and improve component props - Added `skipLibCheck` to TypeScript configuration for faster builds. - Updated prop types in various components to allow for null values in refs, enhancing type safety. - Refactored several components to ensure better type compatibility and maintainability. Signed-off-by: Innei <tukon479@gmail.com> * refactor(mobile): improve layout handling in NavigationHeader component - Added console logs for debugging right and left widths. - Adjusted layout structure to ensure proper width handling for header elements. - Updated loading indicator positioning and visibility logic. Signed-off-by: Innei <tukon479@gmail.com> * refactor(mobile): update Pager and QRCode components to use forwardRef - Refactored Pager and QRCode components to directly export as functional components with forwardRef. - Updated type definitions to improve ref handling and ensure better type safety. - Simplified component structure for improved readability and maintainability. Signed-off-by: Innei <tukon479@gmail.com> * refactor(ui): enhance FAB components with functional component structure and improved type definitions - Converted FABBase and FABPortable to functional components using FC type for better type safety. - Updated props to include optional ref handling, enhancing flexibility in usage. - Simplified component structure for improved readability and maintainability. Signed-off-by: Innei <tukon479@gmail.com> * chore(deps): update react-native-ios-utilities patch and refine TypeScript configuration - Updated the patch for react-native-ios-utilities in pnpm-lock.yaml to reflect a new hash. - Enhanced TypeScript configuration in tsconfig.json by adding exclusion for node_modules and formatting paths for better readability. - Cleaned up the react-native-ios-utilities.patch by removing unused exports from the index file. Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> --------- Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -9,15 +9,6 @@ updates:
|
||||
timezone: Asia/Singapore
|
||||
target-branch: dev
|
||||
ignore:
|
||||
# Stuck by react 19
|
||||
- dependency-name: react
|
||||
versions: [">=19.0.0"]
|
||||
- dependency-name: react-dom
|
||||
versions: [">=19.0.0"]
|
||||
- dependency-name: "@types/react"
|
||||
versions: [">=19.0.0"]
|
||||
- dependency-name: "@types/react-dom"
|
||||
versions: [">=19.0.0"]
|
||||
- dependency-name: "@shopify/flash-list"
|
||||
versions: [">1.7.3"]
|
||||
|
||||
|
||||
+1
-3
@@ -21,6 +21,4 @@ vite.config.*.mjs
|
||||
|
||||
apps/desktop/src/renderer/dev-dist
|
||||
tsconfig.tsbuildinfo
|
||||
|
||||
apps/mobile/ios
|
||||
apps/mobile/android
|
||||
buildServer.json
|
||||
@@ -58,6 +58,7 @@
|
||||
"@types/node": "22.15.3",
|
||||
"electron": "35.1.5",
|
||||
"electron-devtools-installer": "4.0.0",
|
||||
"hono": "4.7.7"
|
||||
"hono": "4.7.7",
|
||||
"typescript": "catalog:"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
"@vite-pwa/assets-generator": "1.0.0",
|
||||
"fake-indexeddb": "6.0.0",
|
||||
"happy-dom": "17.4.4",
|
||||
"react-scan": "0.3.3"
|
||||
"react-scan": "0.3.3",
|
||||
"typescript": "catalog:"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { MotionProps, TargetAndTransition } from "motion/react"
|
||||
import type { TargetAndTransition } from "motion/react"
|
||||
import { m as M } from "motion/react"
|
||||
import { createElement, forwardRef } from "react"
|
||||
import { createElement } from "react"
|
||||
|
||||
import { useReduceMotion } from "~/hooks/biz/useReduceMotion"
|
||||
|
||||
@@ -12,7 +12,7 @@ export const m: typeof M = new Proxy(M, {
|
||||
if (cacheMap.has(p)) {
|
||||
return cacheMap.get(p)
|
||||
}
|
||||
const MotionComponent = forwardRef((props: MotionProps, ref) => {
|
||||
const MotionComponent = ({ ref, ...props }) => {
|
||||
const shouldReduceMotion = useReduceMotion()
|
||||
const nextProps = { ...props }
|
||||
if (shouldReduceMotion) {
|
||||
@@ -34,7 +34,7 @@ export const m: typeof M = new Proxy(M, {
|
||||
}
|
||||
|
||||
return createElement(Component, { ...nextProps, ref })
|
||||
})
|
||||
}
|
||||
|
||||
cacheMap.set(p, MotionComponent)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { MemoedDangerousHTMLStyle } from "@follow/components/common/MemoedDanger
|
||||
import { useIsDark } from "@follow/hooks"
|
||||
import { nanoid } from "nanoid"
|
||||
import type { FC, PropsWithChildren, ReactNode } from "react"
|
||||
import { createContext, createElement, useContext, useLayoutEffect, useMemo, useState } from "react"
|
||||
import { createContext, createElement, use, useLayoutEffect, useMemo, useState } from "react"
|
||||
import root from "react-shadow"
|
||||
|
||||
import { useUISettingKeys } from "~/atoms/settings/ui"
|
||||
@@ -90,7 +90,7 @@ export const ShadowDOM: FC<
|
||||
return (
|
||||
// @ts-expect-error
|
||||
<root.div {...rest}>
|
||||
<ShadowDOMContext.Provider value={true}>
|
||||
<ShadowDOMContext value={true}>
|
||||
<div
|
||||
style={useMemo(
|
||||
() => ({
|
||||
@@ -107,12 +107,12 @@ export const ShadowDOM: FC<
|
||||
{injectHostStyles ? stylesElements : null}
|
||||
{props.children}
|
||||
</div>
|
||||
</ShadowDOMContext.Provider>
|
||||
</ShadowDOMContext>
|
||||
</root.div>
|
||||
)
|
||||
}
|
||||
|
||||
ShadowDOM.useIsShadowDOM = () => useContext(ShadowDOMContext)
|
||||
ShadowDOM.useIsShadowDOM = () => use(ShadowDOMContext)
|
||||
|
||||
const cacheCssTextMap = {} as Record<string, string>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { cn } from "@follow/utils/utils"
|
||||
import { Combobox, ComboboxInput, ComboboxOption, ComboboxOptions } from "@headlessui/react"
|
||||
import Fuse from "fuse.js"
|
||||
import { AnimatePresence, m } from "motion/react"
|
||||
import { forwardRef, Fragment, memo, useCallback, useEffect, useState } from "react"
|
||||
import { Fragment, memo, useCallback, useEffect, useState } from "react"
|
||||
|
||||
export type Suggestion = {
|
||||
name: string
|
||||
@@ -26,102 +26,97 @@ export interface AutocompleteProps extends React.InputHTMLAttributes<HTMLInputEl
|
||||
|
||||
const defaultSearchKeys = ["name", "value"]
|
||||
const defaultRenderSuggestion = (suggestion: any) => suggestion?.name
|
||||
export const Autocomplete = forwardRef<HTMLInputElement, AutocompleteProps>(
|
||||
(
|
||||
{
|
||||
suggestions,
|
||||
renderSuggestion = defaultRenderSuggestion,
|
||||
onSuggestionSelected,
|
||||
maxHeight,
|
||||
export const Autocomplete = ({
|
||||
ref: forwardedRef,
|
||||
suggestions,
|
||||
renderSuggestion = defaultRenderSuggestion,
|
||||
onSuggestionSelected,
|
||||
maxHeight,
|
||||
value,
|
||||
searchKeys = defaultSearchKeys,
|
||||
defaultValue,
|
||||
...inputProps
|
||||
}: AutocompleteProps & { ref?: React.Ref<HTMLInputElement | null> }) => {
|
||||
const [selectedOptions, setSelectedOptions] = useState<NoInfer<Suggestion> | null>(
|
||||
() => suggestions.find((suggestion) => suggestion.value === value) || null,
|
||||
)
|
||||
|
||||
value,
|
||||
searchKeys = defaultSearchKeys,
|
||||
defaultValue,
|
||||
...inputProps
|
||||
},
|
||||
forwardedRef,
|
||||
) => {
|
||||
const [selectedOptions, setSelectedOptions] = useState<NoInfer<Suggestion> | null>(
|
||||
() => suggestions.find((suggestion) => suggestion.value === value) || null,
|
||||
)
|
||||
const [filterableSuggestions, setFilterableSuggestions] = useState(suggestions)
|
||||
|
||||
const [filterableSuggestions, setFilterableSuggestions] = useState(suggestions)
|
||||
const doFilter = useCallback(() => {
|
||||
const fuse = new Fuse(suggestions, {
|
||||
keys: searchKeys,
|
||||
})
|
||||
|
||||
const doFilter = useCallback(() => {
|
||||
const fuse = new Fuse(suggestions, {
|
||||
keys: searchKeys,
|
||||
})
|
||||
const trimInputValue = (value as string)?.trim()
|
||||
|
||||
const trimInputValue = (value as string)?.trim()
|
||||
if (!trimInputValue) return setFilterableSuggestions(suggestions)
|
||||
|
||||
if (!trimInputValue) return setFilterableSuggestions(suggestions)
|
||||
const results = fuse.search(trimInputValue)
|
||||
|
||||
const results = fuse.search(trimInputValue)
|
||||
setFilterableSuggestions(results.map((result) => result.item))
|
||||
}, [suggestions, value, searchKeys])
|
||||
useEffect(() => {
|
||||
doFilter()
|
||||
}, [doFilter])
|
||||
|
||||
setFilterableSuggestions(results.map((result) => result.item))
|
||||
}, [suggestions, value, searchKeys])
|
||||
useEffect(() => {
|
||||
doFilter()
|
||||
}, [doFilter])
|
||||
|
||||
const zIndex = useCorrectZIndex(9)
|
||||
return (
|
||||
<Combobox
|
||||
immediate
|
||||
value={selectedOptions}
|
||||
onChange={(suggestion) => {
|
||||
setSelectedOptions(suggestion)
|
||||
onSuggestionSelected(suggestion)
|
||||
}}
|
||||
>
|
||||
{({ open }) => {
|
||||
return (
|
||||
<Fragment>
|
||||
<ComboboxInput
|
||||
ref={forwardedRef}
|
||||
as={Input}
|
||||
autoComplete="off"
|
||||
aria-label="Select Category"
|
||||
displayValue={renderSuggestion}
|
||||
value={value}
|
||||
{...inputProps}
|
||||
/>
|
||||
<AnimatePresence>
|
||||
{open && filterableSuggestions.length > 0 && (
|
||||
<RootPortal>
|
||||
<ComboboxOptions
|
||||
portal
|
||||
static
|
||||
as={m.div}
|
||||
initial={{ opacity: 0, scale: 0.98 }}
|
||||
animate={{ opacity: 1, scale: 1 }}
|
||||
exit={{ opacity: 0, scale: 0.98 }}
|
||||
anchor="bottom"
|
||||
style={{ zIndex }}
|
||||
onWheel={stopPropagation}
|
||||
className={cn(
|
||||
"bg-material-medium backdrop-blur-background text-text pointer-events-auto",
|
||||
"shadow-context-menu min-w-32 overflow-hidden rounded-[6px] border p-1",
|
||||
"motion-scale-in-75 motion-duration-150 text-body lg:animate-none",
|
||||
"w-[var(--input-width)] empty:invisible",
|
||||
)}
|
||||
>
|
||||
<div style={{ maxHeight }}>
|
||||
{filterableSuggestions.map((suggestion) => (
|
||||
<MemoizedComboboxOption key={suggestion.value} suggestion={suggestion} />
|
||||
))}
|
||||
</div>
|
||||
</ComboboxOptions>
|
||||
</RootPortal>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</Fragment>
|
||||
)
|
||||
}}
|
||||
</Combobox>
|
||||
)
|
||||
},
|
||||
)
|
||||
const zIndex = useCorrectZIndex(9)
|
||||
return (
|
||||
<Combobox
|
||||
immediate
|
||||
value={selectedOptions}
|
||||
onChange={(suggestion) => {
|
||||
setSelectedOptions(suggestion)
|
||||
onSuggestionSelected(suggestion)
|
||||
}}
|
||||
>
|
||||
{({ open }) => {
|
||||
return (
|
||||
<Fragment>
|
||||
<ComboboxInput
|
||||
ref={forwardedRef}
|
||||
as={Input}
|
||||
autoComplete="off"
|
||||
aria-label="Select Category"
|
||||
displayValue={renderSuggestion}
|
||||
value={value}
|
||||
{...inputProps}
|
||||
/>
|
||||
<AnimatePresence>
|
||||
{open && filterableSuggestions.length > 0 && (
|
||||
<RootPortal>
|
||||
<ComboboxOptions
|
||||
portal
|
||||
static
|
||||
as={m.div}
|
||||
initial={{ opacity: 0, scale: 0.98 }}
|
||||
animate={{ opacity: 1, scale: 1 }}
|
||||
exit={{ opacity: 0, scale: 0.98 }}
|
||||
anchor="bottom"
|
||||
style={{ zIndex }}
|
||||
onWheel={stopPropagation}
|
||||
className={cn(
|
||||
"bg-material-medium backdrop-blur-background text-text pointer-events-auto",
|
||||
"shadow-context-menu min-w-32 overflow-hidden rounded-[6px] border p-1",
|
||||
"motion-scale-in-75 motion-duration-150 text-body lg:animate-none",
|
||||
"w-[var(--input-width)] empty:invisible",
|
||||
)}
|
||||
>
|
||||
<div style={{ maxHeight }}>
|
||||
{filterableSuggestions.map((suggestion) => (
|
||||
<MemoizedComboboxOption key={suggestion.value} suggestion={suggestion} />
|
||||
))}
|
||||
</div>
|
||||
</ComboboxOptions>
|
||||
</RootPortal>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</Fragment>
|
||||
)
|
||||
}}
|
||||
</Combobox>
|
||||
)
|
||||
}
|
||||
|
||||
const MemoizedComboboxOption = memo(({ suggestion }: { suggestion: Suggestion }) => {
|
||||
return (
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { ActionButtonProps } from "@follow/components/ui/button/action-button.js"
|
||||
import { ActionButton } from "@follow/components/ui/button/action-button.js"
|
||||
import { forwardRef } from "react"
|
||||
|
||||
import { useCommand } from "~/modules/command/hooks/use-command"
|
||||
import type { FollowCommandId } from "~/modules/command/types"
|
||||
@@ -9,21 +8,22 @@ export interface CommandActionButtonProps extends ActionButtonProps {
|
||||
commandId: FollowCommandId
|
||||
onClick: () => void
|
||||
}
|
||||
export const CommandActionButton = forwardRef<HTMLButtonElement, CommandActionButtonProps>(
|
||||
(props, ref) => {
|
||||
const { commandId, ...rest } = props
|
||||
const command = useCommand(commandId)
|
||||
if (!command) return null
|
||||
const { icon, label } = command
|
||||
export const CommandActionButton = ({
|
||||
ref,
|
||||
...props
|
||||
}: CommandActionButtonProps & { ref?: React.Ref<HTMLButtonElement | null> }) => {
|
||||
const { commandId, ...rest } = props
|
||||
const command = useCommand(commandId)
|
||||
if (!command) return null
|
||||
const { icon, label } = command
|
||||
|
||||
return (
|
||||
<ActionButton
|
||||
ref={ref}
|
||||
icon={icon}
|
||||
tooltip={label.title}
|
||||
tooltipDescription={label.description}
|
||||
{...rest}
|
||||
/>
|
||||
)
|
||||
},
|
||||
)
|
||||
return (
|
||||
<ActionButton
|
||||
ref={ref}
|
||||
icon={icon}
|
||||
tooltip={label.title}
|
||||
tooltipDescription={label.description}
|
||||
{...rest}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export const CopyButton: Component<{
|
||||
style?: React.CSSProperties
|
||||
variant?: "solid" | "outline" | "ghost"
|
||||
}> = ({ value, className, style, variant = "solid" }) => {
|
||||
const copiedTimerRef = useRef<any>()
|
||||
const copiedTimerRef = useRef<any>(undefined)
|
||||
const handleCopy = useCallback(() => {
|
||||
navigator.clipboard.writeText(value)
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ export const AnimatedCommandButton: FC<AnimatedCommandButtonProps & HTMLMotionPr
|
||||
...props
|
||||
}) => {
|
||||
const [pressed, setPressed] = useState(false)
|
||||
const timerRef = useRef<any>()
|
||||
const timerRef = useRef<any>(undefined)
|
||||
|
||||
return (
|
||||
<MotionButtonBase
|
||||
|
||||
@@ -41,7 +41,7 @@ export const CollapseGroup: FC<
|
||||
onOpenChange?.(state)
|
||||
})
|
||||
}, [defaultOpenId])
|
||||
return <CollaspeContext.Provider value={ctxValue}>{children}</CollaspeContext.Provider>
|
||||
return <CollaspeContext value={ctxValue}>{children}</CollaspeContext>
|
||||
}
|
||||
|
||||
export const Collapse: Component<CollapseProps> = ({ onOpenChange, ...props }) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { PrimitiveAtom } from "jotai"
|
||||
import { createContext, useContext } from "react"
|
||||
import { createContext, use } from "react"
|
||||
|
||||
export interface CollapseContextValue {
|
||||
currentOpenCollapseIdAtom: PrimitiveAtom<string | null>
|
||||
@@ -7,7 +7,7 @@ export interface CollapseContextValue {
|
||||
}
|
||||
export const CollaspeContext = createContext<CollapseContextValue>(null!)
|
||||
export const useCollapseContext = () => {
|
||||
const ctx = useContext(CollaspeContext)
|
||||
const ctx = use(CollaspeContext)
|
||||
if (!ctx) {
|
||||
throw new Error("CollapseContext not found")
|
||||
}
|
||||
|
||||
@@ -10,12 +10,15 @@ const ContextMenuGroup = ContextMenuPrimitive.Group
|
||||
const ContextMenuSub = ContextMenuPrimitive.Sub
|
||||
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup
|
||||
|
||||
const ContextMenuSubTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
|
||||
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
|
||||
inset?: boolean
|
||||
}
|
||||
>(({ className, inset, children, ...props }, ref) => (
|
||||
const ContextMenuSubTrigger = ({
|
||||
ref,
|
||||
className,
|
||||
inset,
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
|
||||
inset?: boolean
|
||||
} & { ref?: React.Ref<React.ElementRef<typeof ContextMenuPrimitive.SubTrigger> | null> }) => (
|
||||
<ContextMenuPrimitive.SubTrigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
@@ -30,13 +33,16 @@ const ContextMenuSubTrigger = React.forwardRef<
|
||||
{children}
|
||||
<i className="i-mingcute-right-line -mr-1 ml-auto size-3.5" />
|
||||
</ContextMenuPrimitive.SubTrigger>
|
||||
))
|
||||
)
|
||||
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName
|
||||
|
||||
const ContextMenuSubContent = React.forwardRef<
|
||||
React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
|
||||
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>
|
||||
>(({ className, ...props }, ref) => (
|
||||
const ContextMenuSubContent = ({
|
||||
ref,
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent> & {
|
||||
ref?: React.Ref<React.ElementRef<typeof ContextMenuPrimitive.SubContent> | null>
|
||||
}) => (
|
||||
<RootPortal>
|
||||
<ContextMenuPrimitive.SubContent
|
||||
ref={ref}
|
||||
@@ -51,13 +57,16 @@ const ContextMenuSubContent = React.forwardRef<
|
||||
{...props}
|
||||
/>
|
||||
</RootPortal>
|
||||
))
|
||||
)
|
||||
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName
|
||||
|
||||
const ContextMenuContent = React.forwardRef<
|
||||
React.ElementRef<typeof ContextMenuPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>
|
||||
>(({ className, ...props }, ref) => (
|
||||
const ContextMenuContent = ({
|
||||
ref,
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content> & {
|
||||
ref?: React.Ref<React.ElementRef<typeof ContextMenuPrimitive.Content> | null>
|
||||
}) => (
|
||||
<RootPortal>
|
||||
<ContextMenuPrimitive.Content
|
||||
ref={ref}
|
||||
@@ -69,15 +78,17 @@ const ContextMenuContent = React.forwardRef<
|
||||
{...props}
|
||||
/>
|
||||
</RootPortal>
|
||||
))
|
||||
)
|
||||
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName
|
||||
|
||||
const ContextMenuItem = React.forwardRef<
|
||||
React.ElementRef<typeof ContextMenuPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
|
||||
inset?: boolean
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
const ContextMenuItem = ({
|
||||
ref,
|
||||
className,
|
||||
inset,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
|
||||
inset?: boolean
|
||||
} & { ref?: React.Ref<React.ElementRef<typeof ContextMenuPrimitive.Item> | null> }) => (
|
||||
<ContextMenuPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
@@ -89,13 +100,18 @@ const ContextMenuItem = React.forwardRef<
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
)
|
||||
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName
|
||||
|
||||
const ContextMenuCheckboxItem = React.forwardRef<
|
||||
React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
|
||||
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>
|
||||
>(({ className, children, checked, ...props }, ref) => (
|
||||
const ContextMenuCheckboxItem = ({
|
||||
ref,
|
||||
className,
|
||||
children,
|
||||
checked,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem> & {
|
||||
ref?: React.Ref<React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem> | null>
|
||||
}) => (
|
||||
<ContextMenuPrimitive.CheckboxItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
@@ -114,27 +130,31 @@ const ContextMenuCheckboxItem = React.forwardRef<
|
||||
</span>
|
||||
{children}
|
||||
</ContextMenuPrimitive.CheckboxItem>
|
||||
))
|
||||
)
|
||||
ContextMenuCheckboxItem.displayName = ContextMenuPrimitive.CheckboxItem.displayName
|
||||
|
||||
const ContextMenuLabel = React.forwardRef<
|
||||
React.ElementRef<typeof ContextMenuPrimitive.Label>,
|
||||
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {
|
||||
inset?: boolean
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
const ContextMenuLabel = ({
|
||||
ref,
|
||||
className,
|
||||
inset,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {
|
||||
inset?: boolean
|
||||
} & { ref?: React.Ref<React.ElementRef<typeof ContextMenuPrimitive.Label> | null> }) => (
|
||||
<ContextMenuPrimitive.Label
|
||||
ref={ref}
|
||||
className={cn("text-text px-2 py-1.5 font-semibold", inset && "pl-8", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
)
|
||||
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName
|
||||
|
||||
const ContextMenuSeparator = React.forwardRef<
|
||||
React.ElementRef<typeof ContextMenuPrimitive.Separator>,
|
||||
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>
|
||||
>(({ ...props }, ref) => (
|
||||
const ContextMenuSeparator = ({
|
||||
ref,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator> & {
|
||||
ref?: React.Ref<React.ElementRef<typeof ContextMenuPrimitive.Separator> | null>
|
||||
}) => (
|
||||
<ContextMenuPrimitive.Separator
|
||||
className="backdrop-blur-background mx-2 my-1 h-px"
|
||||
asChild
|
||||
@@ -143,7 +163,7 @@ const ContextMenuSeparator = React.forwardRef<
|
||||
>
|
||||
<Divider />
|
||||
</ContextMenuPrimitive.Separator>
|
||||
))
|
||||
)
|
||||
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName
|
||||
|
||||
export {
|
||||
|
||||
@@ -31,12 +31,17 @@ const DropdownMenuPortal = DropdownMenuPrimitive.Portal
|
||||
const DropdownMenuSub = DropdownMenuPrimitive.Sub
|
||||
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
|
||||
|
||||
const DropdownMenuSubTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
||||
inset?: boolean
|
||||
}
|
||||
>(({ className, inset, children, ...props }, ref) => (
|
||||
const DropdownMenuSubTrigger = ({
|
||||
ref,
|
||||
className,
|
||||
inset,
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
||||
inset?: boolean
|
||||
} & {
|
||||
ref?: React.Ref<React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger> | null>
|
||||
}) => (
|
||||
<DropdownMenuPrimitive.SubTrigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
@@ -51,13 +56,16 @@ const DropdownMenuSubTrigger = React.forwardRef<
|
||||
{children}
|
||||
<i className="i-mingcute-right-line -mr-1 ml-auto size-3.5" />
|
||||
</DropdownMenuPrimitive.SubTrigger>
|
||||
))
|
||||
)
|
||||
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName
|
||||
|
||||
const DropdownMenuSubContent = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
||||
>(({ className, ...props }, ref) => (
|
||||
const DropdownMenuSubContent = ({
|
||||
ref,
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent> & {
|
||||
ref?: React.Ref<React.ElementRef<typeof DropdownMenuPrimitive.SubContent> | null>
|
||||
}) => (
|
||||
<RootPortal>
|
||||
<DropdownMenuPrimitive.SubContent
|
||||
ref={ref}
|
||||
@@ -72,13 +80,17 @@ const DropdownMenuSubContent = React.forwardRef<
|
||||
{...props}
|
||||
/>
|
||||
</RootPortal>
|
||||
))
|
||||
)
|
||||
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName
|
||||
|
||||
const DropdownMenuContent = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
||||
>(({ className, sideOffset = 4, ...props }, ref) => {
|
||||
const DropdownMenuContent = ({
|
||||
ref,
|
||||
className,
|
||||
sideOffset = 4,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> & {
|
||||
ref?: React.Ref<React.ElementRef<typeof DropdownMenuPrimitive.Content> | null>
|
||||
}) => {
|
||||
return (
|
||||
<RootPortal>
|
||||
<DropdownMenuPrimitive.Content
|
||||
@@ -93,18 +105,23 @@ const DropdownMenuContent = React.forwardRef<
|
||||
/>
|
||||
</RootPortal>
|
||||
)
|
||||
})
|
||||
}
|
||||
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
|
||||
|
||||
const DropdownMenuItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
||||
inset?: boolean
|
||||
icon?: React.ReactNode | ((props?: { isActive?: boolean }) => React.ReactNode)
|
||||
active?: boolean
|
||||
highlightColor?: "accent" | "gray"
|
||||
}
|
||||
>(({ className, inset, icon, active, highlightColor = "accent", ...props }, ref) => (
|
||||
const DropdownMenuItem = ({
|
||||
ref,
|
||||
className,
|
||||
inset,
|
||||
icon,
|
||||
active,
|
||||
highlightColor = "accent",
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
||||
inset?: boolean
|
||||
icon?: React.ReactNode | ((props?: { isActive?: boolean }) => React.ReactNode)
|
||||
active?: boolean
|
||||
highlightColor?: "accent" | "gray"
|
||||
} & { ref?: React.Ref<React.ElementRef<typeof DropdownMenuPrimitive.Item> | null> }) => (
|
||||
<DropdownMenuPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
@@ -129,13 +146,18 @@ const DropdownMenuItem = React.forwardRef<
|
||||
{/* Justify Fill */}
|
||||
{!!icon && <span className="ml-1.5 size-4" />}
|
||||
</DropdownMenuPrimitive.Item>
|
||||
))
|
||||
)
|
||||
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
|
||||
|
||||
const DropdownMenuCheckboxItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
||||
>(({ className, children, checked, ...props }, ref) => (
|
||||
const DropdownMenuCheckboxItem = ({
|
||||
ref,
|
||||
className,
|
||||
children,
|
||||
checked,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem> & {
|
||||
ref?: React.Ref<React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem> | null>
|
||||
}) => (
|
||||
<DropdownMenuPrimitive.CheckboxItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
@@ -154,27 +176,31 @@ const DropdownMenuCheckboxItem = React.forwardRef<
|
||||
</span>
|
||||
{children}
|
||||
</DropdownMenuPrimitive.CheckboxItem>
|
||||
))
|
||||
)
|
||||
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName
|
||||
|
||||
const DropdownMenuLabel = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
||||
inset?: boolean
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
const DropdownMenuLabel = ({
|
||||
ref,
|
||||
className,
|
||||
inset,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
||||
inset?: boolean
|
||||
} & { ref?: React.Ref<React.ElementRef<typeof DropdownMenuPrimitive.Label> | null> }) => (
|
||||
<DropdownMenuPrimitive.Label
|
||||
ref={ref}
|
||||
className={cn("text-text px-2 py-1.5 font-semibold", inset && "pl-8", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
)
|
||||
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
|
||||
|
||||
const DropdownMenuSeparator = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
||||
>(({ ...props }, ref) => (
|
||||
const DropdownMenuSeparator = ({
|
||||
ref,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator> & {
|
||||
ref?: React.Ref<React.ElementRef<typeof DropdownMenuPrimitive.Separator> | null>
|
||||
}) => (
|
||||
<DropdownMenuPrimitive.Separator
|
||||
className="backdrop-blur-background mx-2 my-1 h-px"
|
||||
asChild
|
||||
@@ -183,7 +209,7 @@ const DropdownMenuSeparator = React.forwardRef<
|
||||
>
|
||||
<Divider />
|
||||
</DropdownMenuPrimitive.Separator>
|
||||
))
|
||||
)
|
||||
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
|
||||
|
||||
const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => (
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { RootPortal } from "@follow/components/ui/portal/index.jsx"
|
||||
import { useTypeScriptHappyCallback } from "@follow/hooks"
|
||||
import { clsx, cn } from "@follow/utils/utils"
|
||||
import { typescriptHappyForwardRef } from "foxact/typescript-happy-forward-ref"
|
||||
import { atom, useAtomValue } from "jotai"
|
||||
import type { HTMLMotionProps } from "motion/react"
|
||||
import { AnimatePresence } from "motion/react"
|
||||
import type * as React from "react"
|
||||
import type { JSX, PropsWithChildren, ReactNode } from "react"
|
||||
import type { FC, JSX, PropsWithChildren, ReactNode } from "react"
|
||||
import { useId } from "react"
|
||||
|
||||
import { m } from "~/components/common/Motion"
|
||||
@@ -20,77 +19,73 @@ export interface FABConfig {
|
||||
onClick: () => void
|
||||
}
|
||||
|
||||
export const FABBase = typescriptHappyForwardRef(
|
||||
(
|
||||
props: PropsWithChildren<
|
||||
{
|
||||
id: string
|
||||
show?: boolean
|
||||
children: JSX.Element
|
||||
} & HTMLMotionProps<"button">
|
||||
>,
|
||||
ref: React.ForwardedRef<HTMLButtonElement>,
|
||||
) => {
|
||||
const { children, show = true, ...extra } = props
|
||||
const { className, ...rest } = extra
|
||||
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{show && (
|
||||
<m.button
|
||||
type="button"
|
||||
initial={{ scale: 0, opacity: 0 }}
|
||||
animate={{ scale: 1, opacity: 1 }}
|
||||
exit={{ scale: 0, opacity: 0 }}
|
||||
transition={{
|
||||
duration: 0.2,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
ref={ref}
|
||||
aria-label="Floating action button"
|
||||
className={cn(
|
||||
"mt-2 flex items-center justify-center",
|
||||
"size-9 text-lg md:text-base",
|
||||
"outline-accent hover:opacity-100 focus:opacity-100 focus:outline-none",
|
||||
"hover:border-border bg-background relative rounded-xl border border-transparent",
|
||||
"group duration-200",
|
||||
className,
|
||||
)}
|
||||
{...rest}
|
||||
>
|
||||
<div className="shadow-perfect border-border/50 pointer-events-none absolute inset-0 rounded-xl border shadow-xl duration-200 group-hover:opacity-0" />
|
||||
{children}
|
||||
</m.button>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
export const FABPortable = typescriptHappyForwardRef(
|
||||
(
|
||||
props: {
|
||||
children: React.JSX.Element
|
||||
onClick: () => void
|
||||
export const FABBase: FC<
|
||||
PropsWithChildren<
|
||||
{
|
||||
id: string
|
||||
show?: boolean
|
||||
},
|
||||
ref: React.ForwardedRef<HTMLButtonElement>,
|
||||
) => {
|
||||
const { onClick, children, show = true } = props
|
||||
const id = useId()
|
||||
const portalElement = useAtomValue(fabContainerElementAtom)
|
||||
children: JSX.Element
|
||||
ref?: React.Ref<HTMLButtonElement>
|
||||
} & HTMLMotionProps<"button">
|
||||
>
|
||||
> = (props) => {
|
||||
const { children, show = true, ref, ...extra } = props
|
||||
const { className, ...rest } = extra
|
||||
|
||||
if (!portalElement) return null
|
||||
|
||||
return (
|
||||
<RootPortal to={portalElement}>
|
||||
<FABBase ref={ref} id={id} show={show} onClick={onClick}>
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{show && (
|
||||
<m.button
|
||||
type="button"
|
||||
initial={{ scale: 0, opacity: 0 }}
|
||||
animate={{ scale: 1, opacity: 1 }}
|
||||
exit={{ scale: 0, opacity: 0 }}
|
||||
transition={{
|
||||
duration: 0.2,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
ref={ref}
|
||||
aria-label="Floating action button"
|
||||
className={cn(
|
||||
"mt-2 flex items-center justify-center",
|
||||
"size-9 text-lg md:text-base",
|
||||
"outline-accent hover:opacity-100 focus:opacity-100 focus:outline-none",
|
||||
"hover:border-border bg-background relative rounded-xl border border-transparent",
|
||||
"group duration-200",
|
||||
className,
|
||||
)}
|
||||
{...rest}
|
||||
>
|
||||
<div className="shadow-perfect border-border/50 pointer-events-none absolute inset-0 rounded-xl border shadow-xl duration-200 group-hover:opacity-0" />
|
||||
{children}
|
||||
</FABBase>
|
||||
</RootPortal>
|
||||
)
|
||||
},
|
||||
)
|
||||
</m.button>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
)
|
||||
}
|
||||
|
||||
export const FABPortable: FC<
|
||||
PropsWithChildren<{
|
||||
children: React.JSX.Element
|
||||
onClick: () => void
|
||||
show?: boolean
|
||||
ref?: React.Ref<HTMLButtonElement>
|
||||
}>
|
||||
> = (props) => {
|
||||
const { onClick, children, show = true, ref } = props
|
||||
const id = useId()
|
||||
const portalElement = useAtomValue(fabContainerElementAtom)
|
||||
|
||||
if (!portalElement) return null
|
||||
|
||||
return (
|
||||
<RootPortal to={portalElement}>
|
||||
<FABBase ref={ref} id={id} show={show} onClick={onClick}>
|
||||
{children}
|
||||
</FABBase>
|
||||
</RootPortal>
|
||||
)
|
||||
}
|
||||
|
||||
export const FABContainer = (props: { children?: ReactNode }) => {
|
||||
return (
|
||||
|
||||
@@ -55,7 +55,7 @@ const HTMLImpl = <A extends keyof JSX.IntrinsicElements = "div">(props: HTMLProp
|
||||
|
||||
if (!markdownElement) return null
|
||||
return (
|
||||
<MarkdownRenderContainerRefContext.Provider value={refElement}>
|
||||
<MarkdownRenderContainerRefContext value={refElement}>
|
||||
<MediaContainerWidthProvider width={containerWidth}>
|
||||
<MediaInfoRecordProvider mediaInfo={mediaInfo}>
|
||||
<MemoedDangerousHTMLStyle>{katexStyle}</MemoedDangerousHTMLStyle>
|
||||
@@ -71,7 +71,7 @@ const HTMLImpl = <A extends keyof JSX.IntrinsicElements = "div">(props: HTMLProp
|
||||
</MediaInfoRecordProvider>
|
||||
</MediaContainerWidthProvider>
|
||||
{!!accessory && <Fragment key={shouldForceReMountKey}>{accessory}</Fragment>}
|
||||
</MarkdownRenderContainerRefContext.Provider>
|
||||
</MarkdownRenderContainerRefContext>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ export const Markdown: Component<
|
||||
const [refElement, setRefElement] = useState<HTMLElement | null>(null)
|
||||
|
||||
return (
|
||||
<MarkdownRenderContainerRefContext.Provider value={refElement}>
|
||||
<MarkdownRenderContainerRefContext value={refElement}>
|
||||
<article
|
||||
className={cn(
|
||||
"prose dark:prose-invert prose-th:text-left relative cursor-auto select-text",
|
||||
@@ -30,6 +30,6 @@ export const Markdown: Component<
|
||||
>
|
||||
{markdownElement}
|
||||
</article>
|
||||
</MarkdownRenderContainerRefContext.Provider>
|
||||
</MarkdownRenderContainerRefContext>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,16 +2,7 @@ import { useViewport } from "@follow/components/hooks/useViewport.js"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import * as HoverCard from "@radix-ui/react-hover-card"
|
||||
import { AnimatePresence, m } from "motion/react"
|
||||
import {
|
||||
forwardRef,
|
||||
memo,
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useImperativeHandle,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react"
|
||||
import { memo, use, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react"
|
||||
|
||||
import { useRealInWideMode } from "~/atoms/settings/ui"
|
||||
import {
|
||||
@@ -43,55 +34,57 @@ const WiderTocStyle = {
|
||||
export interface TocRef {
|
||||
refreshItems: () => void
|
||||
}
|
||||
export const Toc = forwardRef<TocRef, ComponentType<TocProps>>(
|
||||
({ className, onItemClick }, ref) => {
|
||||
const markdownElement = useContext(MarkdownRenderContainerRefContext)
|
||||
const { toc, rootDepth, refreshItems } = useTocItems(markdownElement)
|
||||
const { currentScrollRange, handleScrollTo } = useScrollTracking(toc, {
|
||||
onItemClick,
|
||||
})
|
||||
export const Toc = ({
|
||||
ref,
|
||||
className,
|
||||
onItemClick,
|
||||
}: ComponentType<TocProps> & { ref?: React.Ref<TocRef | null> }) => {
|
||||
const markdownElement = use(MarkdownRenderContainerRefContext)
|
||||
const { toc, rootDepth, refreshItems } = useTocItems(markdownElement)
|
||||
const { currentScrollRange, handleScrollTo } = useScrollTracking(toc, {
|
||||
onItemClick,
|
||||
})
|
||||
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
useCallback(() => {
|
||||
return {
|
||||
refreshItems,
|
||||
}
|
||||
}, [refreshItems]),
|
||||
)
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
useCallback(() => {
|
||||
return {
|
||||
refreshItems,
|
||||
}
|
||||
}, [refreshItems]),
|
||||
)
|
||||
|
||||
const renderContentElementPosition = useWrappedElementPosition()
|
||||
const renderContentElementSize = useWrappedElementSize()
|
||||
const entryContentInWideMode = useRealInWideMode()
|
||||
const shouldShowTitle = useViewport((v) => {
|
||||
if (!entryContentInWideMode) return false
|
||||
const { w } = v
|
||||
const xAxis = renderContentElementPosition.x + renderContentElementSize.w
|
||||
const renderContentElementPosition = useWrappedElementPosition()
|
||||
const renderContentElementSize = useWrappedElementSize()
|
||||
const entryContentInWideMode = useRealInWideMode()
|
||||
const shouldShowTitle = useViewport((v) => {
|
||||
if (!entryContentInWideMode) return false
|
||||
const { w } = v
|
||||
const xAxis = renderContentElementPosition.x + renderContentElementSize.w
|
||||
|
||||
return w - xAxis > WiderTocStyle.width + 50
|
||||
})
|
||||
return w - xAxis > WiderTocStyle.width + 50
|
||||
})
|
||||
|
||||
if (toc.length === 0) return null
|
||||
if (toc.length === 0) return null
|
||||
|
||||
return shouldShowTitle ? (
|
||||
<TocContainer
|
||||
className={className}
|
||||
toc={toc}
|
||||
rootDepth={rootDepth}
|
||||
currentScrollRange={currentScrollRange}
|
||||
handleScrollTo={handleScrollTo}
|
||||
/>
|
||||
) : (
|
||||
<TocHoverCard
|
||||
className={className}
|
||||
toc={toc}
|
||||
rootDepth={rootDepth}
|
||||
currentScrollRange={currentScrollRange}
|
||||
handleScrollTo={handleScrollTo}
|
||||
/>
|
||||
)
|
||||
},
|
||||
)
|
||||
return shouldShowTitle ? (
|
||||
<TocContainer
|
||||
className={className}
|
||||
toc={toc}
|
||||
rootDepth={rootDepth}
|
||||
currentScrollRange={currentScrollRange}
|
||||
handleScrollTo={handleScrollTo}
|
||||
/>
|
||||
) : (
|
||||
<TocHoverCard
|
||||
className={className}
|
||||
toc={toc}
|
||||
rootDepth={rootDepth}
|
||||
currentScrollRange={currentScrollRange}
|
||||
handleScrollTo={handleScrollTo}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const TocContainer: React.FC<TocContainerProps> = ({
|
||||
className,
|
||||
|
||||
@@ -78,7 +78,7 @@ export const useScrollTracking = (
|
||||
|
||||
const headingTopsRef = useRef<number[]>([])
|
||||
const [headingTopsVersion, setHeadingTopsVersion] = useState(0)
|
||||
const throttleCallerRef = useRef<DebouncedFuncLeading<() => void>>()
|
||||
const throttleCallerRef = useRef<DebouncedFuncLeading<() => void>>(undefined)
|
||||
const store = useStore()
|
||||
|
||||
useLayoutEffect(() => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useContext } from "react"
|
||||
import { use } from "react"
|
||||
import { useContextSelector } from "use-context-selector"
|
||||
|
||||
import { useWrappedElementSize } from "~/providers/wrapped-element-provider"
|
||||
@@ -17,7 +17,7 @@ export const MarkdownBlockImage = (
|
||||
) => {
|
||||
const size = useWrappedElementSize()
|
||||
|
||||
const { transformUrl } = useContext(MarkdownRenderActionContext)
|
||||
const { transformUrl } = use(MarkdownRenderActionContext)
|
||||
const src = transformUrl(props.src)
|
||||
|
||||
const media = useContextSelector(MarkdownImageRecordContext, (record) =>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useScrollViewElement } from "@follow/components/ui/scroll-area/hooks.js"
|
||||
import { springScrollToElement } from "@follow/utils/scroller"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useContext, useId, useRef } from "react"
|
||||
import { use, useId, useRef } from "react"
|
||||
|
||||
import { MarkdownRenderContainerRefContext } from "../context"
|
||||
|
||||
@@ -16,7 +16,7 @@ export const createHeadingRenderer =
|
||||
const { node, ...rest } = props as any
|
||||
|
||||
const scroller = useScrollViewElement()
|
||||
const renderContainer = useContext(MarkdownRenderContainerRefContext)
|
||||
const renderContainer = use(MarkdownRenderContainerRefContext)
|
||||
const ref = useRef<HTMLHeadingElement>(null)
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useContext } from "react"
|
||||
import { use } from "react"
|
||||
import { useContextSelector } from "use-context-selector"
|
||||
|
||||
import { Media } from "../../media"
|
||||
@@ -13,7 +13,7 @@ export const MarkdownInlineImage = (
|
||||
}
|
||||
},
|
||||
) => {
|
||||
const { transformUrl } = useContext(MarkdownRenderActionContext)
|
||||
const { transformUrl } = use(MarkdownRenderActionContext)
|
||||
const populatedUrl = transformUrl(props.src)
|
||||
const media = useContextSelector(MarkdownImageRecordContext, (record) =>
|
||||
props.src ? record[props.src] : null,
|
||||
|
||||
@@ -6,15 +6,13 @@ import {
|
||||
TooltipTrigger,
|
||||
} from "@follow/components/ui/tooltip/index.jsx"
|
||||
import { useCorrectZIndex } from "@follow/components/ui/z-index/ctx.js"
|
||||
import { useContext } from "react"
|
||||
import { use } from "react"
|
||||
|
||||
import type { LinkProps } from "../../link"
|
||||
import { MarkdownRenderActionContext } from "../context"
|
||||
|
||||
export const MarkdownLink = (props: LinkProps) => {
|
||||
const { transformUrl, isAudio, ensureAndRenderTimeStamp } = useContext(
|
||||
MarkdownRenderActionContext,
|
||||
)
|
||||
const { transformUrl, isAudio, ensureAndRenderTimeStamp } = use(MarkdownRenderActionContext)
|
||||
|
||||
const populatedFullHref = transformUrl(props.href)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { IsInParagraphContext } from "./ctx"
|
||||
export const MarkdownP: Component<
|
||||
React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>
|
||||
> = ({ children, ...props }) => {
|
||||
const { isAudio, ensureAndRenderTimeStamp } = React.useContext(MarkdownRenderActionContext)
|
||||
const { isAudio, ensureAndRenderTimeStamp } = React.use(MarkdownRenderActionContext)
|
||||
const parseTimeline = isAudio()
|
||||
if (parseTimeline && typeof children === "string") {
|
||||
const renderer = ensureAndRenderTimeStamp(children)
|
||||
@@ -29,7 +29,7 @@ export const MarkdownP: Component<
|
||||
|
||||
return (
|
||||
<p {...props}>
|
||||
<IsInParagraphContext.Provider value={true}>{children}</IsInParagraphContext.Provider>
|
||||
<IsInParagraphContext value={true}>{children}</IsInParagraphContext>
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createContext, useContext } from "react"
|
||||
import { createContext, use } from "react"
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@@ -6,5 +6,5 @@ import { createContext, useContext } from "react"
|
||||
export const IsInParagraphContext = createContext<boolean>(false)
|
||||
|
||||
export const useIsInParagraphContext = () => {
|
||||
return useContext(IsInParagraphContext)
|
||||
return use(IsInParagraphContext)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { getImageProxyUrl } from "@follow/utils/img-proxy"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useForceUpdate } from "motion/react"
|
||||
import type { FC, ImgHTMLAttributes, VideoHTMLAttributes } from "react"
|
||||
import { createContext, memo, useContext, useMemo, useState } from "react"
|
||||
import { createContext, memo, use, useMemo, useState } from "react"
|
||||
import { Blurhash, BlurhashCanvas } from "react-blurhash"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
@@ -71,7 +71,7 @@ const MediaImpl: FC<MediaProps> = ({
|
||||
...rest
|
||||
} = props
|
||||
|
||||
const ctxMediaInfo = useContext(MediaInfoRecordContext)
|
||||
const ctxMediaInfo = use(MediaInfoRecordContext)
|
||||
const ctxHeight = ctxMediaInfo[src!]?.height
|
||||
const ctxWidth = ctxMediaInfo[src!]?.width
|
||||
|
||||
@@ -460,15 +460,11 @@ export const MediaContainerWidthProvider = ({
|
||||
children: React.ReactNode
|
||||
width: number
|
||||
}) => {
|
||||
return (
|
||||
<MediaContainerWidthContext.Provider value={width}>
|
||||
{children}
|
||||
</MediaContainerWidthContext.Provider>
|
||||
)
|
||||
return <MediaContainerWidthContext value={width}>{children}</MediaContainerWidthContext>
|
||||
}
|
||||
|
||||
const useMediaContainerWidth = () => {
|
||||
return useContext(MediaContainerWidthContext)
|
||||
return use(MediaContainerWidthContext)
|
||||
}
|
||||
|
||||
export type MediaInfoRecord = Record<string, { width?: number; height?: number }>
|
||||
@@ -482,9 +478,5 @@ export const MediaInfoRecordProvider = ({
|
||||
children: React.ReactNode
|
||||
mediaInfo?: Nullable<MediaInfoRecord>
|
||||
}) => {
|
||||
return (
|
||||
<MediaInfoRecordContext.Provider value={mediaInfo || noop}>
|
||||
{children}
|
||||
</MediaInfoRecordContext.Provider>
|
||||
)
|
||||
return <MediaInfoRecordContext value={mediaInfo || noop}>{children}</MediaInfoRecordContext>
|
||||
}
|
||||
|
||||
@@ -7,9 +7,8 @@ import { nextFrame, stopPropagation } from "@follow/utils/dom"
|
||||
import { clsx, cn } from "@follow/utils/utils"
|
||||
import * as Slider from "@radix-ui/react-slider"
|
||||
import { m, useDragControls, useSpring } from "motion/react"
|
||||
import type { PropsWithChildren } from "react"
|
||||
import type { PropsWithChildren, RefObject } from "react"
|
||||
import {
|
||||
forwardRef,
|
||||
memo,
|
||||
startTransition,
|
||||
useEffect,
|
||||
@@ -47,122 +46,126 @@ export type VideoPlayerRef = {
|
||||
unmute: () => void
|
||||
}
|
||||
|
||||
wrapperRef: React.RefObject<HTMLDivElement>
|
||||
wrapperRef: RefObject<HTMLDivElement | null>
|
||||
}
|
||||
|
||||
interface VideoPlayerContextValue {
|
||||
state: HTMLMediaState
|
||||
controls: VideoPlayerRef["controls"]
|
||||
wrapperRef: React.RefObject<HTMLDivElement>
|
||||
wrapperRef: RefObject<HTMLDivElement | null>
|
||||
src: string
|
||||
variant: "preview" | "player" | "thumbnail"
|
||||
}
|
||||
const VideoPlayerContext = createContext<VideoPlayerContextValue>(null!)
|
||||
export const VideoPlayer = forwardRef<VideoPlayerRef, VideoPlayerProps>(
|
||||
({ src, className, variant = "player", ...rest }, ref) => {
|
||||
const isPlayer = variant === "player"
|
||||
const [clickToStatus, setClickToStatus] = useState(null as "play" | "pause" | null)
|
||||
export const VideoPlayer = ({
|
||||
ref,
|
||||
src,
|
||||
className,
|
||||
variant = "player",
|
||||
...rest
|
||||
}: VideoPlayerProps & {
|
||||
ref?: React.Ref<VideoPlayerRef | null> | ((ref: VideoPlayerRef) => void)
|
||||
}) => {
|
||||
const isPlayer = variant === "player"
|
||||
const [clickToStatus, setClickToStatus] = useState(null as "play" | "pause" | null)
|
||||
|
||||
const scaleValue = useSpring(1, Spring.presets.softSpring)
|
||||
const opacityValue = useSpring(0, Spring.presets.softSpring)
|
||||
const handleClick = useEventCallback((e?: any) => {
|
||||
const scaleValue = useSpring(1, Spring.presets.softSpring)
|
||||
const opacityValue = useSpring(0, Spring.presets.softSpring)
|
||||
const handleClick = useEventCallback((e?: any) => {
|
||||
if (!isPlayer) return
|
||||
e?.stopPropagation()
|
||||
|
||||
if (state.playing) {
|
||||
controls.pause()
|
||||
setClickToStatus("pause")
|
||||
} else {
|
||||
controls.play()
|
||||
setClickToStatus("play")
|
||||
}
|
||||
|
||||
opacityValue.jump(1)
|
||||
scaleValue.jump(1)
|
||||
|
||||
nextFrame(() => {
|
||||
scaleValue.set(1.3)
|
||||
opacityValue.set(0)
|
||||
})
|
||||
})
|
||||
|
||||
const [element, state, controls, videoRef] = useVideo({
|
||||
src,
|
||||
className,
|
||||
playsInline: true,
|
||||
...rest,
|
||||
controls: false,
|
||||
onClick(e) {
|
||||
rest.onClick?.(e)
|
||||
handleClick(e)
|
||||
},
|
||||
muted: isPlayer ? false : true,
|
||||
onDoubleClick(e) {
|
||||
rest.onDoubleClick?.(e)
|
||||
if (!isPlayer) return
|
||||
e?.stopPropagation()
|
||||
|
||||
if (state.playing) {
|
||||
controls.pause()
|
||||
setClickToStatus("pause")
|
||||
} else {
|
||||
controls.play()
|
||||
setClickToStatus("play")
|
||||
}
|
||||
|
||||
opacityValue.jump(1)
|
||||
scaleValue.jump(1)
|
||||
|
||||
nextFrame(() => {
|
||||
scaleValue.set(1.3)
|
||||
opacityValue.set(0)
|
||||
})
|
||||
})
|
||||
|
||||
const [element, state, controls, videoRef] = useVideo({
|
||||
src,
|
||||
className,
|
||||
playsInline: true,
|
||||
...rest,
|
||||
controls: false,
|
||||
onClick(e) {
|
||||
rest.onClick?.(e)
|
||||
handleClick(e)
|
||||
},
|
||||
muted: isPlayer ? false : true,
|
||||
onDoubleClick(e) {
|
||||
rest.onDoubleClick?.(e)
|
||||
if (!isPlayer) return
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
if (!document.fullscreenElement) {
|
||||
wrapperRef.current?.requestFullscreen()
|
||||
} else {
|
||||
document.exitFullscreen()
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
useHotkeys("space", (e) => {
|
||||
e.preventDefault()
|
||||
handleClick()
|
||||
})
|
||||
e.stopPropagation()
|
||||
if (!document.fullscreenElement) {
|
||||
wrapperRef.current?.requestFullscreen()
|
||||
} else {
|
||||
document.exitFullscreen()
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const stateRef = useRefValue(state)
|
||||
const memoedControls = useState(controls)[0]
|
||||
const wrapperRef = useRef<HTMLDivElement>(null)
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
() => ({
|
||||
getElement: () => videoRef.current,
|
||||
getState: () => stateRef.current,
|
||||
controls: memoedControls,
|
||||
wrapperRef,
|
||||
}),
|
||||
useHotkeys("space", (e) => {
|
||||
e.preventDefault()
|
||||
handleClick()
|
||||
})
|
||||
|
||||
[stateRef, videoRef, memoedControls],
|
||||
)
|
||||
const stateRef = useRefValue(state)
|
||||
const memoedControls = useState(controls)[0]
|
||||
const wrapperRef = useRef<HTMLDivElement>(null)
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
() => ({
|
||||
getElement: () => videoRef.current,
|
||||
getState: () => stateRef.current,
|
||||
controls: memoedControls,
|
||||
wrapperRef,
|
||||
}),
|
||||
|
||||
return (
|
||||
<Focusable className="center group relative size-full" ref={wrapperRef}>
|
||||
{element}
|
||||
[stateRef, videoRef, memoedControls],
|
||||
)
|
||||
|
||||
<div className="center pointer-events-none absolute inset-0">
|
||||
<m.div
|
||||
className="center flex size-20 rounded-full bg-black p-3"
|
||||
style={{ scale: scaleValue, opacity: opacityValue }}
|
||||
>
|
||||
<i
|
||||
className={cn(
|
||||
"size-8 text-white",
|
||||
clickToStatus === "play" ? "i-mgc-play-cute-fi" : "i-mgc-pause-cute-fi",
|
||||
)}
|
||||
/>
|
||||
</m.div>
|
||||
</div>
|
||||
|
||||
{state.hasAudio && !state.muted && state.playing && <BizControlOutsideMedia />}
|
||||
|
||||
<VideoPlayerContext.Provider
|
||||
value={useMemo(
|
||||
() => ({ state, controls, wrapperRef, src, variant }),
|
||||
[state, controls, src, variant],
|
||||
)}
|
||||
return (
|
||||
<Focusable className="center group relative size-full" ref={wrapperRef}>
|
||||
{element}
|
||||
<div className="center pointer-events-none absolute inset-0">
|
||||
<m.div
|
||||
className="center flex size-20 rounded-full bg-black p-3"
|
||||
style={{ scale: scaleValue, opacity: opacityValue }}
|
||||
>
|
||||
{variant === "preview" && state.hasAudio && <FloatMutedButton />}
|
||||
{isPlayer && <ControlBar />}
|
||||
</VideoPlayerContext.Provider>
|
||||
</Focusable>
|
||||
)
|
||||
},
|
||||
)
|
||||
<i
|
||||
className={cn(
|
||||
"size-8 text-white",
|
||||
clickToStatus === "play" ? "i-mgc-play-cute-fi" : "i-mgc-pause-cute-fi",
|
||||
)}
|
||||
/>
|
||||
</m.div>
|
||||
</div>
|
||||
{state.hasAudio && !state.muted && state.playing && <BizControlOutsideMedia />}
|
||||
{/* eslint-disable-next-line @eslint-react/no-context-provider */}
|
||||
<VideoPlayerContext.Provider
|
||||
value={useMemo(
|
||||
() => ({ state, controls, wrapperRef, src, variant }),
|
||||
[state, controls, src, variant],
|
||||
)}
|
||||
>
|
||||
{variant === "preview" && state.hasAudio && <FloatMutedButton />}
|
||||
{isPlayer && <ControlBar />}
|
||||
</VideoPlayerContext.Provider>
|
||||
</Focusable>
|
||||
)
|
||||
}
|
||||
const BizControlOutsideMedia = () => {
|
||||
const currentAudioPlayerIsPlayRef = useMemo(() => AudioPlayer.get().status === "playing", [])
|
||||
useEffect(() => {
|
||||
@@ -181,6 +184,7 @@ const BizControlOutsideMedia = () => {
|
||||
}
|
||||
|
||||
const FloatMutedButton = () => {
|
||||
// eslint-disable-next-line @eslint-react/no-use-context
|
||||
const ctx = useContext(VideoPlayerContext)
|
||||
const isMuted = ctx.state.muted
|
||||
return (
|
||||
@@ -363,6 +367,7 @@ const VolumeControl = () => {
|
||||
}
|
||||
|
||||
const PlayProgressBar = () => {
|
||||
// eslint-disable-next-line @eslint-react/no-use-context
|
||||
const { state, controls } = useContext(VideoPlayerContext)
|
||||
const [currentDragging, setCurrentDragging] = useState(false)
|
||||
const [dragTime, setDragTime] = useState(0)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable react-refresh/only-export-components */
|
||||
import { useOnce, useTypeScriptHappyCallback } from "@follow/hooks"
|
||||
import type { FC } from "react"
|
||||
import { createContext, createElement, useContext } from "react"
|
||||
import { createContext, createElement, use } from "react"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import type { ModalActionsInternal } from "~/components/ui/modal"
|
||||
@@ -29,9 +29,9 @@ export const useAsyncModal = () => {
|
||||
present({
|
||||
id: options.id,
|
||||
content: () => (
|
||||
<AsyncModalContext.Provider value={options}>
|
||||
<AsyncModalContext value={options}>
|
||||
<LazyContent />
|
||||
</AsyncModalContext.Provider>
|
||||
</AsyncModalContext>
|
||||
),
|
||||
title: "Loading...",
|
||||
CustomModalComponent: NoopChildren,
|
||||
@@ -41,7 +41,7 @@ export const useAsyncModal = () => {
|
||||
}
|
||||
|
||||
const LazyContent = () => {
|
||||
const ctx = useContext(AsyncModalContext)
|
||||
const ctx = use(AsyncModalContext)
|
||||
const queryResult = ctx.useDataFetcher()
|
||||
|
||||
return (
|
||||
@@ -61,7 +61,7 @@ const Presentable: FC<{
|
||||
data: any
|
||||
}> = ({ data }) => {
|
||||
const { present, dismissTop } = useModalStack()
|
||||
const ctx = useContext(AsyncModalContext)
|
||||
const ctx = use(AsyncModalContext)
|
||||
|
||||
useOnce(() => {
|
||||
dismissTop()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createContext, useContext } from "react"
|
||||
import { createContext, use } from "react"
|
||||
|
||||
export const InPeekModal = createContext(false)
|
||||
InPeekModal.displayName = "InPeekModal"
|
||||
export const useInPeekModal = () => useContext(InPeekModal)
|
||||
export const useInPeekModal = () => use(InPeekModal)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getStableRouterNavigate } from "@follow/components/atoms/route.js"
|
||||
import { RootPortalProvider } from "@follow/components/ui/portal/provider.js"
|
||||
import { RootPortalContext } from "@follow/components/ui/portal/provider.js"
|
||||
import type { PropsWithChildren, ReactNode } from "react"
|
||||
import { useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
@@ -29,7 +29,7 @@ export const PeekModal = (
|
||||
const [rootRef, setRootRef] = useState<HTMLDivElement | null>(null)
|
||||
|
||||
return (
|
||||
<RootPortalProvider value={rootRef as HTMLElement}>
|
||||
<RootPortalContext value={rootRef as HTMLElement}>
|
||||
<div
|
||||
className="scrollbar-none relative mx-auto mt-[10vh] max-w-full overflow-hidden px-2 lg:max-w-[65rem] lg:p-0"
|
||||
ref={setRootRef}
|
||||
@@ -39,7 +39,7 @@ export const PeekModal = (
|
||||
transition={{ duration: 0.2 }}
|
||||
className="motion-preset-slide-up motion-duration-200 motion-ease-spring-smooth scrollbar-none overflow-hidden"
|
||||
>
|
||||
<InPeekModal.Provider value={true}>{children}</InPeekModal.Provider>
|
||||
<InPeekModal value={true}>{children}</InPeekModal>
|
||||
</m.div>
|
||||
<m.div
|
||||
initial={true}
|
||||
@@ -70,6 +70,6 @@ export const PeekModal = (
|
||||
<FixedModalCloseButton onClick={dismiss} />
|
||||
</m.div>
|
||||
</div>
|
||||
</RootPortalProvider>
|
||||
</RootPortalContext>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import type { Enable } from "re-resizable"
|
||||
import type { Context, PropsWithChildren } from "react"
|
||||
import { memo, useContext } from "react"
|
||||
import { memo, use } from "react"
|
||||
|
||||
export const InjectContext = (context: Context<any>) => {
|
||||
const ctxValue = useContext(context)
|
||||
return memo(({ children }: PropsWithChildren) => (
|
||||
<context.Provider value={ctxValue}>{children}</context.Provider>
|
||||
))
|
||||
export const InjectContext = (Context: Context<any>) => {
|
||||
const ctxValue = use(Context)
|
||||
return memo(({ children }: PropsWithChildren) => <Context value={ctxValue}>{children}</Context>)
|
||||
}
|
||||
|
||||
export function resizableOnly(...positions: (keyof Enable)[]) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { nextFrame } from "@follow/utils/dom"
|
||||
import { atom, useAtomValue } from "jotai"
|
||||
import type { DragControls } from "motion/react"
|
||||
import type { ResizeCallback, ResizeStartCallback } from "re-resizable"
|
||||
import { useContext, useId, useRef, useState } from "react"
|
||||
import { use, useId, useRef, useState } from "react"
|
||||
import { flushSync } from "react-dom"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { useContextSelector } from "use-context-selector"
|
||||
@@ -98,12 +98,12 @@ const actions = {
|
||||
},
|
||||
}
|
||||
|
||||
export const useCurrentModal = () => useContext(CurrentModalContext)
|
||||
export const useCurrentModal = () => use(CurrentModalContext)
|
||||
|
||||
export const useIsInModal = () => useContextSelector(CurrentModalStateContext, (v) => v.isInModal)
|
||||
|
||||
export const useResizeableModal = (
|
||||
modalElementRef: React.RefObject<HTMLDivElement>,
|
||||
modalElementRef: React.RefObject<HTMLDivElement | null>,
|
||||
{
|
||||
enableResizeable,
|
||||
dragControls,
|
||||
|
||||
@@ -8,7 +8,7 @@ import { useResizeableModal } from "../hooks"
|
||||
* @internal
|
||||
*/
|
||||
export const useModalResizeAndDrag = (
|
||||
modalElementRef: RefObject<HTMLDivElement>,
|
||||
modalElementRef: RefObject<HTMLDivElement | null>,
|
||||
{
|
||||
resizeable,
|
||||
draggable,
|
||||
|
||||
@@ -89,9 +89,9 @@ const ModalToSheet = (props: ModalProps & { index: number; id: string }) => {
|
||||
)
|
||||
|
||||
const finalChildren = (
|
||||
<CurrentModalContext.Provider value={ModalContextProps}>
|
||||
<CurrentModalContext value={ModalContextProps}>
|
||||
{createElement(content, ModalProps)}
|
||||
</CurrentModalContext.Provider>
|
||||
</CurrentModalContext>
|
||||
)
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { RootPortalProvider } from "@follow/components/ui/portal/provider.js"
|
||||
import { RootPortalContext } from "@follow/components/ui/portal/provider.js"
|
||||
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
|
||||
import { ZIndexProvider } from "@follow/components/ui/z-index/index.js"
|
||||
import { useRefValue } from "@follow/hooks"
|
||||
@@ -14,7 +14,6 @@ import { Resizable } from "re-resizable"
|
||||
import type { FC, PropsWithChildren, SyntheticEvent } from "react"
|
||||
import {
|
||||
createElement,
|
||||
forwardRef,
|
||||
Fragment,
|
||||
memo,
|
||||
useCallback,
|
||||
@@ -48,254 +47,205 @@ import type { ModalOverlayOptions, ModalProps } from "./types"
|
||||
const DragBar = ELECTRON_BUILD ? (
|
||||
<span className="drag-region fixed left-0 right-36 top-0 h-8" />
|
||||
) : null
|
||||
export const ModalInternal = memo(
|
||||
forwardRef<
|
||||
HTMLDivElement,
|
||||
{
|
||||
item: ModalProps & { id: string }
|
||||
index: number
|
||||
export const ModalInternal = memo(function Modal({
|
||||
ref,
|
||||
item,
|
||||
overlayOptions,
|
||||
onClose: onPropsClose,
|
||||
children,
|
||||
isTop,
|
||||
index,
|
||||
isBottom,
|
||||
}: {
|
||||
item: ModalProps & { id: string }
|
||||
index: number
|
||||
|
||||
isTop?: boolean
|
||||
isBottom?: boolean
|
||||
overlayOptions?: ModalOverlayOptions
|
||||
onClose?: (open: boolean) => void
|
||||
} & PropsWithChildren
|
||||
>(function Modal(
|
||||
{ item, overlayOptions, onClose: onPropsClose, children, isTop, index, isBottom },
|
||||
ref,
|
||||
) {
|
||||
const {
|
||||
CustomModalComponent,
|
||||
content,
|
||||
title,
|
||||
clickOutsideToDismiss,
|
||||
isTop?: boolean
|
||||
isBottom?: boolean
|
||||
overlayOptions?: ModalOverlayOptions
|
||||
onClose?: (open: boolean) => void
|
||||
} & PropsWithChildren & { ref?: React.Ref<HTMLDivElement | null> }) {
|
||||
const {
|
||||
CustomModalComponent,
|
||||
content,
|
||||
title,
|
||||
clickOutsideToDismiss,
|
||||
|
||||
modalClassName,
|
||||
modalContainerClassName,
|
||||
modalContentClassName,
|
||||
modalClassName,
|
||||
modalContainerClassName,
|
||||
modalContentClassName,
|
||||
|
||||
wrapper: Wrapper = Fragment,
|
||||
max,
|
||||
icon,
|
||||
canClose = true,
|
||||
wrapper: Wrapper = Fragment,
|
||||
max,
|
||||
icon,
|
||||
canClose = true,
|
||||
|
||||
draggable = false,
|
||||
resizeable = false,
|
||||
resizeDefaultSize,
|
||||
modal = true,
|
||||
autoFocus = true,
|
||||
} = item
|
||||
draggable = false,
|
||||
resizeable = false,
|
||||
resizeDefaultSize,
|
||||
modal = true,
|
||||
autoFocus = true,
|
||||
} = item
|
||||
|
||||
const setStack = useSetAtom(modalStackAtom)
|
||||
const setStack = useSetAtom(modalStackAtom)
|
||||
|
||||
const [currentIsClosing, setCurrentIsClosing] = useState(false)
|
||||
const { noticeModal, animateController, dismissing } = useModalAnimate(!!isTop)
|
||||
const [currentIsClosing, setCurrentIsClosing] = useState(false)
|
||||
const { noticeModal, animateController, dismissing } = useModalAnimate(!!isTop)
|
||||
|
||||
const close = useEventCallback((forceClose = false) => {
|
||||
if (!canClose && !forceClose) return
|
||||
setCurrentIsClosing(true)
|
||||
const close = useEventCallback((forceClose = false) => {
|
||||
if (!canClose && !forceClose) return
|
||||
setCurrentIsClosing(true)
|
||||
|
||||
if (!CustomModalComponent) {
|
||||
dismissing().then(() => {
|
||||
setStack((p) => p.filter((modal) => modal.id !== item.id))
|
||||
})
|
||||
} else {
|
||||
if (!CustomModalComponent) {
|
||||
dismissing().then(() => {
|
||||
setStack((p) => p.filter((modal) => modal.id !== item.id))
|
||||
}
|
||||
onPropsClose?.(false)
|
||||
})
|
||||
|
||||
const onClose = useCallback(
|
||||
(open: boolean): void => {
|
||||
if (!open) {
|
||||
close()
|
||||
}
|
||||
},
|
||||
[close],
|
||||
)
|
||||
|
||||
const modalSettingOverlay = useUISettingKey("modalOverlay")
|
||||
|
||||
const dismiss = useCallback(
|
||||
(e: SyntheticEvent) => {
|
||||
e.stopPropagation()
|
||||
|
||||
close(true)
|
||||
},
|
||||
[close],
|
||||
)
|
||||
|
||||
const modalElementRef = useRef<HTMLDivElement>(null)
|
||||
const {
|
||||
handleDrag,
|
||||
handleResizeStart,
|
||||
handleResizeStop,
|
||||
relocateModal,
|
||||
preferDragDir,
|
||||
isResizeable,
|
||||
resizeableStyle,
|
||||
|
||||
dragController,
|
||||
} = useModalResizeAndDrag(modalElementRef, {
|
||||
resizeable,
|
||||
draggable,
|
||||
})
|
||||
|
||||
const getIndex = useEventCallback(() => index)
|
||||
const [modalContentRef, setModalContentRef] = useState<HTMLDivElement | null>(null)
|
||||
const ModalProps: ModalActionsInternal = useMemo(
|
||||
() => ({
|
||||
dismiss: close,
|
||||
getIndex,
|
||||
setClickOutSideToDismiss: (v) => {
|
||||
setStack((state) =>
|
||||
produce(state, (draft) => {
|
||||
const model = draft.find((modal) => modal.id === item.id)
|
||||
if (!model) return
|
||||
if (model.clickOutsideToDismiss === v) return
|
||||
model.clickOutsideToDismiss = v
|
||||
}),
|
||||
)
|
||||
},
|
||||
}),
|
||||
[close, getIndex, item.id, setStack],
|
||||
)
|
||||
useModalSubscriber(item.id, ModalProps)
|
||||
|
||||
const ModalContextProps = useMemo<CurrentModalContentProps>(
|
||||
() => ({
|
||||
...ModalProps,
|
||||
ref: { current: modalContentRef },
|
||||
modalElementRef,
|
||||
}),
|
||||
[ModalProps, modalContentRef],
|
||||
)
|
||||
|
||||
const [edgeElementRef, setEdgeElementRef] = useState<HTMLDivElement | null>(null)
|
||||
|
||||
const finalChildren = useMemo(
|
||||
() => (
|
||||
<AppErrorBoundary errorType={ErrorComponentType.Modal}>
|
||||
<RootPortalProvider value={edgeElementRef as HTMLElement}>
|
||||
{children ?? createElement(content, ModalProps)}
|
||||
</RootPortalProvider>
|
||||
</AppErrorBoundary>
|
||||
),
|
||||
[ModalProps, children, content, edgeElementRef],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (currentIsClosing) {
|
||||
// Radix dialog will block pointer events
|
||||
document.body.style.pointerEvents = "auto"
|
||||
}
|
||||
}, [currentIsClosing])
|
||||
|
||||
useShortcutScope()
|
||||
|
||||
const modalStyle = resizeableStyle
|
||||
const { handleSelectStart, handleDetectSelectEnd, isSelectingRef } = useModalSelect()
|
||||
const handleClickOutsideToDismiss = useCallback(
|
||||
(e: SyntheticEvent) => {
|
||||
if (isSelectingRef.current) return
|
||||
const fn = modal ? (clickOutsideToDismiss && canClose ? dismiss : noticeModal) : undefined
|
||||
fn?.(e)
|
||||
},
|
||||
[canClose, clickOutsideToDismiss, dismiss, modal, noticeModal, isSelectingRef],
|
||||
)
|
||||
|
||||
const openAutoFocus = useCallback(
|
||||
(event: Event) => {
|
||||
if (!autoFocus) {
|
||||
event.preventDefault()
|
||||
}
|
||||
},
|
||||
[autoFocus],
|
||||
)
|
||||
|
||||
const measureDragConstraints = useRef((constraints: BoundingBox) => {
|
||||
if (getOS() === "Windows") {
|
||||
return {
|
||||
...constraints,
|
||||
top: constraints.top + ElECTRON_CUSTOM_TITLEBAR_HEIGHT,
|
||||
}
|
||||
}
|
||||
return constraints
|
||||
}).current
|
||||
|
||||
useImperativeHandle(ref, () => modalElementRef.current!)
|
||||
const currentModalZIndex = MODAL_STACK_Z_INDEX + index * 2
|
||||
|
||||
const Overlay = (
|
||||
<ModalOverlay
|
||||
zIndex={currentModalZIndex - 1}
|
||||
blur={overlayOptions?.blur}
|
||||
hidden={
|
||||
item.overlay ? currentIsClosing : !(modalSettingOverlay && isBottom) || currentIsClosing
|
||||
}
|
||||
/>
|
||||
)
|
||||
|
||||
const mutateableEdgeElementRef = useRefValue(edgeElementRef)
|
||||
|
||||
if (CustomModalComponent) {
|
||||
return (
|
||||
<Wrapper>
|
||||
<Dialog.Root open onOpenChange={onClose} modal={modal}>
|
||||
<Dialog.Portal>
|
||||
{Overlay}
|
||||
<Dialog.DialogTitle className="sr-only">{title}</Dialog.DialogTitle>
|
||||
<Dialog.Content
|
||||
ref={setModalContentRef}
|
||||
asChild
|
||||
aria-describedby={undefined}
|
||||
onPointerDownOutside={preventDefault}
|
||||
onOpenAutoFocus={openAutoFocus}
|
||||
>
|
||||
<div
|
||||
ref={setEdgeElementRef}
|
||||
className={cn(
|
||||
"no-drag-region fixed",
|
||||
modal ? "inset-0 overflow-auto" : "left-0 top-0",
|
||||
currentIsClosing ? "!pointer-events-none" : "!pointer-events-auto",
|
||||
modalContainerClassName,
|
||||
)}
|
||||
style={{
|
||||
zIndex: currentModalZIndex,
|
||||
}}
|
||||
onPointerUp={handleDetectSelectEnd}
|
||||
onClick={handleClickOutsideToDismiss}
|
||||
onFocus={stopPropagation}
|
||||
tabIndex={-1}
|
||||
>
|
||||
{DragBar}
|
||||
<div
|
||||
className={cn("contents", modalClassName, modalContentClassName)}
|
||||
onClick={stopPropagation}
|
||||
tabIndex={-1}
|
||||
ref={modalElementRef}
|
||||
onSelect={handleSelectStart}
|
||||
onKeyUp={handleDetectSelectEnd}
|
||||
>
|
||||
<ModalContext modalContextProps={ModalContextProps} isTop={!!isTop}>
|
||||
<CustomModalComponent>{finalChildren}</CustomModalComponent>
|
||||
</ModalContext>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog.Portal>
|
||||
</Dialog.Root>
|
||||
</Wrapper>
|
||||
)
|
||||
})
|
||||
} else {
|
||||
setStack((p) => p.filter((modal) => modal.id !== item.id))
|
||||
}
|
||||
onPropsClose?.(false)
|
||||
})
|
||||
|
||||
const ResizeSwitch = resizeable ? Resizable : SafeFragment
|
||||
const onClose = useCallback(
|
||||
(open: boolean): void => {
|
||||
if (!open) {
|
||||
close()
|
||||
}
|
||||
},
|
||||
[close],
|
||||
)
|
||||
|
||||
const modalSettingOverlay = useUISettingKey("modalOverlay")
|
||||
|
||||
const dismiss = useCallback(
|
||||
(e: SyntheticEvent) => {
|
||||
e.stopPropagation()
|
||||
|
||||
close(true)
|
||||
},
|
||||
[close],
|
||||
)
|
||||
|
||||
const modalElementRef = useRef<HTMLDivElement | null>(null)
|
||||
const {
|
||||
handleDrag,
|
||||
handleResizeStart,
|
||||
handleResizeStop,
|
||||
relocateModal,
|
||||
preferDragDir,
|
||||
isResizeable,
|
||||
resizeableStyle,
|
||||
|
||||
dragController,
|
||||
} = useModalResizeAndDrag(modalElementRef, {
|
||||
resizeable,
|
||||
draggable,
|
||||
})
|
||||
|
||||
const getIndex = useEventCallback(() => index)
|
||||
const [modalContentRef, setModalContentRef] = useState<HTMLDivElement | null>(null)
|
||||
const ModalProps: ModalActionsInternal = useMemo(
|
||||
() => ({
|
||||
dismiss: close,
|
||||
getIndex,
|
||||
setClickOutSideToDismiss: (v) => {
|
||||
setStack((state) =>
|
||||
produce(state, (draft) => {
|
||||
const model = draft.find((modal) => modal.id === item.id)
|
||||
if (!model) return
|
||||
if (model.clickOutsideToDismiss === v) return
|
||||
model.clickOutsideToDismiss = v
|
||||
}),
|
||||
)
|
||||
},
|
||||
}),
|
||||
[close, getIndex, item.id, setStack],
|
||||
)
|
||||
useModalSubscriber(item.id, ModalProps)
|
||||
|
||||
const ModalContextProps = useMemo<CurrentModalContentProps>(
|
||||
() => ({
|
||||
...ModalProps,
|
||||
ref: { current: modalContentRef },
|
||||
modalElementRef,
|
||||
}),
|
||||
[ModalProps, modalContentRef],
|
||||
)
|
||||
|
||||
const [edgeElementRef, setEdgeElementRef] = useState<HTMLDivElement | null>(null)
|
||||
|
||||
const finalChildren = useMemo(
|
||||
() => (
|
||||
<AppErrorBoundary errorType={ErrorComponentType.Modal}>
|
||||
<RootPortalContext value={edgeElementRef as HTMLElement}>
|
||||
{children ?? createElement(content, ModalProps)}
|
||||
</RootPortalContext>
|
||||
</AppErrorBoundary>
|
||||
),
|
||||
[ModalProps, children, content, edgeElementRef],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (currentIsClosing) {
|
||||
// Radix dialog will block pointer events
|
||||
document.body.style.pointerEvents = "auto"
|
||||
}
|
||||
}, [currentIsClosing])
|
||||
|
||||
useShortcutScope()
|
||||
|
||||
const modalStyle = resizeableStyle
|
||||
const { handleSelectStart, handleDetectSelectEnd, isSelectingRef } = useModalSelect()
|
||||
const handleClickOutsideToDismiss = useCallback(
|
||||
(e: SyntheticEvent) => {
|
||||
if (isSelectingRef.current) return
|
||||
const fn = modal ? (clickOutsideToDismiss && canClose ? dismiss : noticeModal) : undefined
|
||||
fn?.(e)
|
||||
},
|
||||
[canClose, clickOutsideToDismiss, dismiss, modal, noticeModal, isSelectingRef],
|
||||
)
|
||||
|
||||
const openAutoFocus = useCallback(
|
||||
(event: Event) => {
|
||||
if (!autoFocus) {
|
||||
event.preventDefault()
|
||||
}
|
||||
},
|
||||
[autoFocus],
|
||||
)
|
||||
|
||||
const measureDragConstraints = useRef((constraints: BoundingBox) => {
|
||||
if (getOS() === "Windows") {
|
||||
return {
|
||||
...constraints,
|
||||
top: constraints.top + ElECTRON_CUSTOM_TITLEBAR_HEIGHT,
|
||||
}
|
||||
}
|
||||
return constraints
|
||||
}).current
|
||||
|
||||
useImperativeHandle(ref, () => modalElementRef.current!)
|
||||
const currentModalZIndex = MODAL_STACK_Z_INDEX + index * 2
|
||||
|
||||
const Overlay = (
|
||||
<ModalOverlay
|
||||
zIndex={currentModalZIndex - 1}
|
||||
blur={overlayOptions?.blur}
|
||||
hidden={
|
||||
item.overlay ? currentIsClosing : !(modalSettingOverlay && isBottom) || currentIsClosing
|
||||
}
|
||||
/>
|
||||
)
|
||||
|
||||
const mutateableEdgeElementRef = useRefValue(edgeElementRef)
|
||||
|
||||
if (CustomModalComponent) {
|
||||
return (
|
||||
<Wrapper>
|
||||
<Dialog.Root modal={modal} open onOpenChange={onClose}>
|
||||
<Dialog.Root open onOpenChange={onClose} modal={modal}>
|
||||
<Dialog.Portal>
|
||||
{Overlay}
|
||||
<Dialog.DialogTitle className="sr-only">{title}</Dialog.DialogTitle>
|
||||
<Dialog.Content
|
||||
ref={setModalContentRef}
|
||||
asChild
|
||||
@@ -305,103 +255,153 @@ export const ModalInternal = memo(
|
||||
>
|
||||
<div
|
||||
ref={setEdgeElementRef}
|
||||
onContextMenu={preventDefault}
|
||||
className={cn(
|
||||
"fixed flex",
|
||||
"no-drag-region fixed",
|
||||
modal ? "inset-0 overflow-auto" : "left-0 top-0",
|
||||
currentIsClosing && "!pointer-events-none",
|
||||
currentIsClosing ? "!pointer-events-none" : "!pointer-events-auto",
|
||||
modalContainerClassName,
|
||||
!isResizeable && "center",
|
||||
)}
|
||||
onFocus={stopPropagation}
|
||||
onPointerUp={handleDetectSelectEnd}
|
||||
onClick={handleClickOutsideToDismiss}
|
||||
style={{
|
||||
zIndex: currentModalZIndex,
|
||||
}}
|
||||
onPointerUp={handleDetectSelectEnd}
|
||||
onClick={handleClickOutsideToDismiss}
|
||||
onFocus={stopPropagation}
|
||||
tabIndex={-1}
|
||||
>
|
||||
{DragBar}
|
||||
|
||||
<m.div
|
||||
ref={modalElementRef}
|
||||
style={modalStyle}
|
||||
{...modalMontionConfig}
|
||||
animate={animateController}
|
||||
className={cn(
|
||||
"relative flex flex-col overflow-hidden rounded-lg px-2 pt-2",
|
||||
"bg-background",
|
||||
"shadow-modal",
|
||||
max ? "h-[90vh] w-[90vw]" : "max-h-[90vh]",
|
||||
|
||||
"border-border border",
|
||||
modalClassName,
|
||||
)}
|
||||
tabIndex={-1}
|
||||
<div
|
||||
className={cn("contents", modalClassName, modalContentClassName)}
|
||||
onClick={stopPropagation}
|
||||
tabIndex={-1}
|
||||
ref={modalElementRef}
|
||||
onSelect={handleSelectStart}
|
||||
onKeyUp={handleDetectSelectEnd}
|
||||
drag={draggable && (preferDragDir || draggable)}
|
||||
dragControls={dragController}
|
||||
dragElastic={0}
|
||||
dragListener={false}
|
||||
dragMomentum={false}
|
||||
dragConstraints={mutateableEdgeElementRef}
|
||||
onMeasureDragConstraints={measureDragConstraints}
|
||||
whileDrag={{
|
||||
cursor: "grabbing",
|
||||
}}
|
||||
>
|
||||
<ResizeSwitch
|
||||
// enable={resizableOnly("bottomRight")}
|
||||
onResizeStart={handleResizeStart}
|
||||
onResizeStop={handleResizeStop}
|
||||
defaultSize={resizeDefaultSize}
|
||||
className="flex grow flex-col"
|
||||
>
|
||||
<div className={"relative flex items-center"}>
|
||||
<Dialog.Title
|
||||
className="flex w-0 max-w-full grow items-center gap-2 px-2 py-1 text-lg font-semibold"
|
||||
onPointerDownCapture={handleDrag}
|
||||
onPointerDown={relocateModal}
|
||||
>
|
||||
{!!icon && <span className="size-4">{icon}</span>}
|
||||
<EllipsisHorizontalTextWithTooltip className="truncate">
|
||||
<span>{title}</span>
|
||||
</EllipsisHorizontalTextWithTooltip>
|
||||
</Dialog.Title>
|
||||
{canClose && (
|
||||
<Dialog.DialogClose
|
||||
className="center hover:bg-material-ultra-thick z-[2] rounded-lg p-2"
|
||||
tabIndex={1}
|
||||
onClick={close}
|
||||
>
|
||||
<i className="i-mgc-close-cute-re" />
|
||||
</Dialog.DialogClose>
|
||||
)}
|
||||
</div>
|
||||
<div className="bg-border mx-1 mt-2 h-px shrink-0" />
|
||||
|
||||
<div
|
||||
className={cn(
|
||||
"-mx-2 min-h-0 shrink grow overflow-auto p-4",
|
||||
modalContentClassName,
|
||||
)}
|
||||
>
|
||||
<ModalContext modalContextProps={ModalContextProps} isTop={!!isTop}>
|
||||
{finalChildren}
|
||||
</ModalContext>
|
||||
</div>
|
||||
</ResizeSwitch>
|
||||
</m.div>
|
||||
<ModalContext modalContextProps={ModalContextProps} isTop={!!isTop}>
|
||||
<CustomModalComponent>{finalChildren}</CustomModalComponent>
|
||||
</ModalContext>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog.Portal>
|
||||
</Dialog.Root>
|
||||
</Wrapper>
|
||||
)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
const ResizeSwitch = resizeable ? Resizable : SafeFragment
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<Dialog.Root modal={modal} open onOpenChange={onClose}>
|
||||
<Dialog.Portal>
|
||||
{Overlay}
|
||||
<Dialog.Content
|
||||
ref={setModalContentRef}
|
||||
asChild
|
||||
aria-describedby={undefined}
|
||||
onPointerDownOutside={preventDefault}
|
||||
onOpenAutoFocus={openAutoFocus}
|
||||
>
|
||||
<div
|
||||
ref={setEdgeElementRef}
|
||||
onContextMenu={preventDefault}
|
||||
className={cn(
|
||||
"fixed flex",
|
||||
modal ? "inset-0 overflow-auto" : "left-0 top-0",
|
||||
currentIsClosing && "!pointer-events-none",
|
||||
modalContainerClassName,
|
||||
!isResizeable && "center",
|
||||
)}
|
||||
onFocus={stopPropagation}
|
||||
onPointerUp={handleDetectSelectEnd}
|
||||
onClick={handleClickOutsideToDismiss}
|
||||
style={{
|
||||
zIndex: currentModalZIndex,
|
||||
}}
|
||||
tabIndex={-1}
|
||||
>
|
||||
{DragBar}
|
||||
|
||||
<m.div
|
||||
ref={modalElementRef}
|
||||
style={modalStyle}
|
||||
{...modalMontionConfig}
|
||||
animate={animateController}
|
||||
className={cn(
|
||||
"relative flex flex-col overflow-hidden rounded-lg px-2 pt-2",
|
||||
"bg-background",
|
||||
"shadow-modal",
|
||||
max ? "h-[90vh] w-[90vw]" : "max-h-[90vh]",
|
||||
|
||||
"border-border border",
|
||||
modalClassName,
|
||||
)}
|
||||
tabIndex={-1}
|
||||
onClick={stopPropagation}
|
||||
onSelect={handleSelectStart}
|
||||
onKeyUp={handleDetectSelectEnd}
|
||||
drag={draggable && (preferDragDir || draggable)}
|
||||
dragControls={dragController}
|
||||
dragElastic={0}
|
||||
dragListener={false}
|
||||
dragMomentum={false}
|
||||
dragConstraints={mutateableEdgeElementRef}
|
||||
onMeasureDragConstraints={measureDragConstraints}
|
||||
whileDrag={{
|
||||
cursor: "grabbing",
|
||||
}}
|
||||
>
|
||||
<ResizeSwitch
|
||||
// enable={resizableOnly("bottomRight")}
|
||||
onResizeStart={handleResizeStart}
|
||||
onResizeStop={handleResizeStop}
|
||||
defaultSize={resizeDefaultSize}
|
||||
className="flex grow flex-col"
|
||||
>
|
||||
<div className={"relative flex items-center"}>
|
||||
<Dialog.Title
|
||||
className="flex w-0 max-w-full grow items-center gap-2 px-2 py-1 text-lg font-semibold"
|
||||
onPointerDownCapture={handleDrag}
|
||||
onPointerDown={relocateModal}
|
||||
>
|
||||
{!!icon && <span className="size-4">{icon}</span>}
|
||||
<EllipsisHorizontalTextWithTooltip className="truncate">
|
||||
<span>{title}</span>
|
||||
</EllipsisHorizontalTextWithTooltip>
|
||||
</Dialog.Title>
|
||||
{canClose && (
|
||||
<Dialog.DialogClose
|
||||
className="center hover:bg-material-ultra-thick z-[2] rounded-lg p-2"
|
||||
tabIndex={1}
|
||||
onClick={close}
|
||||
>
|
||||
<i className="i-mgc-close-cute-re" />
|
||||
</Dialog.DialogClose>
|
||||
)}
|
||||
</div>
|
||||
<div className="bg-border mx-1 mt-2 h-px shrink-0" />
|
||||
|
||||
<div
|
||||
className={cn(
|
||||
"-mx-2 min-h-0 shrink grow overflow-auto p-4",
|
||||
modalContentClassName,
|
||||
)}
|
||||
>
|
||||
<ModalContext modalContextProps={ModalContextProps} isTop={!!isTop}>
|
||||
{finalChildren}
|
||||
</ModalContext>
|
||||
</div>
|
||||
</ResizeSwitch>
|
||||
</m.div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog.Portal>
|
||||
</Dialog.Root>
|
||||
</Wrapper>
|
||||
)
|
||||
})
|
||||
|
||||
const useShortcutScope = () => {
|
||||
const switchHotkeyScope = useSwitchHotKeyScope()
|
||||
@@ -428,7 +428,8 @@ const ModalContext: FC<
|
||||
)
|
||||
|
||||
return (
|
||||
<CurrentModalContext.Provider value={modalContextProps}>
|
||||
<CurrentModalContext value={modalContextProps}>
|
||||
{/* eslint-disable-next-line @eslint-react/no-context-provider */}
|
||||
<CurrentModalStateContext.Provider
|
||||
value={useMemo(
|
||||
() => ({
|
||||
@@ -440,6 +441,6 @@ const ModalContext: FC<
|
||||
>
|
||||
<ZIndexProvider zIndex={zIndex}>{children}</ZIndexProvider>
|
||||
</CurrentModalStateContext.Provider>
|
||||
</CurrentModalContext.Provider>
|
||||
</CurrentModalContext>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,45 +1,35 @@
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import * as Dialog from "@radix-ui/react-dialog"
|
||||
import { AnimatePresence } from "motion/react"
|
||||
import type { ForwardedRef } from "react"
|
||||
import { forwardRef } from "react"
|
||||
import type { FC } from "react"
|
||||
|
||||
import { m } from "~/components/common/Motion"
|
||||
|
||||
export const ModalOverlay = forwardRef(
|
||||
(
|
||||
{
|
||||
zIndex,
|
||||
blur,
|
||||
className,
|
||||
hidden,
|
||||
}: {
|
||||
zIndex?: number
|
||||
blur?: boolean
|
||||
className?: string
|
||||
hidden?: boolean
|
||||
},
|
||||
ref: ForwardedRef<HTMLDivElement>,
|
||||
) => (
|
||||
<Dialog.Overlay>
|
||||
<AnimatePresence>
|
||||
{!hidden && (
|
||||
<m.div
|
||||
ref={ref}
|
||||
id="modal-overlay"
|
||||
className={cn(
|
||||
// NOTE: pointer-events-none is required, if remove this, when modal is closing, you can not click element behind the modal
|
||||
"bg-material-ultra-thick !pointer-events-none fixed inset-0 rounded-[var(--fo-window-radius)]",
|
||||
blur && "backdrop-blur-sm",
|
||||
className,
|
||||
)}
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
style={{ zIndex }}
|
||||
/>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</Dialog.Overlay>
|
||||
),
|
||||
export const ModalOverlay: FC<{
|
||||
ref?: React.Ref<HTMLDivElement | null>
|
||||
zIndex?: number
|
||||
blur?: boolean
|
||||
className?: string
|
||||
hidden?: boolean
|
||||
}> = ({ ref, zIndex, blur, className, hidden }) => (
|
||||
<Dialog.Overlay>
|
||||
<AnimatePresence>
|
||||
{!hidden && (
|
||||
<m.div
|
||||
ref={ref}
|
||||
id="modal-overlay"
|
||||
className={cn(
|
||||
// NOTE: pointer-events-none is required, if remove this, when modal is closing, you can not click element behind the modal
|
||||
"bg-material-ultra-thick !pointer-events-none fixed inset-0 rounded-[var(--fo-window-radius)]",
|
||||
blur && "backdrop-blur-sm",
|
||||
className,
|
||||
)}
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
style={{ zIndex }}
|
||||
/>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</Dialog.Overlay>
|
||||
)
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { getReadonlyRoute, useReadonlyRouteSelector } from "@follow/components/atoms/route.js"
|
||||
import {
|
||||
getReadonlyRoute,
|
||||
useReadonlyRoute,
|
||||
useReadonlyRouteSelector,
|
||||
} from "@follow/components/atoms/route.js"
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { isBizId } from "@follow/utils/utils"
|
||||
import { useMemo } from "react"
|
||||
import type { Params } from "react-router"
|
||||
import { useParams } from "react-router"
|
||||
|
||||
@@ -79,7 +84,8 @@ const parseRouteParams = (params: Params<any>): BizRouteParams => {
|
||||
}
|
||||
|
||||
export const useRouteParams = () => {
|
||||
return useRouteParamsSelector((s) => s)
|
||||
const route = useReadonlyRoute()
|
||||
return useMemo(() => parseRouteParams(route.params), [route.params])
|
||||
}
|
||||
|
||||
const noop = [] as any[]
|
||||
|
||||
@@ -39,27 +39,27 @@ export const parseHtml = (
|
||||
},
|
||||
img: Img,
|
||||
|
||||
h1: (props) => {
|
||||
h1: ({ ref, ...props }) => {
|
||||
markInlineImage(props.node)
|
||||
return createHeadingRenderer(1)(props)
|
||||
},
|
||||
h2: (props) => {
|
||||
h2: ({ ref, ...props }) => {
|
||||
markInlineImage(props.node)
|
||||
return createHeadingRenderer(2)(props)
|
||||
},
|
||||
h3: (props) => {
|
||||
h3: ({ ref, ...props }) => {
|
||||
markInlineImage(props.node)
|
||||
return createHeadingRenderer(3)(props)
|
||||
},
|
||||
h4: (props) => {
|
||||
h4: ({ ref, ...props }) => {
|
||||
markInlineImage(props.node)
|
||||
return createHeadingRenderer(4)(props)
|
||||
},
|
||||
h5: (props) => {
|
||||
h5: ({ ref, ...props }) => {
|
||||
markInlineImage(props.node)
|
||||
return createHeadingRenderer(5)(props)
|
||||
},
|
||||
h6: (props) => {
|
||||
h6: ({ ref, ...props }) => {
|
||||
markInlineImage(props.node)
|
||||
return createHeadingRenderer(6)(props)
|
||||
},
|
||||
@@ -67,7 +67,7 @@ export const parseHtml = (
|
||||
|
||||
video: ({ node, ...props }) =>
|
||||
createElement(Media, { ...props, popper: true, type: "video" }),
|
||||
p: ({ node, ...props }) => {
|
||||
p: ({ node, ref, ...props }) => {
|
||||
if (node?.children && node.children.length !== 1) {
|
||||
for (const item of node.children) {
|
||||
item.type === "element" &&
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useSetAtom } from "jotai"
|
||||
import type { FC } from "react"
|
||||
import { useContext } from "react"
|
||||
import { use } from "react"
|
||||
|
||||
import { EntryContentPlaceholderContext } from "~/modules/app-layout/entry-content/EntryContentPlaceholderContext"
|
||||
|
||||
@@ -26,7 +26,7 @@ export const EntryPlaceholderDaily = ({
|
||||
const NormalDailyReportTitle: FC<DailyItemProps> = ({ day }) => {
|
||||
const { title, startDate, endDate } = useParseDailyDate(day)
|
||||
|
||||
const setOpenedSummary = useSetAtom(useContext(EntryContentPlaceholderContext).openedSummary)
|
||||
const setOpenedSummary = useSetAtom(use(EntryContentPlaceholderContext).openedSummary)
|
||||
|
||||
return (
|
||||
<button
|
||||
|
||||
@@ -31,7 +31,7 @@ export function CenterColumnDesktop() {
|
||||
min: isSafari() ? 356 : 300,
|
||||
max: Math.max((window.innerWidth - feedColumnWidth) / 2, 600),
|
||||
initial: entryColWidth,
|
||||
containerRef,
|
||||
containerRef: containerRef as React.RefObject<HTMLElement>,
|
||||
onResizeEnd({ position }) {
|
||||
setUISetting("entryColWidth", position)
|
||||
// TODO: Remove this after useMeasure can get bounds in time
|
||||
|
||||
+3
-3
@@ -30,7 +30,7 @@ export const EntryContentPlaceholder = () => {
|
||||
const openedSummary = useAtomValue(ctxValue.openedSummary)
|
||||
return (
|
||||
<LayoutGroup>
|
||||
<EntryContentPlaceholderContext.Provider value={ctxValue}>
|
||||
<EntryContentPlaceholderContext value={ctxValue}>
|
||||
<AnimatePresence>
|
||||
{openedSummary === null ? (
|
||||
<m.div
|
||||
@@ -47,14 +47,14 @@ export const EntryContentPlaceholder = () => {
|
||||
<SummaryDetailContent />
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</EntryContentPlaceholderContext.Provider>
|
||||
</EntryContentPlaceholderContext>
|
||||
</LayoutGroup>
|
||||
)
|
||||
}
|
||||
|
||||
const SummaryDetailContent = () => {
|
||||
const { view } = useRouteParams()
|
||||
const ctxValue = React.useContext(EntryContentPlaceholderContext)
|
||||
const ctxValue = React.use(EntryContentPlaceholderContext)
|
||||
const openedSummary = useAtomValue(ctxValue.openedSummary)
|
||||
const setOpenedSummary = useSetAtom(ctxValue.openedSummary)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import { Slot } from "@radix-ui/react-slot"
|
||||
import { debounce } from "es-toolkit/compat"
|
||||
import type { PropsWithChildren } from "react"
|
||||
import * as React from "react"
|
||||
import { forwardRef, Suspense, useEffect, useRef, useState } from "react"
|
||||
import { Suspense, useEffect, useRef, useState } from "react"
|
||||
import { useHotkeys } from "react-hotkeys-hook"
|
||||
import { Trans } from "react-i18next"
|
||||
import { useResizable } from "react-resizable-layout"
|
||||
@@ -64,7 +64,7 @@ export function MainDestopLayout() {
|
||||
const isAuthFail = useLoginModalShow()
|
||||
const user = useWhoami()
|
||||
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
const containerRef = useRef<HTMLDivElement | null>(null)
|
||||
|
||||
useDailyTask()
|
||||
|
||||
@@ -156,7 +156,10 @@ export function MainDestopLayout() {
|
||||
)
|
||||
}
|
||||
|
||||
const RootContainer = forwardRef<HTMLDivElement, PropsWithChildren>(({ children }, ref) => {
|
||||
const RootContainer = ({
|
||||
ref,
|
||||
children,
|
||||
}: PropsWithChildren & { ref?: React.Ref<HTMLDivElement | null> }) => {
|
||||
const feedColWidth = useUISettingKey("feedColWidth")
|
||||
|
||||
const [elementRef, _setElementRef] = useState<HTMLDivElement | null>(null)
|
||||
@@ -180,20 +183,20 @@ const RootContainer = forwardRef<HTMLDivElement, PropsWithChildren>(({ children
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const FeedResponsiveResizerContainer = ({
|
||||
containerRef,
|
||||
children,
|
||||
}: {
|
||||
containerRef: React.RefObject<HTMLDivElement>
|
||||
containerRef: React.RefObject<HTMLDivElement | null>
|
||||
} & PropsWithChildren) => {
|
||||
const { isDragging, position, separatorProps, separatorCursor } = useResizable({
|
||||
axis: "x",
|
||||
min: 256,
|
||||
max: 300,
|
||||
initial: getUISettings().feedColWidth,
|
||||
containerRef,
|
||||
containerRef: containerRef as React.RefObject<HTMLElement>,
|
||||
|
||||
onResizeEnd({ position }) {
|
||||
setUISetting("feedColWidth", position)
|
||||
|
||||
@@ -69,7 +69,7 @@ export const FeedForm: Component<{
|
||||
const { t } = useTranslation()
|
||||
|
||||
const isInModal = useIsInModal()
|
||||
const placeholderRef = useRef<HTMLDivElement>(null)
|
||||
const placeholderRef = useRef<HTMLDivElement | null>(null)
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -181,7 +181,7 @@ const FeedInnerForm = ({
|
||||
entries?: EntryModelSimple[]
|
||||
analytics?: FeedAnalyticsModel
|
||||
|
||||
placeholderRef: React.RefObject<HTMLDivElement>
|
||||
placeholderRef: React.RefObject<HTMLDivElement | null>
|
||||
}) => {
|
||||
const subscription = useSubscriptionByFeedId(id || "") || subscriptionData
|
||||
const isSubscribed = !!subscription
|
||||
|
||||
+5
-4
@@ -54,9 +54,10 @@ export function PictureItemStateLess({ entry }: EntryItemStatelessProps) {
|
||||
|
||||
return (
|
||||
<div className="text-text relative w-full select-none rounded-md transition-colors" ref={ref}>
|
||||
<MasonryItemWidthContext.Provider value={currentItemWidth}>
|
||||
<MasonryItemWidthContext value={currentItemWidth}>
|
||||
{/* eslint-disable-next-line @eslint-react/no-context-provider */}
|
||||
<MasonryItemsAspectRatioContext.Provider value={masonryItemsRadio}>
|
||||
<MasonryItemsAspectRatioSetterContext.Provider value={setMasonryItemsRadio}>
|
||||
<MasonryItemsAspectRatioSetterContext value={setMasonryItemsRadio}>
|
||||
<MediaContainerWidthProvider width={currentItemWidth}>
|
||||
<Masonry
|
||||
items={mediaItems}
|
||||
@@ -67,9 +68,9 @@ export function PictureItemStateLess({ entry }: EntryItemStatelessProps) {
|
||||
render={MasonryRender}
|
||||
/>
|
||||
</MediaContainerWidthProvider>
|
||||
</MasonryItemsAspectRatioSetterContext.Provider>
|
||||
</MasonryItemsAspectRatioSetterContext>
|
||||
</MasonryItemsAspectRatioContext.Provider>
|
||||
</MasonryItemWidthContext.Provider>
|
||||
</MasonryItemWidthContext>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import type { PropsWithChildren } from "react"
|
||||
import { memo, useContext, useEffect, useMemo, useState } from "react"
|
||||
import { memo, use, useEffect, useMemo, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { SwipeMedia } from "~/components/ui/media/SwipeMedia"
|
||||
@@ -77,7 +77,7 @@ export const PictureWaterFallItem = memo(function PictureWaterFallItem({
|
||||
const itemWidth = useMasonryItemWidth()
|
||||
|
||||
const [ref, setRef] = useState<HTMLDivElement | null>(null)
|
||||
const intersectionObserver = useContext(MasonryIntersectionContext)
|
||||
const intersectionObserver = use(MasonryIntersectionContext)
|
||||
|
||||
useEffect(() => {
|
||||
if (!ref || !intersectionObserver) return
|
||||
|
||||
@@ -16,8 +16,8 @@ import type { FC, ReactNode } from "react"
|
||||
import {
|
||||
createContext,
|
||||
startTransition,
|
||||
use,
|
||||
useCallback,
|
||||
useContext,
|
||||
useDeferredValue,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
@@ -115,7 +115,7 @@ export const PictureMasonry: FC<MasonryProps> = (props) => {
|
||||
threshold: 3,
|
||||
})
|
||||
|
||||
const currentRange = useRef<{ start: number; end: number }>()
|
||||
const currentRange = useRef<{ start: number; end: number }>(undefined)
|
||||
const handleRender = useCallback(
|
||||
(startIndex: number, stopIndex: number, items: any[]) => {
|
||||
currentRange.current = { start: startIndex, end: stopIndex }
|
||||
@@ -212,12 +212,13 @@ export const PictureMasonry: FC<MasonryProps> = (props) => {
|
||||
return (
|
||||
<div ref={containerRef} className="mx-4 pt-2">
|
||||
{isInitDim && deferIsInitLayout && (
|
||||
<MasonryItemWidthContext.Provider value={finalItemWidth}>
|
||||
<MasonryItemWidthContext value={finalItemWidth}>
|
||||
{/* eslint-disable-next-line @eslint-react/no-context-provider */}
|
||||
<MasonryItemsAspectRatioContext.Provider value={masonryItemsRadio}>
|
||||
<MasonryItemsAspectRatioSetterContext.Provider value={setMasonryItemsRadio}>
|
||||
<MasonryIntersectionContext.Provider value={intersectionObserver}>
|
||||
<MasonryItemsAspectRatioSetterContext value={setMasonryItemsRadio}>
|
||||
<MasonryIntersectionContext value={intersectionObserver}>
|
||||
<MediaContainerWidthProvider width={finalItemWidth}>
|
||||
<FirstScreenReadyContext.Provider value={firstScreenReady}>
|
||||
<FirstScreenReadyContext value={firstScreenReady}>
|
||||
<Masonry
|
||||
items={firstScreenReady ? items : items.slice(0, FirstScreenItemCount)}
|
||||
columnGutter={gutter}
|
||||
@@ -237,12 +238,12 @@ export const PictureMasonry: FC<MasonryProps> = (props) => {
|
||||
<div className="mb-4">{props.Footer}</div>
|
||||
)
|
||||
) : null}
|
||||
</FirstScreenReadyContext.Provider>
|
||||
</FirstScreenReadyContext>
|
||||
</MediaContainerWidthProvider>
|
||||
</MasonryIntersectionContext.Provider>
|
||||
</MasonryItemsAspectRatioSetterContext.Provider>
|
||||
</MasonryIntersectionContext>
|
||||
</MasonryItemsAspectRatioSetterContext>
|
||||
</MasonryItemsAspectRatioContext.Provider>
|
||||
</MasonryItemWidthContext.Provider>
|
||||
</MasonryItemWidthContext>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
@@ -254,7 +255,7 @@ const MasonryRender: React.ComponentType<
|
||||
entryId: string
|
||||
}>
|
||||
> = ({ data, index }) => {
|
||||
const firstScreenReady = useContext(FirstScreenReadyContext)
|
||||
const firstScreenReady = use(FirstScreenReadyContext)
|
||||
const entry = useEntry(data.entryId)
|
||||
const translation = useEntryTranslation({ entry })
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ const DateItemInner: FC<DateItemInnerProps> = ({
|
||||
},
|
||||
)
|
||||
|
||||
const timerRef = useRef<any>()
|
||||
const timerRef = useRef<any>(undefined)
|
||||
const W = Wrapper ?? SafeFragment
|
||||
|
||||
const { feedId } = useRouteParams()
|
||||
|
||||
+71
-68
@@ -3,7 +3,7 @@ import { Kbd, KbdCombined } from "@follow/components/ui/kbd/Kbd.js"
|
||||
import { useCountdown } from "@follow/hooks"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import type { FC, ReactNode } from "react"
|
||||
import { forwardRef, useState } from "react"
|
||||
import { useState } from "react"
|
||||
import { useHotkeys } from "react-hotkeys-hook"
|
||||
import { Trans, useTranslation } from "react-i18next"
|
||||
import { toast } from "sonner"
|
||||
@@ -21,76 +21,79 @@ interface MarkAllButtonProps {
|
||||
shortcut?: boolean
|
||||
}
|
||||
|
||||
export const MarkAllReadButton = forwardRef<HTMLButtonElement, MarkAllButtonProps>(
|
||||
({ className, which = "all", shortcut }, ref) => {
|
||||
const { t } = useTranslation()
|
||||
const { t: commonT } = useTranslation("common")
|
||||
export const MarkAllReadButton = ({
|
||||
ref,
|
||||
className,
|
||||
which = "all",
|
||||
shortcut,
|
||||
}: MarkAllButtonProps & { ref?: React.Ref<HTMLButtonElement | null> }) => {
|
||||
const { t } = useTranslation()
|
||||
const { t: commonT } = useTranslation("common")
|
||||
|
||||
useHotkeys(
|
||||
shortcuts.entries.markAllAsRead.key,
|
||||
() => {
|
||||
let cancel = false
|
||||
const undo = () => {
|
||||
toast.dismiss(id)
|
||||
useHotkeys(
|
||||
shortcuts.entries.markAllAsRead.key,
|
||||
() => {
|
||||
let cancel = false
|
||||
const undo = () => {
|
||||
toast.dismiss(id)
|
||||
if (cancel) return
|
||||
cancel = true
|
||||
}
|
||||
const id = toast("", {
|
||||
description: <ConfirmMarkAllReadInfo undo={undo} />,
|
||||
duration: 3000,
|
||||
onAutoClose() {
|
||||
if (cancel) return
|
||||
cancel = true
|
||||
}
|
||||
const id = toast("", {
|
||||
description: <ConfirmMarkAllReadInfo undo={undo} />,
|
||||
duration: 3000,
|
||||
onAutoClose() {
|
||||
if (cancel) return
|
||||
markAllByRoute()
|
||||
},
|
||||
action: {
|
||||
label: (
|
||||
<span className="flex items-center gap-1">
|
||||
{t("mark_all_read_button.undo")}
|
||||
<Kbd className="border-border inline-flex items-center border bg-transparent dark:text-white">
|
||||
Meta+Z
|
||||
</Kbd>
|
||||
</span>
|
||||
),
|
||||
onClick: undo,
|
||||
},
|
||||
})
|
||||
},
|
||||
{
|
||||
preventDefault: true,
|
||||
scopes: HotKeyScopeMap.Home,
|
||||
},
|
||||
)
|
||||
|
||||
return (
|
||||
<ActionButton
|
||||
tooltip={
|
||||
<>
|
||||
<Trans
|
||||
i18nKey="mark_all_read_button.mark_as_read"
|
||||
components={{
|
||||
which: <>{commonT(`words.which.${which}` as any)}</>,
|
||||
}}
|
||||
/>
|
||||
{shortcut && (
|
||||
<div className="ml-1">
|
||||
<KbdCombined className="text-text-secondary">
|
||||
{shortcuts.entries.markAllAsRead.key}
|
||||
</KbdCombined>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
className={className}
|
||||
ref={ref}
|
||||
onClick={() => {
|
||||
markAllByRoute()
|
||||
}}
|
||||
>
|
||||
<i className="i-mgc-check-circle-cute-re" />
|
||||
</ActionButton>
|
||||
)
|
||||
},
|
||||
)
|
||||
},
|
||||
action: {
|
||||
label: (
|
||||
<span className="flex items-center gap-1">
|
||||
{t("mark_all_read_button.undo")}
|
||||
<Kbd className="border-border inline-flex items-center border bg-transparent dark:text-white">
|
||||
Meta+Z
|
||||
</Kbd>
|
||||
</span>
|
||||
),
|
||||
onClick: undo,
|
||||
},
|
||||
})
|
||||
},
|
||||
{
|
||||
preventDefault: true,
|
||||
scopes: HotKeyScopeMap.Home,
|
||||
},
|
||||
)
|
||||
|
||||
return (
|
||||
<ActionButton
|
||||
tooltip={
|
||||
<>
|
||||
<Trans
|
||||
i18nKey="mark_all_read_button.mark_as_read"
|
||||
components={{
|
||||
which: <>{commonT(`words.which.${which}` as any)}</>,
|
||||
}}
|
||||
/>
|
||||
{shortcut && (
|
||||
<div className="ml-1">
|
||||
<KbdCombined className="text-text-secondary">
|
||||
{shortcuts.entries.markAllAsRead.key}
|
||||
</KbdCombined>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
className={className}
|
||||
ref={ref}
|
||||
onClick={() => {
|
||||
markAllByRoute()
|
||||
}}
|
||||
>
|
||||
<i className="i-mgc-check-circle-cute-re" />
|
||||
</ActionButton>
|
||||
)
|
||||
}
|
||||
|
||||
const ConfirmMarkAllReadInfo = ({ undo }: { undo: () => any }) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
@@ -75,7 +75,7 @@ const VirtualGrid: FC<EntryListProps> = (props) => {
|
||||
}
|
||||
}, [scrollRef])
|
||||
|
||||
const measureRef = useRef<() => void>()
|
||||
const measureRef = useRef<() => void>(undefined)
|
||||
|
||||
if (!containerWidth) return null
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { views } from "@follow/constants"
|
||||
import { isBizId } from "@follow/utils/utils"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { debounce } from "es-toolkit/compat"
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
||||
import { toast } from "sonner"
|
||||
|
||||
import { useGeneralSettingKey } from "~/atoms/settings/general"
|
||||
import { useRouteParams } from "~/hooks/biz/useRouteParams"
|
||||
@@ -12,9 +14,39 @@ import { entryActions, getEntry, useEntryIdsByFeedIdOrView } from "~/store/entry
|
||||
import { useFolderFeedsByFeedId } from "~/store/subscription"
|
||||
import { feedUnreadActions } from "~/store/unread"
|
||||
|
||||
const anyString = [] as string[]
|
||||
export const useEntriesByView = ({ onReset }: { onReset?: () => void }) => {
|
||||
const { feedId, isAllFeeds, view, isCollection, inboxId, listId, isPreview } = useRouteParams()
|
||||
interface UseEntriesReturn {
|
||||
entriesIds: string[]
|
||||
hasNext: boolean
|
||||
hasUpdate: boolean
|
||||
refetch: () => Promise<void>
|
||||
|
||||
fetchNextPage: () => Promise<void>
|
||||
isLoading: boolean
|
||||
isReady: boolean
|
||||
isFetching: boolean
|
||||
isFetchingNextPage: boolean
|
||||
|
||||
hasNextPage: boolean
|
||||
error: Error | null
|
||||
}
|
||||
|
||||
const fallbackReturn: UseEntriesReturn = {
|
||||
entriesIds: [],
|
||||
hasNext: false,
|
||||
hasUpdate: false,
|
||||
refetch: async () => {},
|
||||
|
||||
fetchNextPage: async () => {},
|
||||
|
||||
isLoading: true,
|
||||
isReady: false,
|
||||
isFetching: false,
|
||||
isFetchingNextPage: false,
|
||||
hasNextPage: false,
|
||||
error: null,
|
||||
}
|
||||
const useRemoteEntries = (): UseEntriesReturn => {
|
||||
const { feedId, view, inboxId, listId, isPreview } = useRouteParams()
|
||||
|
||||
const unreadOnly = useGeneralSettingKey("unreadOnly")
|
||||
|
||||
@@ -68,26 +100,111 @@ export const useEntriesByView = ({ onReset }: { onReset?: () => void }) => {
|
||||
setPauseQuery(hasUpdate)
|
||||
}, [hasUpdate])
|
||||
|
||||
const remoteEntryIds = useMemo(() => {
|
||||
if (!query.data?.pages) return void 0
|
||||
// FIXME The back end should not return duplicate data, and the front end the unique id here.
|
||||
return [
|
||||
...new Set(
|
||||
query.data?.pages?.map((page) => page.data?.map((entry) => entry.entries.id)).flat(),
|
||||
).values(),
|
||||
] as string[]
|
||||
}, [query.data?.pages])
|
||||
useEffect(() => {
|
||||
if (query.isError) {
|
||||
toast.error(query.error.message)
|
||||
}
|
||||
}, [query.isError])
|
||||
|
||||
useFetchEntryContentByStream(remoteEntryIds)
|
||||
const refetch = useCallback(async () => void query.refetch(), [query])
|
||||
const fetchNextPage = useCallback(async () => void query.fetchNextPage(), [query])
|
||||
const entriesIds = useMemo(() => {
|
||||
if (!query.data || query.isLoading || query.isError) {
|
||||
return []
|
||||
}
|
||||
return query.data?.pages?.map((page) => page.data?.map((entry) => entry.entries.id)).flat()
|
||||
}, [query.data, query.isLoading, query.isError])
|
||||
|
||||
const currentEntries = useEntryIdsByFeedIdOrView(
|
||||
listId || inboxId || (isAllFeeds ? view : folderIds || feedId!),
|
||||
if (!query.data || query.isLoading) {
|
||||
return fallbackReturn
|
||||
}
|
||||
return {
|
||||
entriesIds,
|
||||
hasNext: query.hasNextPage,
|
||||
hasUpdate,
|
||||
refetch,
|
||||
|
||||
fetchNextPage,
|
||||
isLoading: query.isFetching,
|
||||
isReady: query.isSuccess,
|
||||
isFetchingNextPage: query.isFetchingNextPage,
|
||||
isFetching: query.isFetching,
|
||||
hasNextPage: query.hasNextPage,
|
||||
error: query.isError ? query.error : null,
|
||||
}
|
||||
}
|
||||
|
||||
const useLocalEntries = (): UseEntriesReturn => {
|
||||
const { feedId, view, inboxId, listId, isAllFeeds } = useRouteParams()
|
||||
|
||||
const unreadOnly = useGeneralSettingKey("unreadOnly")
|
||||
|
||||
const folderIds = useFolderFeedsByFeedId({
|
||||
feedId,
|
||||
view,
|
||||
})
|
||||
|
||||
const allEntries = useEntryIdsByFeedIdOrView(
|
||||
listId || inboxId || (isAllFeeds ? view : folderIds.length > 0 ? folderIds : feedId!),
|
||||
{
|
||||
unread: unreadOnly,
|
||||
view,
|
||||
},
|
||||
)
|
||||
|
||||
const [page, setPage] = useState(0)
|
||||
const pageSize = 30
|
||||
const totalPage = useMemo(
|
||||
() => (allEntries ? Math.ceil(allEntries.length / pageSize) : 0),
|
||||
[allEntries],
|
||||
)
|
||||
|
||||
const entries = useMemo(() => {
|
||||
return allEntries?.slice(0, (page + 1) * pageSize) || []
|
||||
}, [allEntries, page, pageSize])
|
||||
|
||||
const hasNext = useMemo(() => {
|
||||
return entries.length < (allEntries?.length || 0)
|
||||
}, [entries.length, allEntries])
|
||||
|
||||
const refetch = useCallback(async () => {
|
||||
setPage(0)
|
||||
}, [])
|
||||
|
||||
const fetchNextPage = useCallback(
|
||||
debounce(async () => {
|
||||
setPage(page + 1)
|
||||
}, 300),
|
||||
[page],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
setPage(0)
|
||||
}, [view, feedId])
|
||||
|
||||
return {
|
||||
entriesIds: entries,
|
||||
hasNext,
|
||||
hasUpdate: false,
|
||||
refetch,
|
||||
fetchNextPage: fetchNextPage as () => Promise<void>,
|
||||
isLoading: false,
|
||||
isReady: true,
|
||||
isFetchingNextPage: false,
|
||||
isFetching: false,
|
||||
hasNextPage: page < totalPage,
|
||||
error: null,
|
||||
}
|
||||
}
|
||||
|
||||
export const useEntriesByView = ({ onReset }: { onReset?: () => void }) => {
|
||||
const { feedId, view, isCollection, listId } = useRouteParams()
|
||||
|
||||
const remoteQuery = useRemoteEntries()
|
||||
const localQuery = useLocalEntries()
|
||||
|
||||
useFetchEntryContentByStream(remoteQuery.entriesIds)
|
||||
|
||||
// If remote data is not available, we use the local data, get the local data length
|
||||
// FIXME: remote first, then local store data
|
||||
// NOTE: We still can't use the store's data handling directly.
|
||||
@@ -95,7 +212,8 @@ export const useEntriesByView = ({ onReset }: { onReset?: () => void }) => {
|
||||
// then we have no way to incrementally update the data.
|
||||
// We need to add an interface to incrementally update the data based on the version hash.
|
||||
|
||||
const entryIds: string[] = remoteEntryIds || currentEntries || anyString
|
||||
const query = remoteQuery.isReady ? remoteQuery : localQuery
|
||||
const entryIds: string[] = query.entriesIds
|
||||
|
||||
// in unread only entries only can grow the data, but not shrink
|
||||
// so we memo this previous data to avoid the flicker
|
||||
@@ -167,7 +285,7 @@ export const useEntriesByView = ({ onReset }: { onReset?: () => void }) => {
|
||||
return {
|
||||
...query,
|
||||
|
||||
hasUpdate,
|
||||
hasUpdate: query.hasUpdate,
|
||||
refetch: useCallback(() => {
|
||||
const promise = query.refetch()
|
||||
feedUnreadActions.fetchUnreadByView(view)
|
||||
|
||||
@@ -25,7 +25,7 @@ import { EntryEmptyList, EntryList } from "./list"
|
||||
import { EntryColumnWrapper } from "./wrapper"
|
||||
|
||||
function EntryColumnImpl() {
|
||||
const listRef = useRef<Virtualizer<HTMLElement, Element>>()
|
||||
const listRef = useRef<Virtualizer<HTMLElement, Element>>(undefined)
|
||||
const entries = useEntriesByView({
|
||||
onReset: useCallback(() => {
|
||||
listRef.current?.scrollToIndex(0)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { FeedViewType } from "@follow/constants"
|
||||
import type { FC } from "react"
|
||||
import { forwardRef, memo } from "react"
|
||||
import { memo } from "react"
|
||||
|
||||
import { useEntryTranslation } from "~/store/ai/hook"
|
||||
import type { FlatEntryModel } from "~/store/entry"
|
||||
@@ -33,10 +33,16 @@ export const EntryItem: FC<EntryItemProps> = memo(({ entryId, view }) => {
|
||||
return <EntryItemImpl entry={entry} view={view} />
|
||||
})
|
||||
|
||||
export const EntryVirtualListItem = forwardRef<
|
||||
HTMLDivElement,
|
||||
EntryItemProps & React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
|
||||
>(({ entryId, view, className, ...props }, ref) => {
|
||||
export const EntryVirtualListItem = ({
|
||||
ref,
|
||||
entryId,
|
||||
view,
|
||||
className,
|
||||
...props
|
||||
}: EntryItemProps &
|
||||
React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
|
||||
ref?: React.Ref<HTMLDivElement | null>
|
||||
}) => {
|
||||
const entry = useEntry(entryId)
|
||||
|
||||
if (!entry) return <div ref={ref} {...props} style={undefined} />
|
||||
@@ -46,4 +52,4 @@ export const EntryVirtualListItem = forwardRef<
|
||||
<EntryItemImpl entry={entry} view={view} />
|
||||
</div>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -8,16 +8,7 @@ import type { Range, VirtualItem, Virtualizer } from "@tanstack/react-virtual"
|
||||
import { defaultRangeExtractor, useVirtualizer } from "@tanstack/react-virtual"
|
||||
import type { HTMLMotionProps } from "motion/react"
|
||||
import type { FC, MutableRefObject, ReactNode } from "react"
|
||||
import {
|
||||
forwardRef,
|
||||
Fragment,
|
||||
memo,
|
||||
startTransition,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react"
|
||||
import { Fragment, memo, startTransition, useEffect, useMemo, useRef, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
@@ -32,7 +23,10 @@ import { EntryColumnShortcutHandler } from "./EntryColumnShortcutHandler"
|
||||
import { EntryItemSkeleton } from "./EntryItemSkeleton"
|
||||
import { EntryVirtualListItem } from "./item"
|
||||
|
||||
export const EntryEmptyList = forwardRef<HTMLDivElement, HTMLMotionProps<"div">>((props, ref) => {
|
||||
export const EntryEmptyList = ({
|
||||
ref,
|
||||
...props
|
||||
}: HTMLMotionProps<"div"> & { ref?: React.Ref<HTMLDivElement | null> }) => {
|
||||
const unreadOnly = useGeneralSettingKey("unreadOnly")
|
||||
const { t } = useTranslation()
|
||||
return (
|
||||
@@ -54,7 +48,7 @@ export const EntryEmptyList = forwardRef<HTMLDivElement, HTMLMotionProps<"div">>
|
||||
)}
|
||||
</m.div>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export type EntryListProps = {
|
||||
feedId: string
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { ScrollArea } from "@follow/components/ui/scroll-area/ScrollArea.js"
|
||||
import { views } from "@follow/constants"
|
||||
import { clsx } from "clsx"
|
||||
import { forwardRef } from "react"
|
||||
|
||||
import { useIsZenMode } from "~/atoms/settings/ui"
|
||||
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
|
||||
@@ -9,29 +8,27 @@ 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)
|
||||
export const EntryColumnWrapper = ({ ref, children, onScroll }: EntryColumnWrapperProps) => {
|
||||
const view = useRouteParamsSelector((state) => state.view)
|
||||
|
||||
const isZenMode = useIsZenMode()
|
||||
const isZenMode = useIsZenMode()
|
||||
|
||||
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" : "",
|
||||
isZenMode ? "max-w-[80ch] mx-auto" : "",
|
||||
)}
|
||||
viewportClassName="[&>div]:grow flex"
|
||||
onScroll={onScroll}
|
||||
>
|
||||
{children}
|
||||
</ScrollArea>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
)
|
||||
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" : "",
|
||||
isZenMode ? "max-w-[80ch] mx-auto" : "",
|
||||
)}
|
||||
viewportClassName="[&>div]:grow flex"
|
||||
onScroll={onScroll}
|
||||
>
|
||||
{children}
|
||||
</ScrollArea>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ScrollElementContext } from "@follow/components/ui/scroll-area/ctx.js"
|
||||
import { views } from "@follow/constants"
|
||||
import { clsx } from "clsx"
|
||||
import { forwardRef, useState } from "react"
|
||||
import { useState } from "react"
|
||||
|
||||
import { PullToRefresh } from "~/components/ux/pull-to-refresh"
|
||||
import { ENTRY_COLUMN_LIST_SCROLLER_ID } from "~/constants/dom"
|
||||
@@ -12,31 +12,31 @@ import { styles } from "./wrapper.shared"
|
||||
|
||||
const noop = async () => {}
|
||||
|
||||
export const EntryColumnWrapper = forwardRef<HTMLDivElement, EntryColumnWrapperProps>(
|
||||
({ children, onPullToRefresh, onScroll }, ref) => {
|
||||
const view = useRouteParamsSelector((state) => state.view)
|
||||
export const EntryColumnWrapper = ({
|
||||
ref,
|
||||
children,
|
||||
onPullToRefresh,
|
||||
onScroll,
|
||||
}: EntryColumnWrapperProps) => {
|
||||
const view = useRouteParamsSelector((state) => state.view)
|
||||
|
||||
const [scrollElement, setScrollElement] = useState<HTMLElement | null>(null)
|
||||
return (
|
||||
<div className={clsx(styles, "relative flex flex-col")}>
|
||||
<div
|
||||
ref={ref}
|
||||
className={clsx("grow overflow-hidden", views[view]!.wideMode ? "mt-2" : "")}
|
||||
>
|
||||
<PullToRefresh className="h-full" onRefresh={onPullToRefresh || noop}>
|
||||
<ScrollElementContext.Provider value={scrollElement}>
|
||||
<div
|
||||
className="h-full overflow-y-auto"
|
||||
ref={setScrollElement}
|
||||
id={ENTRY_COLUMN_LIST_SCROLLER_ID}
|
||||
onScroll={onScroll}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</ScrollElementContext.Provider>
|
||||
</PullToRefresh>
|
||||
</div>
|
||||
const [scrollElement, setScrollElement] = useState<HTMLElement | null>(null)
|
||||
return (
|
||||
<div className={clsx(styles, "relative flex flex-col")}>
|
||||
<div ref={ref} className={clsx("grow overflow-hidden", views[view]!.wideMode ? "mt-2" : "")}>
|
||||
<PullToRefresh className="h-full" onRefresh={onPullToRefresh || noop}>
|
||||
<ScrollElementContext value={scrollElement}>
|
||||
<div
|
||||
className="h-full overflow-y-auto"
|
||||
ref={setScrollElement}
|
||||
id={ENTRY_COLUMN_LIST_SCROLLER_ID}
|
||||
onScroll={onScroll}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</ScrollElementContext>
|
||||
</PullToRefresh>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
)
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,4 +4,5 @@ export const animationStyles = tw`duration-300 ease-in-out animate-in fade-in sl
|
||||
export interface EntryColumnWrapperProps extends ComponentType {
|
||||
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void
|
||||
onPullToRefresh?: () => Promise<any>
|
||||
ref?: React.Ref<HTMLDivElement | null>
|
||||
}
|
||||
|
||||
@@ -52,9 +52,10 @@ export const ImageGallery = ({ images }: { images: MediaModel }) => {
|
||||
const [masonryItemsRadio, setMasonryItemsRadio] = useState<Record<string, number>>({})
|
||||
return (
|
||||
<div ref={containerRef}>
|
||||
<MasonryItemWidthContext.Provider value={currentItemWidth}>
|
||||
<MasonryItemWidthContext value={currentItemWidth}>
|
||||
{/* eslint-disable-next-line @eslint-react/no-context-provider */}
|
||||
<MasonryItemsAspectRatioContext.Provider value={masonryItemsRadio}>
|
||||
<MasonryItemsAspectRatioSetterContext.Provider value={setMasonryItemsRadio}>
|
||||
<MasonryItemsAspectRatioSetterContext value={setMasonryItemsRadio}>
|
||||
<MediaContainerWidthProvider width={currentItemWidth}>
|
||||
<Masonry
|
||||
items={images ?? []}
|
||||
@@ -65,9 +66,9 @@ export const ImageGallery = ({ images }: { images: MediaModel }) => {
|
||||
render={Render}
|
||||
/>
|
||||
</MediaContainerWidthProvider>
|
||||
</MasonryItemsAspectRatioSetterContext.Provider>
|
||||
</MasonryItemsAspectRatioSetterContext>
|
||||
</MasonryItemsAspectRatioContext.Provider>
|
||||
</MasonryItemWidthContext.Provider>
|
||||
</MasonryItemWidthContext>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
+8
-6
@@ -6,7 +6,7 @@ import { parseSafeUrl } from "@follow/utils/utils"
|
||||
import { Label } from "@radix-ui/react-label"
|
||||
import { PopoverPortal } from "@radix-ui/react-popover"
|
||||
import { atomWithStorage } from "jotai/utils"
|
||||
import { forwardRef, useState } from "react"
|
||||
import { useState } from "react"
|
||||
|
||||
import { useGeneralSettingKey, useGeneralSettingValue } from "~/atoms/settings/general"
|
||||
import { jotaiStore } from "~/lib/jotai"
|
||||
@@ -42,10 +42,12 @@ const getURLDomain = (url: string) => {
|
||||
return urlObj?.hostname ?? null
|
||||
}
|
||||
|
||||
const WarnGoToExternalLinkImpl = forwardRef<
|
||||
HTMLAnchorElement,
|
||||
React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>
|
||||
>(({ ...rest }, ref) => {
|
||||
const WarnGoToExternalLinkImpl = ({
|
||||
ref,
|
||||
...rest
|
||||
}: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> & {
|
||||
ref?: React.Ref<HTMLAnchorElement | null>
|
||||
}) => {
|
||||
const [open, setOpen] = useState(false)
|
||||
const [checked, setChecked] = useState<boolean | "indeterminate">(false)
|
||||
|
||||
@@ -113,7 +115,7 @@ const WarnGoToExternalLinkImpl = forwardRef<
|
||||
</PopoverPortal>
|
||||
</Popover>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export const WarnGoToExternalLink = withSettingEnabled(
|
||||
useGeneralSettingValue,
|
||||
|
||||
@@ -14,7 +14,9 @@ declare module "@follow/utils/event-bus" {
|
||||
}
|
||||
}
|
||||
|
||||
export const useFocusEntryContainerSubscriptions = (ref: React.RefObject<HTMLDivElement>) => {
|
||||
export const useFocusEntryContainerSubscriptions = (
|
||||
ref: React.RefObject<HTMLDivElement | null>,
|
||||
) => {
|
||||
useEffect(() => {
|
||||
return EventBus.subscribe("FOCUS_ENTRY_CONTAINER", () => {
|
||||
ref.current?.focus()
|
||||
|
||||
@@ -75,7 +75,7 @@ export const EntryContent: Component<EntryContentProps> = ({
|
||||
|
||||
const isInReadabilityMode = useEntryIsInReadability(entryId)
|
||||
const isReadabilitySuccess = useEntryIsInReadabilitySuccess(entryId)
|
||||
const scrollerRef = useRef<HTMLDivElement>(null)
|
||||
const scrollerRef = useRef<HTMLDivElement | null>(null)
|
||||
useEffect(() => {
|
||||
scrollerRef.current?.scrollTo(0, 0)
|
||||
scrollerRef.current?.focus()
|
||||
@@ -194,7 +194,7 @@ export const EntryContent: Component<EntryContentProps> = ({
|
||||
}
|
||||
|
||||
const EntryScrollArea: Component<{
|
||||
scrollerRef: React.RefObject<HTMLDivElement>
|
||||
scrollerRef: React.RefObject<HTMLDivElement | null>
|
||||
}> = ({ children, className, scrollerRef }) => {
|
||||
const isInPeekModal = useInPeekModal()
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ export const EntryContent: Component<{
|
||||
|
||||
return (
|
||||
<WrappedElementProvider>
|
||||
<ScrollElementContext.Provider value={scrollElement}>
|
||||
<ScrollElementContext value={scrollElement}>
|
||||
<div className="flex h-screen flex-col">
|
||||
<EntryHeader
|
||||
entryId={entry.entries.id}
|
||||
@@ -214,7 +214,7 @@ export const EntryContent: Component<{
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ScrollElementContext.Provider>
|
||||
</ScrollElementContext>
|
||||
</WrappedElementProvider>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import { cn } from "@follow/utils/utils"
|
||||
import type { FallbackRender } from "@sentry/react"
|
||||
import { useStore } from "jotai"
|
||||
import type { FC } from "react"
|
||||
import { forwardRef, memo, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"
|
||||
import { memo, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import {
|
||||
@@ -249,7 +249,7 @@ const useReadPercent = () => {
|
||||
}
|
||||
|
||||
export const ContainerToc = memo(
|
||||
forwardRef<TocRef, ComponentType>((_, ref) => {
|
||||
({ ref, ..._ }: ComponentType & { ref?: React.Ref<TocRef | null> }) => {
|
||||
const wrappedElement = useWrappedElement()
|
||||
|
||||
return (
|
||||
@@ -277,7 +277,7 @@ export const ContainerToc = memo(
|
||||
</div>
|
||||
</RootPortal>
|
||||
)
|
||||
}),
|
||||
},
|
||||
)
|
||||
const BackTopIndicator: Component = memo(({ className }) => {
|
||||
const [readPercent] = useReadPercent()
|
||||
|
||||
@@ -6,7 +6,7 @@ import { cn, getUrlIcon } from "@follow/utils/utils"
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@radix-ui/react-avatar"
|
||||
import { m } from "motion/react"
|
||||
import type { ReactNode } from "react"
|
||||
import { forwardRef, useMemo } from "react"
|
||||
import { useMemo } from "react"
|
||||
|
||||
const getFeedIconSrc = ({
|
||||
src,
|
||||
@@ -39,12 +39,15 @@ const getFeedIconSrc = ({
|
||||
return [ret.src, ret.fallbackUrl]
|
||||
}
|
||||
|
||||
const FallbackableImage = forwardRef<
|
||||
HTMLImageElement,
|
||||
{
|
||||
fallbackUrl: string
|
||||
} & React.ImgHTMLAttributes<HTMLImageElement>
|
||||
>(function FallbackableImage({ fallbackUrl, ...rest }, ref) {
|
||||
const FallbackableImage = function FallbackableImage({
|
||||
ref,
|
||||
fallbackUrl,
|
||||
...rest
|
||||
}: {
|
||||
fallbackUrl: string
|
||||
} & React.ImgHTMLAttributes<HTMLImageElement> & {
|
||||
ref?: React.Ref<HTMLImageElement | null>
|
||||
}) {
|
||||
return (
|
||||
<img
|
||||
onError={(e) => {
|
||||
@@ -61,7 +64,7 @@ const FallbackableImage = forwardRef<
|
||||
ref={ref}
|
||||
/>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
type FeedIconFeed =
|
||||
| (Pick<FeedModel, "ownerUserId" | "id" | "title" | "url" | "image"> & {
|
||||
|
||||
@@ -129,7 +129,7 @@ export const SearchCmdK: React.FC = () => {
|
||||
const canLoadMore = totalCount > renderedTotalCount && renderedTotalCount > 0
|
||||
|
||||
return (
|
||||
<SearchCmdKContext.Provider value={searchInstance}>
|
||||
<SearchCmdKContext value={searchInstance}>
|
||||
<Command.Dialog
|
||||
ref={dialogRef}
|
||||
shouldFilter={false}
|
||||
@@ -224,7 +224,7 @@ export const SearchCmdK: React.FC = () => {
|
||||
</div>
|
||||
</div>
|
||||
</Command.Dialog>
|
||||
</SearchCmdKContext.Provider>
|
||||
</SearchCmdKContext>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ const SearchResultCount: FC<{
|
||||
count?: number
|
||||
}> = ({ count }) => {
|
||||
const t = useI18n()
|
||||
const searchInstance = React.useContext(SearchCmdKContext)
|
||||
const searchInstance = React.use(SearchCmdKContext)
|
||||
const hasKeyword = useSearchStore((s) => !!s.keyword)
|
||||
const searchType = useSearchType()
|
||||
|
||||
@@ -345,7 +345,7 @@ const SearchOptions: Component = memo(({ children }) => {
|
||||
const { t } = useTranslation()
|
||||
const searchType = useSearchType()
|
||||
|
||||
const searchInstance = React.useContext(SearchCmdKContext)
|
||||
const searchInstance = React.use(SearchCmdKContext)
|
||||
|
||||
return (
|
||||
<div className="text-text flex items-center gap-2 text-sm">
|
||||
|
||||
@@ -78,7 +78,7 @@ export const UserProfileModalContent: FC<SubscriptionModalContentProps> = ({ use
|
||||
const [scrollerRef, setScrollerRef] = useState<HTMLDivElement | null>(null)
|
||||
const [isHeaderSimple, setHeaderSimple] = useState(false)
|
||||
|
||||
const currentVisibleRef = useRef<Set<string>>()
|
||||
const currentVisibleRef = useRef<Set<string>>(undefined)
|
||||
useEffect(() => {
|
||||
const $ref = scrollerRef
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { nextFrame } from "@follow/utils/dom"
|
||||
import { formatTimeToSeconds } from "@follow/utils/utils"
|
||||
import { useContext } from "react"
|
||||
import { use } from "react"
|
||||
|
||||
import { AudioPlayer } from "~/atoms/player"
|
||||
import { useEntry } from "~/store/entry"
|
||||
@@ -8,7 +8,7 @@ import { useEntry } from "~/store/entry"
|
||||
import { EntryInfoContext } from "../context"
|
||||
|
||||
export const TimeStamp = (props: { time: string }) => {
|
||||
const { entryId } = useContext(EntryInfoContext)
|
||||
const { entryId } = use(EntryInfoContext)
|
||||
const entry = useEntry(entryId)
|
||||
const mediaDuration = formatTimeToSeconds(entry?.entries.attachments?.[0]?.duration_in_seconds)
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ const defaultContextValue: EntryContentContext = {
|
||||
export const EntryContentContext = createContext<EntryContentContext>(defaultContextValue)
|
||||
|
||||
export const EntryContentProvider: Component<EntryContentContext> = ({ children, ...value }) => (
|
||||
// eslint-disable-next-line @eslint-react/no-context-provider
|
||||
<EntryContentContext.Provider value={value}>{children}</EntryContentContext.Provider>
|
||||
)
|
||||
|
||||
|
||||
@@ -59,13 +59,14 @@ export function EntryContentHTMLRenderer<AS extends keyof JSX.IntrinsicElements
|
||||
}
|
||||
}, [feedId, view])
|
||||
return (
|
||||
// eslint-disable-next-line @eslint-react/no-context-provider
|
||||
<MarkdownImageRecordContext.Provider value={images}>
|
||||
<MarkdownRenderActionContext.Provider value={actions}>
|
||||
<EntryInfoContext.Provider value={useMemo(() => ({ feedId, entryId }), [feedId, entryId])}>
|
||||
<MarkdownRenderActionContext value={actions}>
|
||||
<EntryInfoContext value={useMemo(() => ({ feedId, entryId }), [feedId, entryId])}>
|
||||
{/* @ts-expect-error */}
|
||||
<HTML {...props}>{children}</HTML>
|
||||
</EntryInfoContext.Provider>
|
||||
</MarkdownRenderActionContext.Provider>
|
||||
</EntryInfoContext>
|
||||
</MarkdownRenderActionContext>
|
||||
</MarkdownImageRecordContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { FC } from "react"
|
||||
import { createElement, forwardRef } from "react"
|
||||
import { createElement } from "react"
|
||||
|
||||
type WithSelect<T> = T & {
|
||||
select: (_s: any) => any
|
||||
@@ -11,11 +11,11 @@ export const withSettingEnabled =
|
||||
IfComponent: FC<P> | keyof JSX.IntrinsicElements,
|
||||
ElseComponent: FC<P> | keyof JSX.IntrinsicElements,
|
||||
) =>
|
||||
forwardRef<any, P>((props, ref) => {
|
||||
const res = useSettings.select(condition)
|
||||
return res
|
||||
? // @ts-expect-error
|
||||
createElement(IfComponent, { ...props, ref })
|
||||
: // @ts-expect-error
|
||||
createElement(ElseComponent, { ...props, ref })
|
||||
})
|
||||
({ ref, ...props }: P & { ref?: React.Ref<any | null> }) => {
|
||||
const res = useSettings.select(condition)
|
||||
return res
|
||||
? // @ts-expect-error
|
||||
createElement(IfComponent, { ...props, ref })
|
||||
: // @ts-expect-error
|
||||
createElement(ElseComponent, { ...props, ref })
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ export function SettingModalLayout(
|
||||
cursor: "grabbing",
|
||||
}}
|
||||
>
|
||||
{/* eslint-disable-next-line @eslint-react/no-context-provider */}
|
||||
<SettingContext.Provider value={defaultCtx}>
|
||||
<Resizable
|
||||
onResizeStart={handleResizeStart}
|
||||
|
||||
@@ -39,11 +39,13 @@ export const SettingItemGroup: FC<PropsWithChildren> = ({ children }) => {
|
||||
switch (prevType) {
|
||||
case SettingSwitch: {
|
||||
return cloneElement(child as React.ReactElement, {
|
||||
// @ts-expect-error
|
||||
className: "!-mt-2",
|
||||
})
|
||||
}
|
||||
case SettingActionItem: {
|
||||
return cloneElement(child as React.ReactElement, {
|
||||
// @ts-expect-error
|
||||
className: "!-mt-2",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ export const ListFeedsModalContent = ({ id }: { id: string }) => {
|
||||
const { t } = useTranslation("settings")
|
||||
|
||||
const [feedSearchFor, setFeedSearchFor] = useState("")
|
||||
const selectedFeedIdRef = useRef<string | null>()
|
||||
const selectedFeedIdRef = useRef<string | null>(undefined)
|
||||
const addMutation = useAddFeedToFeedList({
|
||||
onSuccess: () => {
|
||||
setFeedSearchFor("")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { Slot } from "@radix-ui/react-slot"
|
||||
import { useContext } from "react"
|
||||
import { use } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { useLoaderData } from "react-router"
|
||||
|
||||
@@ -44,7 +44,7 @@ export const SettingsTitle = ({
|
||||
} = (useLoaderData() || loader || {}) as SettingPageConfig
|
||||
|
||||
const usedIcon = headerIcon || iconName
|
||||
const isInSettingIndependentWindow = useContext(IsInSettingIndependentWindowContext)
|
||||
const isInSettingIndependentWindow = use(IsInSettingIndependentWindowContext)
|
||||
if (!title) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -3,21 +3,27 @@ import { ScrollArea } from "@follow/components/ui/scroll-area/ScrollArea.js"
|
||||
import { FeedViewType, views } from "@follow/constants"
|
||||
import type { EntryModelSimple, FeedModel } from "@follow/models"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { cloneElement, forwardRef } from "react"
|
||||
import { cloneElement } from "react"
|
||||
|
||||
import { useI18n } from "~/hooks/common"
|
||||
|
||||
import { EntryItemSkeleton } from "../entry-column/EntryItemSkeleton"
|
||||
import { EntryItemStateless } from "../entry-column/item-stateless"
|
||||
|
||||
export const ViewSelectorRadioGroup = forwardRef<
|
||||
HTMLInputElement,
|
||||
{
|
||||
entries?: EntryModelSimple[]
|
||||
feed?: FeedModel
|
||||
view?: number
|
||||
} & React.InputHTMLAttributes<HTMLInputElement>
|
||||
>(({ entries, feed, view, className, ...rest }, ref) => {
|
||||
export const ViewSelectorRadioGroup = ({
|
||||
ref,
|
||||
entries,
|
||||
feed,
|
||||
view,
|
||||
className,
|
||||
...rest
|
||||
}: {
|
||||
entries?: EntryModelSimple[]
|
||||
feed?: FeedModel
|
||||
view?: number
|
||||
} & React.InputHTMLAttributes<HTMLInputElement> & {
|
||||
ref?: React.Ref<HTMLInputElement | null>
|
||||
}) => {
|
||||
const t = useI18n()
|
||||
|
||||
const showPreview = feed && entries && entries.length > 0
|
||||
@@ -71,4 +77,4 @@ export const ViewSelectorRadioGroup = forwardRef<
|
||||
{showLoading && <EntryItemSkeleton view={view ?? FeedViewType.Articles} count={2} />}
|
||||
</Card>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -393,9 +393,9 @@ const RenameCategoryForm: FC<{
|
||||
toast.success(t("sidebar.feed_column.context_menu.rename_category_success"))
|
||||
},
|
||||
})
|
||||
const formRef = useRef<HTMLFormElement>(null)
|
||||
const formRef = useRef<HTMLFormElement | null>(null)
|
||||
useOnClickOutside(
|
||||
formRef,
|
||||
formRef as React.RefObject<HTMLElement>,
|
||||
() => {
|
||||
onFinished()
|
||||
},
|
||||
|
||||
@@ -12,7 +12,7 @@ import type { FeedViewType } from "@follow/constants"
|
||||
import { nextFrame } from "@follow/utils/dom"
|
||||
import { cn, isKeyForMultiSelectPressed } from "@follow/utils/utils"
|
||||
import dayjs from "dayjs"
|
||||
import { memo, useCallback, useContext, useState } from "react"
|
||||
import { memo, use, useCallback, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { MenuItemSeparator, MenuItemText, useShowContextMenu } from "~/atoms/context-menu"
|
||||
@@ -51,7 +51,7 @@ const DraggableItemWrapper: Component<
|
||||
isInMultipleSelection: boolean
|
||||
} & React.HTMLAttributes<HTMLDivElement>
|
||||
> = ({ children, isInMultipleSelection, ...props }) => {
|
||||
const draggableContext = useContext(DraggableContext)
|
||||
const draggableContext = use(DraggableContext)
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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 { memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import Selecto from "react-selecto"
|
||||
import { useEventListener } from "usehooks-ts"
|
||||
@@ -25,257 +25,256 @@ import {
|
||||
} from "./atom"
|
||||
import { DraggableContext } from "./context"
|
||||
import { FeedItem, ListItem } from "./FeedItem"
|
||||
import type { FeedListProps } from "./FeedList"
|
||||
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 FeedListImpl = ({ ref, className, view }: FeedListProps) => {
|
||||
const feedsData = useFeedsGroupedData(view)
|
||||
const listsData = useListsGroupedData(view)
|
||||
const inboxesData = useInboxesGroupedData(view)
|
||||
|
||||
const categoryOpenStateData = useCategoryOpenStateByView(view)
|
||||
const categoryOpenStateData = useCategoryOpenStateByView(view)
|
||||
|
||||
const hasData =
|
||||
Object.keys(feedsData).length > 0 ||
|
||||
Object.keys(listsData).length > 0 ||
|
||||
Object.keys(inboxesData).length > 0
|
||||
const hasData =
|
||||
Object.keys(feedsData).length > 0 ||
|
||||
Object.keys(listsData).length > 0 ||
|
||||
Object.keys(inboxesData).length > 0
|
||||
|
||||
const { t } = useTranslation()
|
||||
const { t } = useTranslation()
|
||||
|
||||
// Data prefetch
|
||||
useAuthQuery(Queries.lists.list())
|
||||
// Data prefetch
|
||||
useAuthQuery(Queries.lists.list())
|
||||
|
||||
const hasListData = Object.keys(listsData).length > 0
|
||||
const hasInboxData = Object.keys(inboxesData).length > 0
|
||||
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 scrollerRef = useRef<HTMLDivElement | null>(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 { 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)
|
||||
const draggableContextValue = useMemo(
|
||||
() => ({
|
||||
attributes,
|
||||
listeners,
|
||||
style: {
|
||||
...style,
|
||||
willChange: "transform",
|
||||
},
|
||||
scrollerRef,
|
||||
{ capture: false, passive: true },
|
||||
)
|
||||
}),
|
||||
[attributes, listeners, style],
|
||||
)
|
||||
|
||||
const shouldFreeUpSpace = useShouldFreeUpSpace()
|
||||
useImperativeHandle(ref, () => scrollerRef.current!)
|
||||
|
||||
const routerParams = useRouteParams()
|
||||
const { listId, isPreview, feedId } = routerParams
|
||||
const isFeedPreview = isPreview && !listId
|
||||
const isListPreview = isPreview && listId
|
||||
useEventListener(
|
||||
"scroll",
|
||||
() => {
|
||||
const round = (num: number) => Math.round(num * 1e2) / 1e2
|
||||
const getPositions = () => {
|
||||
const el = scrollerRef.current
|
||||
if (!el) return
|
||||
|
||||
useFeedQuery({ id: isFeedPreview ? feedId : undefined })
|
||||
useList({ id: isListPreview ? listId : undefined })
|
||||
return {
|
||||
x: round(el.scrollLeft / (el.scrollWidth - el.clientWidth)),
|
||||
y: round(el.scrollTop / (el.scrollHeight - el.clientHeight)),
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={cn(className, "font-medium")}>
|
||||
<ListHeader view={view} />
|
||||
const newScrollValues = getPositions()
|
||||
if (!newScrollValues) return
|
||||
|
||||
<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
|
||||
const { y } = newScrollValues
|
||||
setFeedAreaScrollProgressValue(y)
|
||||
},
|
||||
scrollerRef as React.RefObject<HTMLElement>,
|
||||
{ capture: false, passive: true },
|
||||
)
|
||||
|
||||
if (
|
||||
dataFeedId &&
|
||||
selectedFeedIds.includes(dataFeedId) &&
|
||||
!isKeyForMultiSelectPressed(inputEvent)
|
||||
const shouldFreeUpSpace = useShouldFreeUpSpace()
|
||||
|
||||
const routerParams = useRouteParams()
|
||||
const { listId, isPreview, feedId } = routerParams
|
||||
const isFeedPreview = isPreview && !listId
|
||||
const isListPreview = isPreview && listId
|
||||
|
||||
useFeedQuery({ id: isFeedPreview ? feedId : undefined })
|
||||
useList({ id: isListPreview ? listId : undefined })
|
||||
|
||||
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,
|
||||
)
|
||||
return false
|
||||
const currentSelected =
|
||||
added.length === 1 ? added[0] : removed.length === 1 ? removed[0] : null
|
||||
const currentIndex = currentSelected ? allVisible.indexOf(currentSelected) : -1
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
// command or ctrl with click, update start feed id
|
||||
if (!(e.inputEvent as MouseEvent).shiftKey && currentSelected) {
|
||||
setCurrentStartFeedId(currentSelected)
|
||||
}
|
||||
|
||||
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)
|
||||
}}
|
||||
/>
|
||||
// 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<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 || (isListPreview && listId)) && (
|
||||
<>
|
||||
<div className="text-text-secondary 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>
|
||||
{isListPreview && listId && (
|
||||
<ListItem listId={listId} view={view} className="pl-2.5 pr-0" isPreview />
|
||||
)}
|
||||
<SortByAlphabeticalList view={view} data={listsData} />
|
||||
</>
|
||||
)}
|
||||
{hasInboxData && (
|
||||
<>
|
||||
<div className="text-text-secondary 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} />
|
||||
</>
|
||||
)}
|
||||
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)
|
||||
}}
|
||||
/>
|
||||
|
||||
{(hasListData || hasInboxData) && (
|
||||
<div
|
||||
className={cn(
|
||||
"text-text-secondary 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")}
|
||||
<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 || (isListPreview && listId)) && (
|
||||
<>
|
||||
<div className="text-text-secondary 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>
|
||||
)}
|
||||
{isFeedPreview && feedId && (
|
||||
<FeedItem feedId={feedId} view={view} className="pl-2.5 pr-0.5" isPreview />
|
||||
)}
|
||||
<DraggableContext.Provider value={draggableContextValue}>
|
||||
<div className="space-y-px" id="feeds-area" ref={setNodeRef}>
|
||||
{hasData ? (
|
||||
<SortableFeedList
|
||||
view={view}
|
||||
data={feedsData}
|
||||
categoryOpenStateData={categoryOpenStateData}
|
||||
/>
|
||||
) : (
|
||||
<EmptyFeedList />
|
||||
)}
|
||||
{isListPreview && listId && (
|
||||
<ListItem listId={listId} view={view} className="pl-2.5 pr-0" isPreview />
|
||||
)}
|
||||
<SortByAlphabeticalList view={view} data={listsData} />
|
||||
</>
|
||||
)}
|
||||
{hasInboxData && (
|
||||
<>
|
||||
<div className="text-text-secondary 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>
|
||||
</DraggableContext.Provider>
|
||||
</ScrollArea.ScrollArea>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
)
|
||||
<SortByAlphabeticalInbox view={view} data={inboxesData} />
|
||||
</>
|
||||
)}
|
||||
|
||||
{(hasListData || hasInboxData) && (
|
||||
<div
|
||||
className={cn(
|
||||
"text-text-secondary 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>
|
||||
)}
|
||||
{isFeedPreview && feedId && (
|
||||
<FeedItem feedId={feedId} view={view} className="pl-2.5 pr-0.5" isPreview />
|
||||
)}
|
||||
<DraggableContext value={draggableContextValue}>
|
||||
<div className="space-y-px" id="feeds-area" ref={setNodeRef}>
|
||||
{hasData ? (
|
||||
<SortableFeedList
|
||||
view={view}
|
||||
data={feedsData}
|
||||
categoryOpenStateData={categoryOpenStateData}
|
||||
/>
|
||||
) : (
|
||||
<EmptyFeedList />
|
||||
)}
|
||||
</div>
|
||||
</DraggableContext>
|
||||
</ScrollArea.ScrollArea>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
FeedListImpl.displayName = "FeedListImpl"
|
||||
|
||||
export const FeedList = memo(FeedListImpl)
|
||||
|
||||
@@ -14,11 +14,12 @@ import {
|
||||
useListsGroupedData,
|
||||
} from "~/store/subscription"
|
||||
|
||||
import type { FeedListProps } from "./FeedList"
|
||||
import { EmptyFeedList, ListHeader, StarredItem } from "./FeedList.shared"
|
||||
import { SortableFeedList, SortByAlphabeticalInbox, SortByAlphabeticalList } from "./sort-by"
|
||||
import { feedColumnStyles } from "./styles"
|
||||
|
||||
const FeedListImpl = ({ className, view }: { className?: string; view: number }) => {
|
||||
const FeedListImpl = ({ className, view }: FeedListProps) => {
|
||||
const feedsData = useFeedsGroupedData(view)
|
||||
const listsData = useListsGroupedData(view)
|
||||
const inboxesData = useInboxesGroupedData(view)
|
||||
|
||||
@@ -106,8 +106,8 @@ const SortButton = () => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const [open, setOpen] = useState(false)
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
useOnClickOutside(ref, () => {
|
||||
const ref = useRef<HTMLDivElement | null>(null)
|
||||
useOnClickOutside(ref as React.RefObject<HTMLElement>, () => {
|
||||
setOpen(false)
|
||||
})
|
||||
|
||||
|
||||
@@ -4,3 +4,9 @@ import { FeedList as FeedListDesktop } from "./FeedList.electron"
|
||||
import { FeedList as FeedListMobile } from "./FeedList.mobile"
|
||||
|
||||
export const FeedList = withResponsiveSyncComponent(FeedListDesktop, FeedListMobile)
|
||||
|
||||
export type FeedListProps = ComponentType<
|
||||
{ className?: string; view: number } & {
|
||||
ref?: React.Ref<HTMLDivElement | null> | ((node: HTMLDivElement | null) => void)
|
||||
}
|
||||
>
|
||||
|
||||
@@ -7,7 +7,7 @@ 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 { memo, useCallback, useLayoutEffect, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { useNavigate } from "react-router"
|
||||
|
||||
@@ -219,12 +219,15 @@ export const ProfileButton: FC<ProfileButtonProps> = memo((props) => {
|
||||
})
|
||||
ProfileButton.displayName = "ProfileButton"
|
||||
|
||||
const TransitionAvatar = forwardRef<
|
||||
HTMLButtonElement,
|
||||
{
|
||||
stage: "zoom-in" | ""
|
||||
} & React.HTMLAttributes<HTMLButtonElement>
|
||||
>(({ stage, ...props }, forwardRef) => {
|
||||
const TransitionAvatar = ({
|
||||
ref: forwardRef,
|
||||
stage,
|
||||
...props
|
||||
}: {
|
||||
stage: "zoom-in" | ""
|
||||
} & React.HTMLAttributes<HTMLButtonElement> & {
|
||||
ref?: React.Ref<HTMLButtonElement | null>
|
||||
}) => {
|
||||
const [ref, { x, y }, forceRefresh] = useMeasure()
|
||||
const [avatarHovered, setAvatarHovered] = useState(false)
|
||||
|
||||
@@ -274,4 +277,4 @@ const TransitionAvatar = forwardRef<
|
||||
)}
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@follow/components/ui/avatar/index.jsx"
|
||||
import { getColorScheme, stringToHue } from "@follow/utils/color"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { forwardRef } from "react"
|
||||
|
||||
import { useAuthQuery } from "~/hooks/common"
|
||||
import { defineQuery } from "~/lib/defineQuery"
|
||||
@@ -13,78 +12,80 @@ import { userActions } from "~/store/user"
|
||||
import type { LoginProps } from "./LoginButton"
|
||||
import { LoginButton } from "./LoginButton"
|
||||
|
||||
export const UserAvatar = forwardRef<
|
||||
HTMLDivElement,
|
||||
{
|
||||
className?: string
|
||||
avatarClassName?: string
|
||||
hideName?: boolean
|
||||
userId?: string
|
||||
enableModal?: boolean
|
||||
} & LoginProps &
|
||||
React.HTMLAttributes<HTMLDivElement>
|
||||
>(
|
||||
(
|
||||
{ className, avatarClassName, hideName, userId, enableModal, style, onClick, ...props },
|
||||
ref,
|
||||
) => {
|
||||
const { session, status } = useSession({
|
||||
enabled: !userId,
|
||||
})
|
||||
const presentUserProfile = usePresentUserProfileModal("drawer")
|
||||
export const UserAvatar = ({
|
||||
ref,
|
||||
className,
|
||||
avatarClassName,
|
||||
hideName,
|
||||
userId,
|
||||
enableModal,
|
||||
style,
|
||||
onClick,
|
||||
...props
|
||||
}: {
|
||||
className?: string
|
||||
avatarClassName?: string
|
||||
hideName?: boolean
|
||||
userId?: string
|
||||
enableModal?: boolean
|
||||
} & LoginProps &
|
||||
React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement | null> }) => {
|
||||
const { session, status } = useSession({
|
||||
enabled: !userId,
|
||||
})
|
||||
const presentUserProfile = usePresentUserProfileModal("drawer")
|
||||
|
||||
const profile = useAuthQuery(
|
||||
defineQuery(["profiles", userId], async () => {
|
||||
return userActions.getOrFetchProfile(userId!)
|
||||
}),
|
||||
{
|
||||
enabled: !!userId,
|
||||
},
|
||||
)
|
||||
const profile = useAuthQuery(
|
||||
defineQuery(["profiles", userId], async () => {
|
||||
return userActions.getOrFetchProfile(userId!)
|
||||
}),
|
||||
{
|
||||
enabled: !!userId,
|
||||
},
|
||||
)
|
||||
|
||||
if (!userId && status !== "authenticated") {
|
||||
return <LoginButton {...props} />
|
||||
}
|
||||
if (!userId && status !== "authenticated") {
|
||||
return <LoginButton {...props} />
|
||||
}
|
||||
|
||||
const renderUserData = userId ? profile.data : session?.user
|
||||
const randomColor = stringToHue(renderUserData?.name || "")
|
||||
return (
|
||||
<div
|
||||
style={style}
|
||||
ref={ref}
|
||||
onClick={(e) => {
|
||||
if (enableModal) {
|
||||
presentUserProfile(userId)
|
||||
}
|
||||
onClick?.(e)
|
||||
}}
|
||||
{...props}
|
||||
const renderUserData = userId ? profile.data : session?.user
|
||||
const randomColor = stringToHue(renderUserData?.name || "")
|
||||
return (
|
||||
<div
|
||||
style={style}
|
||||
ref={ref}
|
||||
onClick={(e) => {
|
||||
if (enableModal) {
|
||||
presentUserProfile(userId)
|
||||
}
|
||||
onClick?.(e)
|
||||
}}
|
||||
{...props}
|
||||
className={cn(
|
||||
"text-text-secondary flex h-20 items-center justify-center gap-2 px-5 py-2 font-medium",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<Avatar
|
||||
className={cn(
|
||||
"text-text-secondary flex h-20 items-center justify-center gap-2 px-5 py-2 font-medium",
|
||||
className,
|
||||
"aspect-square h-full w-auto overflow-hidden rounded-full border bg-stone-300",
|
||||
avatarClassName,
|
||||
)}
|
||||
>
|
||||
<Avatar
|
||||
className={cn(
|
||||
"aspect-square h-full w-auto overflow-hidden rounded-full border bg-stone-300",
|
||||
avatarClassName,
|
||||
)}
|
||||
<AvatarImage
|
||||
className="animate-in fade-in-0 duration-200"
|
||||
src={replaceImgUrlIfNeed(renderUserData?.image || undefined)}
|
||||
/>
|
||||
<AvatarFallback
|
||||
style={{ backgroundColor: getColorScheme(randomColor, true).light.accent }}
|
||||
className="text-xs text-white"
|
||||
>
|
||||
<AvatarImage
|
||||
className="animate-in fade-in-0 duration-200"
|
||||
src={replaceImgUrlIfNeed(renderUserData?.image || undefined)}
|
||||
/>
|
||||
<AvatarFallback
|
||||
style={{ backgroundColor: getColorScheme(randomColor, true).light.accent }}
|
||||
className="text-xs text-white"
|
||||
>
|
||||
{renderUserData?.name?.[0]}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
{!hideName && <div>{renderUserData?.name}</div>}
|
||||
</div>
|
||||
)
|
||||
},
|
||||
)
|
||||
{renderUserData?.name?.[0]}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
{!hideName && <div>{renderUserData?.name}</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
UserAvatar.displayName = "UserAvatar"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { throttle } from "es-toolkit/compat"
|
||||
import type { FC, PropsWithChildren } from "react"
|
||||
import { createContext, useContext, useLayoutEffect, useRef, useState } from "react"
|
||||
import { createContext, use, useLayoutEffect, useRef, useState } from "react"
|
||||
|
||||
import { APP_GRID_CONTAINER_ID } from "~/constants/dom"
|
||||
|
||||
@@ -29,12 +29,12 @@ export const AppLayoutGridContainerProvider: FC<PropsWithChildren> = ({ children
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<AppLayoutGridContainerWidthContext.Provider value={width}>
|
||||
<AppLayoutGridContainerWidthContext value={width}>
|
||||
<div ref={ref} className="relative z-0 contents" id={APP_GRID_CONTAINER_ID}>
|
||||
{children}
|
||||
</div>
|
||||
</AppLayoutGridContainerWidthContext.Provider>
|
||||
</AppLayoutGridContainerWidthContext>
|
||||
)
|
||||
}
|
||||
|
||||
export const useAppLayoutGridContainerWidth = () => useContext(AppLayoutGridContainerWidthContext)
|
||||
export const useAppLayoutGridContainerWidth = () => use(AppLayoutGridContainerWidthContext)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { MemoedDangerousHTMLStyle } from "@follow/components/common/MemoedDangerousHTMLStyle.jsx"
|
||||
import { RootPortal } from "@follow/components/ui/portal/index.js"
|
||||
import type { FC, PropsWithChildren } from "react"
|
||||
import { createContext, useCallback, useContext, useState } from "react"
|
||||
import { createContext, use, useCallback, useState } from "react"
|
||||
|
||||
const Provider = createContext<(id: string, styles: string) => () => void>(() => () => {})
|
||||
export const PortalInjectStylesProvider: FC<PropsWithChildren> = ({ children }) => {
|
||||
@@ -20,7 +20,7 @@ export const PortalInjectStylesProvider: FC<PropsWithChildren> = ({ children })
|
||||
return dispose
|
||||
}, [])
|
||||
return (
|
||||
<Provider.Provider value={injectStyles}>
|
||||
<Provider value={injectStyles}>
|
||||
<RootPortal to={document.head}>
|
||||
{Object.entries(styles).map(([id, style]) => (
|
||||
<MemoedDangerousHTMLStyle key={id} id={`inject-${id}`}>
|
||||
@@ -29,10 +29,10 @@ export const PortalInjectStylesProvider: FC<PropsWithChildren> = ({ children })
|
||||
))}
|
||||
</RootPortal>
|
||||
{children}
|
||||
</Provider.Provider>
|
||||
</Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export const useInjectStyles = () => {
|
||||
return useContext(Provider)
|
||||
return use(Provider)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { createContextState } from "foxact/create-context-state"
|
||||
import { useIsomorphicLayoutEffect } from "foxact/use-isomorphic-layout-effect"
|
||||
import type { PrimitiveAtom } from "jotai"
|
||||
import { atom, useAtomValue, useSetAtom } from "jotai"
|
||||
import { createContext, memo, useCallback, useContext, useEffect, useRef } from "react"
|
||||
import { createContext, memo, use, useCallback, useEffect, useRef } from "react"
|
||||
|
||||
import { ProviderComposer } from "~/components/common/ProviderComposer"
|
||||
import { jotaiStore } from "~/lib/jotai"
|
||||
@@ -32,7 +32,7 @@ const [IsStartOfElementProviderInternal, useIsSoFWrappedElement, useSetIsSOfElem
|
||||
const Providers = [
|
||||
<WrappedElementProviderInternal key="ArticleElementProviderInternal" />,
|
||||
<ElementSizeProviderInternal key="ElementSizeProviderInternal" />,
|
||||
<ElementPositionProviderInternal.Provider
|
||||
<ElementPositionProviderInternal
|
||||
key="ElementPositionProviderInternal"
|
||||
value={atom({
|
||||
x: 0,
|
||||
@@ -63,7 +63,7 @@ export const WrappedElementProvider: Component<WrappedElementProviderProps> = ({
|
||||
const ArticleElementResizeObserver = () => {
|
||||
const setSize = useSetWrappedElementSize()
|
||||
|
||||
const setPosition = useSetAtom(useContext(ElementPositionProviderInternal))
|
||||
const setPosition = useSetAtom(use(ElementPositionProviderInternal))
|
||||
const $element = useWrappedElement()
|
||||
useIsomorphicLayoutEffect(() => {
|
||||
if (!$element) return
|
||||
@@ -140,11 +140,10 @@ const BoundingDetection: Component<{
|
||||
return <div ref={ref} />
|
||||
}
|
||||
|
||||
export const useWrappedElementPosition = () =>
|
||||
useAtomValue(useContext(ElementPositionProviderInternal))
|
||||
export const useWrappedElementPosition = () => useAtomValue(use(ElementPositionProviderInternal))
|
||||
|
||||
export const useGetWrappedElementPosition = () => {
|
||||
const atom = useContext(ElementPositionProviderInternal)
|
||||
const atom = use(ElementPositionProviderInternal)
|
||||
return useCallback(() => jotaiStore.get(atom), [atom])
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ export const useEntryIdsByView = (view: FeedViewType, filter?: EntryFilter) => {
|
||||
|
||||
return useEntryStore(
|
||||
useCallback(
|
||||
() => getFilteredFeedIds([...feedIds, ...listFeedIds], filter) || [],
|
||||
() => getFilteredFeedIds(Array.from(new Set([...feedIds, ...listFeedIds])), filter) || [],
|
||||
[feedIds, listFeedIds, filter],
|
||||
),
|
||||
)
|
||||
@@ -108,6 +108,7 @@ export const useEntryIdsByFeedIdOrView = (
|
||||
const byView = useEntryIdsByView(feedIdOrView as FeedViewType, filter)
|
||||
const byId = useEntryIdsByFeedId(feedIdOrView as string, filter)
|
||||
const byFolder = useEntryIdsByFeedIds(feedIdOrView as string[], filter)
|
||||
|
||||
if (Array.isArray(feedIdOrView)) {
|
||||
return byFolder
|
||||
} else if (typeof feedIdOrView === "string") {
|
||||
|
||||
@@ -79,8 +79,8 @@
|
||||
"html-minifier-terser": "7.2.0",
|
||||
"js-yaml": "4.1.0",
|
||||
"nbump": "2.1.2",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1",
|
||||
"react": "19.0.0",
|
||||
"react-dom": "19.0.0",
|
||||
"tailwindcss-multi": "0.4.6",
|
||||
"tar": "7.4.3",
|
||||
"tsup": "8.4.0",
|
||||
|
||||
@@ -36,3 +36,11 @@ yarn-error.*
|
||||
*.tsbuildinfo
|
||||
|
||||
app-example
|
||||
|
||||
|
||||
|
||||
ios/Pods
|
||||
android
|
||||
Podfile.lock
|
||||
|
||||
buildServer.json
|
||||
@@ -4,7 +4,6 @@ import type { ConfigContext, ExpoConfig } from "expo/config"
|
||||
|
||||
import PKG from "./package.json"
|
||||
|
||||
const isCI = process.env.CI === "true"
|
||||
// const roundedIconPath = resolve(__dirname, "../../resources/icon.png")
|
||||
const iconPathMap = {
|
||||
production: resolve(__dirname, "./assets/icon.png"),
|
||||
@@ -16,8 +15,10 @@ const iconPath = iconPathMap[process.env.PROFILE || "production"] || iconPathMap
|
||||
|
||||
const adaptiveIconPath = resolve(__dirname, "./assets/adaptive-icon.png")
|
||||
|
||||
const isDev = process.env.NODE_ENV === "development"
|
||||
|
||||
export default ({ config }: ConfigContext): ExpoConfig => {
|
||||
const result = {
|
||||
const result: ExpoConfig = {
|
||||
...config,
|
||||
|
||||
extra: {
|
||||
@@ -29,9 +30,7 @@ export default ({ config }: ConfigContext): ExpoConfig => {
|
||||
updates: {
|
||||
url: "https://u.expo.dev/a6335b14-fb84-45aa-ba80-6f6ab8926920",
|
||||
},
|
||||
runtimeVersion: {
|
||||
policy: "appVersion" as const,
|
||||
},
|
||||
runtimeVersion: isDev ? "0.0.0-dev" : PKG.version,
|
||||
|
||||
name: "Folo",
|
||||
slug: "follow",
|
||||
@@ -112,6 +111,7 @@ export default ({ config }: ConfigContext): ExpoConfig => {
|
||||
},
|
||||
],
|
||||
"expo-apple-authentication",
|
||||
"expo-web-browser",
|
||||
[
|
||||
"expo-video",
|
||||
{
|
||||
@@ -123,16 +123,15 @@ export default ({ config }: ConfigContext): ExpoConfig => {
|
||||
require("./plugins/with-follow-assets.js"),
|
||||
{
|
||||
// Add asset directory paths, the plugin copies the files in the given paths to the app bundle folder named Assets
|
||||
assetsPath: !isCI ? resolve(__dirname, "..", "..", "out", "rn-web") : "/tmp/rn-web",
|
||||
assetsPath: resolve(__dirname, "..", "..", "out", "rn-web"),
|
||||
},
|
||||
],
|
||||
require("./plugins/with-follow-app-delegate.js"),
|
||||
|
||||
require("./plugins/with-gradle-jvm-heap-size-increase.js"),
|
||||
require("./plugins/with-android-day-night-theme-plugin.js"),
|
||||
"expo-secure-store",
|
||||
"@react-native-firebase/app",
|
||||
"@react-native-firebase/crashlytics",
|
||||
"@react-native-firebase/app-check",
|
||||
[
|
||||
"expo-image-picker",
|
||||
{
|
||||
@@ -145,21 +144,11 @@ export default ({ config }: ConfigContext): ExpoConfig => {
|
||||
enableBackgroundRemoteNotifications: true,
|
||||
},
|
||||
],
|
||||
[
|
||||
// Fix status bar flash issue on Android
|
||||
// Learn more: https://github.com/expo/expo/blob/main/packages/expo-status-bar/src/StatusBar.android.tsx#L21
|
||||
"react-native-edge-to-edge",
|
||||
{
|
||||
android: {
|
||||
parentTheme: "Default",
|
||||
enforceNavigationBarContrast: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
}
|
||||
|
||||
if (process.env.PROFILE !== "production") {
|
||||
result.plugins ||= []
|
||||
result.plugins.push(require("./plugins/android-trust-user-certs.js"))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
module.exports = function (api) {
|
||||
api.cache(true)
|
||||
return {
|
||||
presets: [["babel-preset-expo", { jsxImportSource: "nativewind" }], "nativewind/babel"],
|
||||
presets: [
|
||||
["babel-preset-expo", { jsxImportSource: "nativewind", unstable_transformImportMeta: true }],
|
||||
"nativewind/babel",
|
||||
],
|
||||
plugins: [
|
||||
["inline-import", { extensions: [".sql"] }],
|
||||
[
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# OSX
|
||||
#
|
||||
.DS_Store
|
||||
|
||||
# Xcode
|
||||
#
|
||||
build/
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata
|
||||
*.xccheckout
|
||||
*.moved-aside
|
||||
DerivedData
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.xcuserstate
|
||||
project.xcworkspace
|
||||
.xcode.env.local
|
||||
|
||||
# Bundle artifacts
|
||||
*.jsbundle
|
||||
|
||||
# CocoaPods
|
||||
/Pods/
|
||||
@@ -0,0 +1,11 @@
|
||||
# This `.xcode.env` file is versioned and is used to source the environment
|
||||
# used when running script phases inside Xcode.
|
||||
# To customize your local environment, you can create an `.xcode.env.local`
|
||||
# file that is not versioned.
|
||||
|
||||
# NODE_BINARY variable contains the PATH to the node executable.
|
||||
#
|
||||
# Customize the NODE_BINARY variable here.
|
||||
# For example, to use nvm with brew, add the following line
|
||||
# . "$(brew --prefix nvm)/nvm.sh" --no-use
|
||||
export NODE_BINARY=$(command -v node)
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1130"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
|
||||
BuildableName = "Folo.app"
|
||||
BlueprintName = "Folo"
|
||||
ReferencedContainer = "container:Folo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "00E356ED1AD99517003FC87E"
|
||||
BuildableName = "FoloTests.xctest"
|
||||
BlueprintName = "FoloTests"
|
||||
ReferencedContainer = "container:Folo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
|
||||
BuildableName = "Folo.app"
|
||||
BlueprintName = "Folo"
|
||||
ReferencedContainer = "container:Folo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
|
||||
BuildableName = "Folo.app"
|
||||
BlueprintName = "Folo"
|
||||
ReferencedContainer = "container:Folo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:Folo.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Pods/Pods.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,89 @@
|
||||
import Expo
|
||||
import FirebaseCore
|
||||
import RNFBAppCheck
|
||||
import React
|
||||
import ReactAppDependencyProvider
|
||||
|
||||
@UIApplicationMain
|
||||
public class AppDelegate: ExpoAppDelegate {
|
||||
var window: UIWindow?
|
||||
|
||||
var reactNativeDelegate: ExpoReactNativeFactoryDelegate?
|
||||
var reactNativeFactory: RCTReactNativeFactory?
|
||||
|
||||
public override func application(
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
|
||||
) -> Bool {
|
||||
let delegate = ReactNativeDelegate()
|
||||
let factory = ExpoReactNativeFactory(delegate: delegate)
|
||||
delegate.dependencyProvider = RCTAppDependencyProvider()
|
||||
|
||||
reactNativeDelegate = delegate
|
||||
reactNativeFactory = factory
|
||||
bindReactNativeFactory(factory)
|
||||
|
||||
RNFBAppCheckModule.sharedInstance()
|
||||
FirebaseApp.configure()
|
||||
|
||||
setAppAppearance()
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
window = UIWindow(frame: UIScreen.main.bounds)
|
||||
factory.startReactNative(
|
||||
withModuleName: "main",
|
||||
in: window,
|
||||
launchOptions: launchOptions)
|
||||
#endif
|
||||
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
}
|
||||
|
||||
// Linking API
|
||||
public override func application(
|
||||
_ app: UIApplication,
|
||||
open url: URL,
|
||||
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
|
||||
) -> Bool {
|
||||
return super.application(app, open: url, options: options)
|
||||
|| RCTLinkingManager.application(app, open: url, options: options)
|
||||
}
|
||||
|
||||
// Universal Links
|
||||
public override func application(
|
||||
_ application: UIApplication,
|
||||
continue userActivity: NSUserActivity,
|
||||
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
|
||||
) -> Bool {
|
||||
let result = RCTLinkingManager.application(
|
||||
application, continue: userActivity, restorationHandler: restorationHandler)
|
||||
return super.application(
|
||||
application, continue: userActivity, restorationHandler: restorationHandler) || result
|
||||
}
|
||||
}
|
||||
|
||||
class ReactNativeDelegate: ExpoReactNativeFactoryDelegate {
|
||||
// Extension point for config-plugins
|
||||
|
||||
override func sourceURL(for bridge: RCTBridge) -> URL? {
|
||||
// needed to return the correct URL for expo-dev-client.
|
||||
bridge.bundleURL ?? bundleURL()
|
||||
}
|
||||
|
||||
override func bundleURL() -> URL? {
|
||||
#if DEBUG
|
||||
return RCTBundleURLProvider.sharedSettings().jsBundleURL(
|
||||
forBundleRoot: ".expo/.virtual-metro-entry")
|
||||
#else
|
||||
return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private func setAppAppearance() {
|
||||
let tintColor = UIColor(red: 255.0 / 255.0, green: 92.0 / 255.0, blue: 0.0 / 255.0, alpha: 1.0)
|
||||
UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = tintColor
|
||||
|
||||
UIButton.appearance().tintColor = tintColor
|
||||
UISwitch.appearance().onTintColor = tintColor
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
//
|
||||
// Use this file to import your target's public headers that you would like to expose to Swift.
|
||||
//
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>aps-environment</key>
|
||||
<string>development</string>
|
||||
<key>com.apple.developer.applesignin</key>
|
||||
<array>
|
||||
<string>Default</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>API_KEY</key>
|
||||
<string>AIzaSyBD8lePDcfuPeJpJkvY1Egc_5sLX5lrtpg</string>
|
||||
<key>GCM_SENDER_ID</key>
|
||||
<string>194977404578</string>
|
||||
<key>PLIST_VERSION</key>
|
||||
<string>1</string>
|
||||
<key>BUNDLE_ID</key>
|
||||
<string>is.follow</string>
|
||||
<key>PROJECT_ID</key>
|
||||
<string>follow-428106</string>
|
||||
<key>STORAGE_BUCKET</key>
|
||||
<string>follow-428106.firebasestorage.app</string>
|
||||
<key>IS_ADS_ENABLED</key>
|
||||
<false></false>
|
||||
<key>IS_ANALYTICS_ENABLED</key>
|
||||
<false></false>
|
||||
<key>IS_APPINVITE_ENABLED</key>
|
||||
<true></true>
|
||||
<key>IS_GCM_ENABLED</key>
|
||||
<true></true>
|
||||
<key>IS_SIGNIN_ENABLED</key>
|
||||
<true></true>
|
||||
<key>GOOGLE_APP_ID</key>
|
||||
<string>1:194977404578:ios:f26373d7487896293669fb</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user