Skip to content
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

Refactor api to simplify code and add proper errors #238

Merged
merged 30 commits into from
Feb 5, 2025

Conversation

Simon-Laux
Copy link
Collaborator

@Simon-Laux Simon-Laux commented Jan 26, 2025

This pr introduces an API context class that has the methods to make requests.
I tries to deduplicate/simplify code, and also making failing request throw an error, like react query mutations expects it.
it is one step into switching accounts easily.
Some progress with typescript typings was also made.

I also added an error screen for the profile screen when an account can not be found, which also shows a search button when it was opened from a username to lessen the impact of #240 :

ScreenRecording_01-27-2025.02-15-24_1.MP4

  • fix lint
  • log and present error dialog when DM chat message failed to send
  • introduce ApiContext (simplify/refactor api) - replace selfPut (was used only in editing a post - I tested it with new method and it still works) - and change getStatusById to get id directly - because thats easier to understand and type
  • also type useLocalSearchParams and add types some more places
  • error screen for account not found

@Simon-Laux Simon-Laux marked this pull request as ready for review January 27, 2025 01:17
@Simon-Laux
Copy link
Collaborator Author

Refactoring is not completed yet, but it is already an improvement and I want to keep the pr small so it is easier to review.
So this can already be merged.

@Simon-Laux Simon-Laux requested a review from Kwasow January 27, 2025 01:24
@Simon-Laux Simon-Laux requested a review from dansup January 27, 2025 13:07
Copy link
Collaborator

@Kwasow Kwasow left a comment

Choose a reason for hiding this comment

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

Nothing to add to what's already been said by @jippi

@dansup dansup merged commit 6c24747 into pixelfed:main Feb 5, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants