fix: should hide unhandled action in some place

- Updated `useEntryActions` to include `routeEntryId` for better context handling.
- Added `isCurrentVisitEntry` logic to conditionally hide the export action in the entry menu.
- Modified `MoreActions` component to conditionally render the customize toolbar action based on the new prop.
- Adjusted animation properties in `EntryItemWrapper` for smoother transitions.
- Added `data-hide-in-print` attribute to `AIChatFixedPanel` for improved print handling.

These changes improve the functionality and user experience of entry actions and related UI components.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei 2025-09-05 23:55:05 +08:00
parent f251e05c96
commit 82dc3992c9
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
4 changed files with 24 additions and 15 deletions

View File

@ -228,7 +228,7 @@ export const useEntryActions = ({
compact?: boolean
}) => {
const entry = useEntry(entryId, entrySelector)
const { isCollection } = useRouteParams()
const { isCollection, entryId: routeEntryId } = useRouteParams()
const isInCollection = useIsEntryStarred(entryId)
const isEntryInReadability = useEntryIsInReadability(entryId)
@ -256,6 +256,8 @@ export const useEntryActions = ({
const shortcuts = useCommandShortcuts()
const isCurrentVisitEntry = routeEntryId === entryId
const actionConfigs: EntryActionItem[] = useMemo(() => {
if (!hasEntry) return []
@ -338,6 +340,7 @@ export const useEntryActions = ({
}),
new EntryActionMenuItem({
id: COMMAND_ID.entry.exportAsPDF,
hide: !isCurrentVisitEntry,
onClick: runCmdFn(COMMAND_ID.entry.exportAsPDF, [{ entryId }]),
entryId,
}),
@ -497,6 +500,7 @@ export const useEntryActions = ({
shortcuts,
view,
isInCollection,
isCurrentVisitEntry,
isShowSourceContent,
isShowAISummaryAuto,
isShowAISummaryOnce,
@ -506,7 +510,6 @@ export const useEntryActions = ({
isCollection,
compact,
isEntryInReadability,
integrationSettings.customIntegration,
integrationSettings.enableCustomIntegration,
])

View File

@ -13,6 +13,7 @@ export const AIChatFixedPanel: FC<AIChatFixedPanelProps> = ({ className, ...prop
return (
<Focusable
scope={HotkeyScope.AIChat}
data-hide-in-print
className={cn("bg-background relative flex h-full flex-col overflow-hidden", className)}
{...props}
>

View File

@ -248,9 +248,9 @@ const ActionBar = ({ entryId }: { entryId: string }) => {
return (
<m.div
initial={{ opacity: 0, scale: 0.9, y: "-1/2" }}
animate={{ opacity: 1, scale: 1, y: "-1/2" }}
exit={{ opacity: 0, scale: 0.9, y: "-1/2" }}
initial={{ opacity: 0, scale: 0.9, translateY: "-1/2" }}
animate={{ opacity: 1, scale: 1, translateY: "-1/2" }}
exit={{ opacity: 0, scale: 0.9, translateY: "-1/2" }}
transition={Spring.presets.smooth}
className="absolute -right-2 top-0 -translate-y-1/2 rounded-lg border border-gray-200 bg-white/90 p-1 shadow-sm backdrop-blur-sm dark:border-neutral-900 dark:bg-neutral-900"
onClick={(e) => {
@ -260,7 +260,7 @@ const ActionBar = ({ entryId }: { entryId: string }) => {
>
<div className="flex items-center gap-1">
<EntryHeaderActions entryId={entryId} view={view} compact />
<MoreActions entryId={entryId} view={view} compact />
<MoreActions entryId={entryId} view={view} compact hideCustomizeToolbar />
</div>
</m.div>
)

View File

@ -27,10 +27,12 @@ export const MoreActions = ({
entryId,
view,
compact,
hideCustomizeToolbar = false,
}: {
entryId: string
view: FeedViewType
compact?: boolean
hideCustomizeToolbar?: boolean
}) => {
const { moreAction } = useSortedEntryActions({ entryId, view })
@ -56,14 +58,17 @@ export const MoreActions = ({
const runCmdFn = useRunCommandFn()
const extraAction: EntryActionMenuItem[] = useMemo(
() => [
new EntryActionMenuItem({
id: COMMAND_ID.settings.customizeToolbar,
onClick: runCmdFn(COMMAND_ID.settings.customizeToolbar, []),
entryId,
}),
],
[entryId, runCmdFn],
() =>
!hideCustomizeToolbar
? [
new EntryActionMenuItem({
id: COMMAND_ID.settings.customizeToolbar,
onClick: runCmdFn(COMMAND_ID.settings.customizeToolbar, []),
entryId,
}),
]
: [],
[entryId, hideCustomizeToolbar, runCmdFn],
)
if (availableActions.length === 0 && extraAction.length === 0) {
@ -121,7 +126,7 @@ export const MoreActions = ({
return null
})}
{availableActions.length > 0 && <DropdownMenuSeparator />}
{availableActions.length > 0 && extraAction.length > 0 && <DropdownMenuSeparator />}
{extraAction
.filter((item) => item instanceof MenuItemText)
.map((config) => (