fix: make useServerAction accept void-returning actions and remove dead queryCount
Local Build and Deploy / deploy (push) Successful in 53s
Local Build and Deploy / deploy (push) Successful in 53s
- Type run()'s action param as Promise<unknown> and cast result (Biome strips void from unions) - Remove unused queryCount field increment in DbService (dead code) - Reformat theme-contrast test pair assertions
This commit is contained in:
1 parent
1908136071
commit
2455a4850e
4 files changed
+12
-835
No files matched your search
@@ -36,10 +36,7 @@ export function useServerAction(options: UseServerActionOptions = {}) {
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const router = useRouter();
|
||||
|
||||
function run(
|
||||
action: () => Promise<ActionResult | undefined | void>,
|
||||
opts: RunOptions = {},
|
||||
) {
|
||||
function run(action: () => Promise<unknown>, opts: RunOptions = {}) {
|
||||
const {
|
||||
successMessage = "Saved successfully.",
|
||||
errorMessage = "An error occurred.",
|
||||
@@ -49,7 +46,7 @@ export function useServerAction(options: UseServerActionOptions = {}) {
|
||||
|
||||
startTransition(async () => {
|
||||
try {
|
||||
const result = await action();
|
||||
const result = (await action()) as ActionResult | undefined;
|
||||
|
||||
if (!result || result.ok) {
|
||||
toast.success(successMessage);
|
||||
|
||||
Reference in new issue
Block a user