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) { 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); toast.error(err.message);
}); });
} }

View File

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

View File

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