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: update UI to use new client uploadImage function #967

Merged
merged 2 commits into from
Mar 27, 2023

Conversation

SleeplessOne1917
Copy link
Member

This PR updates the UI project to use the upload image change introduced in the most recent lemmy-js-client update.

@SleeplessOne1917
Copy link
Member Author

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);
Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member

@dessalines dessalines left a 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);
Copy link
Member

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);
Copy link
Member

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.

@dessalines dessalines enabled auto-merge (squash) March 27, 2023 02:05
@dessalines dessalines merged commit 47daa9d into LemmyNet:main Mar 27, 2023
@SleeplessOne1917 SleeplessOne1917 deleted the lemmy-client-pictrs branch March 29, 2023 19:55
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