From fe5f3ac1b9a59c0ae15ea7119c4b6d139fed1ad8 Mon Sep 17 00:00:00 2001 From: Aslam H Date: Sat, 9 Nov 2024 15:12:26 +0700 Subject: [PATCH] chore: remove account and memo --- .../command-palette/command-data.ts | 4 +- .../command-palette/command-group.tsx | 90 ++++++++++--------- .../command-palette/command-palette.tsx | 9 +- 3 files changed, 54 insertions(+), 49 deletions(-) diff --git a/web/app/components/command-palette/command-data.ts b/web/app/components/command-palette/command-data.ts index e8d04735..92ec2379 100644 --- a/web/app/components/command-palette/command-data.ts +++ b/web/app/components/command-palette/command-data.ts @@ -1,5 +1,4 @@ import { icons } from "lucide-react" -import { LaAccount } from "@/lib/schema" import { HTMLLikeElement } from "@/lib/utils" import { useCommandActions } from "~/hooks/actions/use-command-actions" @@ -44,7 +43,6 @@ const createNavigationItem = ( export const createCommandGroups = ( actions: ReturnType, - me: LaAccount, ): Record => ({ home: [ { @@ -97,7 +95,7 @@ export const createCommandGroups = ( icon: "Plus", value: "Create New Page...", label: "Create New Page...", - action: () => actions.createNewPage(me), + action: () => actions.createNewPage(), }, ], }, diff --git a/web/app/components/command-palette/command-group.tsx b/web/app/components/command-palette/command-group.tsx index 96823cbb..8818834b 100644 --- a/web/app/components/command-palette/command-group.tsx +++ b/web/app/components/command-palette/command-group.tsx @@ -10,26 +10,31 @@ export interface CommandItemProps extends Omit { handleAction: (action: CommandAction, payload?: any) => void } -const HTMLLikeRenderer: React.FC<{ content: HTMLLikeElement | string }> = - React.memo(({ content }) => { - return ( - {renderHTMLLikeElement(content)} - ) - }) +const HTMLLikeRenderer: React.FC<{ content: HTMLLikeElement | string }> = ({ + content, +}) => { + return {renderHTMLLikeElement(content)} +} HTMLLikeRenderer.displayName = "HTMLLikeRenderer" -export const CommandItem: React.FC = React.memo( - ({ icon, label, action, payload, shortcut, handleAction, ...item }) => ( - handleAction(action, payload)} - > - {icon && } - - {shortcut && {shortcut}} - - ), +export const CommandItem: React.FC = ({ + icon, + label, + action, + payload, + shortcut, + handleAction, + ...item +}) => ( + handleAction(action, payload)} + > + {icon && } + + {shortcut && {shortcut}} + ) CommandItem.displayName = "CommandItem" @@ -41,33 +46,36 @@ export interface CommandGroupProps { isLastGroup: boolean } -export const CommandGroup: React.FC = React.memo( - ({ heading, items, handleAction, isLastGroup }) => { - return ( - <> - {heading ? ( - - {items.map((item, index) => ( - - ))} - - ) : ( - items.map((item, index) => ( +export const CommandGroup: React.FC = ({ + heading, + items, + handleAction, + isLastGroup, +}) => { + return ( + <> + {heading ? ( + + {items.map((item, index) => ( - )) - )} - {!isLastGroup && } - - ) - }, -) + ))} + + ) : ( + items.map((item, index) => ( + + )) + )} + {!isLastGroup && } + + ) +} CommandGroup.displayName = "CommandGroup" diff --git a/web/app/components/command-palette/command-palette.tsx b/web/app/components/command-palette/command-palette.tsx index 654d3947..fa13739f 100644 --- a/web/app/components/command-palette/command-palette.tsx +++ b/web/app/components/command-palette/command-palette.tsx @@ -32,17 +32,16 @@ export function CommandPalette() { } export function RealCommandPalette() { - const { me } = useAccount({ root: { personalLinks: [], personalPages: [] } }) + const { me } = useAccount({ + root: { personalLinks: [{}], personalPages: [{}] }, + }) const dialogRef = React.useRef(null) const [inputValue, setInputValue] = React.useState("") const [activePage, setActivePage] = React.useState("home") const [open, setOpen] = useAtom(commandPaletteOpenAtom) const actions = useCommandActions() - const commandGroups = React.useMemo( - () => me && createCommandGroups(actions, me), - [actions, me], - ) + const commandGroups = createCommandGroups(actions) const bounce = React.useCallback(() => { if (dialogRef.current) {