refactor: fixed customize toolbar action
This commit is contained in:
@@ -16,11 +16,15 @@ export const DEFAULT_ACTION_ORDER: ToolbarActionOrder = {
|
||||
),
|
||||
more: [
|
||||
...Object.values(COMMAND_ID.integration),
|
||||
...Object.values(COMMAND_ID.entry)
|
||||
.filter((id) => !([COMMAND_ID.entry.read, COMMAND_ID.entry.unread] as string[]).includes(id))
|
||||
.filter((id) =>
|
||||
([COMMAND_ID.entry.copyLink, COMMAND_ID.entry.openInBrowser] as string[]).includes(id),
|
||||
),
|
||||
COMMAND_ID.settings.customizeToolbar,
|
||||
...Object.values(COMMAND_ID.entry).filter((id) =>
|
||||
(
|
||||
[
|
||||
COMMAND_ID.entry.copyLink,
|
||||
COMMAND_ID.entry.openInBrowser,
|
||||
COMMAND_ID.entry.read,
|
||||
COMMAND_ID.entry.unread,
|
||||
] as string[]
|
||||
).includes(id),
|
||||
),
|
||||
],
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@ import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "~/components/ui/dropdown-menu/dropdown-menu"
|
||||
import { useEntryActions } from "~/hooks/biz/useEntryActions"
|
||||
import { COMMAND_ID } from "~/modules/command/commands/id"
|
||||
import { useCommand } from "~/modules/command/hooks/use-command"
|
||||
import type { FollowCommandId } from "~/modules/command/types"
|
||||
import { useToolbarOrderMap } from "~/modules/customize-toolbar/hooks"
|
||||
@@ -21,17 +23,24 @@ export const MoreActions = ({ entryId, view }: { entryId: string; view?: FeedVie
|
||||
actionConfigs
|
||||
.filter((item) => {
|
||||
const order = orderMap.get(item.id)
|
||||
if (!order) return false
|
||||
// If the order is not set, it should be in the "more" menu
|
||||
if (!order) return true
|
||||
return order.type !== "main"
|
||||
})
|
||||
.filter((item) => item.id !== COMMAND_ID.settings.customizeToolbar)
|
||||
.sort((a, b) => {
|
||||
const orderA = orderMap.get(a.id)?.order || 0
|
||||
const orderB = orderMap.get(b.id)?.order || 0
|
||||
const orderA = orderMap.get(a.id)?.order || Infinity
|
||||
const orderB = orderMap.get(b.id)?.order || Infinity
|
||||
return orderA - orderB
|
||||
}),
|
||||
[actionConfigs, orderMap],
|
||||
)
|
||||
|
||||
const extraAction = useMemo(
|
||||
() => actionConfigs.filter((item) => item.id === COMMAND_ID.settings.customizeToolbar),
|
||||
[actionConfigs],
|
||||
)
|
||||
|
||||
if (availableActions.length === 0) {
|
||||
return null
|
||||
}
|
||||
@@ -45,6 +54,10 @@ export const MoreActions = ({ entryId, view }: { entryId: string; view?: FeedVie
|
||||
{availableActions.map((config) => (
|
||||
<CommandDropdownMenuItem key={config.id} commandId={config.id} onClick={config.onClick} />
|
||||
))}
|
||||
<DropdownMenuSeparator />
|
||||
{extraAction.map((config) => (
|
||||
<CommandDropdownMenuItem key={config.id} commandId={config.id} onClick={config.onClick} />
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user