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

Fix not_a_mod_or_admin errors #131

Merged
merged 4 commits into from
Mar 4, 2025
Merged

Fix not_a_mod_or_admin errors #131

merged 4 commits into from
Mar 4, 2025

Conversation

EricBAndrews
Copy link
Member

@EricBAndrews EricBAndrews commented Mar 4, 2025

Backend changes to address mlemgroup/mlem#1825. Does not require a Mlem PR, but this Mlem PR is pointed at this branch so the changes can be easily tested.

Report feed loaders and the report count in UnreadCount now catch not_an_admin and not_a_mod_or_admin errors and return safe values.

Thanks to the joy of multithreading, there are some race conditions that cause these functions to be called from the frontend which would be extremely painful to resolve; the frontend doesn't ever display the empty responses unless something goes seriously wrong, but the calls still get made and the errors still pop up.

@EricBAndrews EricBAndrews requested a review from a team as a code owner March 4, 2025 01:32
@EricBAndrews EricBAndrews requested review from Sjmarf and removed request for a team March 4, 2025 01:32
Copy link
Member

@Sjmarf Sjmarf left a comment

Choose a reason for hiding this comment

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

LGTM 👍

We might want to consider upgrading to Swift 6 strict concurrency mode (#931) at some point. Having the project in that mode eliminates the possibility of data races occurring. Looks quite time consuming though. It might amount to just putting @MainActor everywhere lol.

Comment on lines 18 to 19
} catch let ApiClientError.response(response, _) where response.error == "not_a_mod_or_admin" {
return .init(items: .init(), prevCursor: nil, nextCursor: nil)
Copy link
Member

Choose a reason for hiding this comment

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

In the ApiErrorResponse file we've got some precedent for how we match these errors. It would be better to continue that precedent here, I think.

In the longer-term it would be nice to create an enum of the error types. This looks possible to do in lemmy-swift-codegen - all of the error types are listed in LemmyErrorType.ts.

@EricBAndrews EricBAndrews merged commit 7df5e6c into master Mar 4, 2025
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.

2 participants