-
Notifications
You must be signed in to change notification settings - Fork 338
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: update UI to use new client uploadImage function #967
refactor: update UI to use new client uploadImage function #967
Conversation
I noticed that there's already a PR up related to uploading images (#812). Should I implement that as part of this PR? It looks like there's not much code in the change and judging by this comment was supposed to be in the 0.17 release but didn't make it. Also, it seems like translations have already been added for the change. |
@@ -1441,3 +1442,9 @@ export function selectableLanguages( | |||
} | |||
} | |||
} | |||
|
|||
export function uploadImage(image: File): Promise<UploadImageResponse> { | |||
const client = new LemmyHttp(httpBase); |
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.
It looks like there are multiple functions that rely on a lemmy HTTP client newed up with the just the HTTP base URL (i.e. this function, fetchCommunities
, and fetchUsers
). It may make more sense to just make a module level variable variable of the HTTP client instead of newing it up every time one of these functions is called. Thoughts?
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'd def be good with that. Maybe as a service-y type singleton pattern alongside WebSocketService
and UserService
.
The isometric back-end does have to have its own separate http client tho I think, that's in server/index.ts
But ya it doesn't have to be a part of this PR, but feel free to add an issue for it.
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.
Looks good, thanks!
i.setState({ loading: false }); | ||
i.props.onUpload(url); | ||
i.props.onUpload(res.url as string); |
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.
Looks much cleaner.
@@ -1441,3 +1442,9 @@ export function selectableLanguages( | |||
} | |||
} | |||
} | |||
|
|||
export function uploadImage(image: File): Promise<UploadImageResponse> { | |||
const client = new LemmyHttp(httpBase); |
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'd def be good with that. Maybe as a service-y type singleton pattern alongside WebSocketService
and UserService
.
The isometric back-end does have to have its own separate http client tho I think, that's in server/index.ts
But ya it doesn't have to be a part of this PR, but feel free to add an issue for it.
This PR updates the UI project to use the upload image change introduced in the most recent lemmy-js-client update.