Skip to content

mutations are typed correctly #8122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged

mutations are typed correctly #8122

merged 1 commit into from
Apr 11, 2025

Conversation

estib-vega
Copy link
Contributor

The types for the mutation hooks where defined loosely and outside their value declarations. This lead to the hooks being mistyped by mistake.

  • Move the hooks types to where the hook functions are.
  • Strengthen the types so that we don't mistype by accident.

Copy link

vercel bot commented Apr 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gitbutler-components ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 11, 2025 1:28pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
gitbutler-web ⬜️ Skipped (Inspect) Apr 11, 2025 1:28pm

The types for the mutation hooks where defined loosely and outside their value declarations. This lead to the hooks being mistyped by mistake.

- Move the hooks types to where the hook functions are.
- Strengthen the types so that we don't mistype by accident.
Comment on lines -232 to -235
promise = dispatchResult;
const result = await promise.unwrap().catch((error) => {
onError?.(error, queryArg);
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't swallow the error

Comment on lines +286 to +290
} catch (error: unknown) {
if (onError && isTauriCommandError(error)) {
onError(error, queryArg);
}
throw error;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On error is called, but the error is thrown still

}

return result;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't return the dispatch result

Comment on lines +253 to +260
const result = await dispatchResult.unwrap();
sideEffect?.(result, queryArg);
return result;
} catch (error: unknown) {
if (onError && isTauriCommandError(error)) {
onError(error, queryArg);
}
throw error;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return the mutation result or throw

@estib-vega estib-vega merged commit 1280469 into master Apr 11, 2025
19 checks passed
@estib-vega estib-vega deleted the e-branch-11 branch April 11, 2025 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant