-
Notifications
You must be signed in to change notification settings - Fork 334
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 search page to stop couldnt_find_object
error
#1669
Conversation
couldnt_find_object
error
} | ||
|
||
export class HttpService { | ||
static #_instance: HttpService; | ||
#silent_client: WrappedLemmyHttp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a nicer way to achieve this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of any.
if ( | ||
!(this.state.isIsomorphic || this.props.history.location.state?.searched) | ||
) { | ||
if (!this.state.isIsomorphic) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this because it was causing no search results to display.
f28971c
to
f83cdf0
Compare
src/shared/components/search.tsx
Outdated
|
||
// If we return this object with a state of failed, the catch-all-handler will redirect | ||
// to an error page, so we ignore it by covering up the error with the empty state. | ||
if (resolveObjectResponse.state == "failed") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use triple equals instead of double equals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch - will fix 👍
}); | ||
|
||
await this.search(); | ||
this.props.history.push(`/search${getQueryString(queryParams)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we create a global siteUrl
constant at some point, in case someone installs Lemmy in a subdirectory or something?
When searching for anything that isn't a community or user link (starting with a '!' or '@') while logged in, an error appears as a toast on the search page, or if you're loading the search URL directly, it will show an error page.
Toast:
Error page (when loading the search url with the query parameters directly):
This is because we send a request to the server on the
resolve_object
endpoint which returns an errorcouldnt_find_object
if the input is just random text and it doesn't match to any objects.I've updated the front end to make the requests to
resolve_object
silent. This means that if there is any error, no toast is shown and it is not logged. I think this is acceptable because of the way we are using the endpoint here. we are just interested if it returns any valid results.I'm unsure if there is a better way to implement a "silent client" though, so please let me know if you can think of something a bit more elegant.
Fixes LemmyNet/lemmy#3296