chore: Fix various warnings

This commit is contained in:
Tom Moor
2024-02-05 21:59:14 -05:00
parent 69665a42d7
commit d4d226e011
3 changed files with 10 additions and 4 deletions

View File

@@ -119,7 +119,7 @@ export function actionToKBar(
}
export async function performAction(action: Action, context: ActionContext) {
return action.perform?.(context).catch((err: Error) => {
return action.perform?.(context)?.catch((err: Error) => {
toast.error(err.message);
});
}

View File

@@ -2,6 +2,7 @@
import * as React from "react";
import Tooltip, { Props as TooltipProps } from "~/components/Tooltip";
import { performAction } from "~/actions";
import useIsMounted from "~/hooks/useIsMounted";
import { Action, ActionContext } from "~/types";
export type Props = React.HTMLAttributes<HTMLButtonElement> & {
@@ -25,6 +26,7 @@ const ActionButton = React.forwardRef<HTMLButtonElement, Props>(
{ action, context, tooltip, hideOnActionDisabled, ...rest }: Props,
ref: React.Ref<HTMLButtonElement>
) {
const isMounted = useIsMounted();
const [executing, setExecuting] = React.useState(false);
const disabled = rest.disabled;
@@ -64,7 +66,9 @@ const ActionButton = React.forwardRef<HTMLButtonElement, Props>(
const response = performAction(action, actionContext);
if (response?.finally) {
setExecuting(true);
void response.finally(() => setExecuting(false));
void response.finally(
() => isMounted() && setExecuting(false)
);
}
}
: rest.onClick

View File

@@ -74,6 +74,7 @@ const InputSelect = (props: Props, ref: React.RefObject<InputSelectRef>) => {
disabled,
note,
icon,
nude,
...rest
} = props;
@@ -179,6 +180,7 @@ const InputSelect = (props: Props, ref: React.RefObject<InputSelectRef>) => {
disclosure
className={className}
icon={icon}
$nude={nude}
{...props}
>
{getOptionFromValue(options, select.selectedValue)?.label || (
@@ -261,7 +263,7 @@ const Spacer = styled.div`
flex-shrink: 0;
`;
const StyledButton = styled(Button)<{ nude?: boolean }>`
const StyledButton = styled(Button)<{ $nude?: boolean }>`
font-weight: normal;
text-transform: none;
margin-bottom: 16px;
@@ -274,7 +276,7 @@ const StyledButton = styled(Button)<{ nude?: boolean }>`
}
${(props) =>
props.nude &&
props.$nude &&
css`
border-color: transparent;
box-shadow: none;