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

chore: remove node-fetch from app code #8178

Merged
merged 6 commits into from
May 16, 2023
Merged

Conversation

mattkrick
Copy link
Member

Description

  • Removes node-fetch since Node now has fetch natively
  • Fixes the update avatar call that used .buffer, which doesn't exist on native fetch

Testing scenarios

  • change your user avatar

Signed-off-by: Matt Krick <matt.krick@gmail.com>
Signed-off-by: Matt Krick <matt.krick@gmail.com>
Signed-off-by: Matt Krick <matt.krick@gmail.com>
@github-actions github-actions bot added size/s and removed size/l labels May 10, 2023
Signed-off-by: Matt Krick <matt.krick@gmail.com>
@github-actions github-actions bot added size/xl and removed size/s labels May 11, 2023
@github-actions
Copy link
Contributor

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR will be delayed and might be rejected due to its size.

packages/client/jest.config.js Show resolved Hide resolved
@@ -38,7 +37,8 @@ const updateUserProfile = async (

if (validUpdatedUser.picture && validUpdatedUser.picture.endsWith('.svg')) {
const res = await fetch(validUpdatedUser.picture)
const buffer = await res.buffer()
const arrayBuffer = await res.arrayBuffer()
Copy link
Member Author

Choose a reason for hiding this comment

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

this is the only real change

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 That piece of code is unused. Apparently we only have one place where we call updateUserProfile and there we only update the name:

UpdateUserProfileMutation(atmosphere, {updatedUser: {preferredName}}, {onError, onCompleted})

We seem to only upload images via uploadUserImage where we convert SVGs to PNG first
const [normalExt, normalBuffer] = await normalizeAvatarUpload(validExt, validBuffer)

Copy link
Member Author

Choose a reason for hiding this comment

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

right you are! we got some good spaghetti code going on there.
shall i remove that .svg conditional clause in this PR or should we save it for later? OK with either option.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's leave it for later and then let's remove the picture input from this mutation completely.

Copy link
Member Author

Choose a reason for hiding this comment

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

Issue made! #8207

@@ -55,7 +55,7 @@
"eslint-plugin-emotion": "^10.0.14",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^1.6.1",
"jest": "^27.0.6",
"jest": "^29.5.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

native fetch isn't available to jest until v28 so i bumped to latest

@github-actions
Copy link
Contributor

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR will be delayed and might be rejected due to its size.

@github-actions
Copy link
Contributor

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR will be delayed and might be rejected due to its size.

@@ -38,7 +37,8 @@ const updateUserProfile = async (

if (validUpdatedUser.picture && validUpdatedUser.picture.endsWith('.svg')) {
const res = await fetch(validUpdatedUser.picture)
const buffer = await res.buffer()
const arrayBuffer = await res.arrayBuffer()
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 That piece of code is unused. Apparently we only have one place where we call updateUserProfile and there we only update the name:

UpdateUserProfileMutation(atmosphere, {updatedUser: {preferredName}}, {onError, onCompleted})

We seem to only upload images via uploadUserImage where we convert SVGs to PNG first
const [normalExt, normalBuffer] = await normalizeAvatarUpload(validExt, validBuffer)

packages/client/jest.config.js Show resolved Hide resolved
Signed-off-by: Matt Krick <matt.krick@gmail.com>
@github-actions
Copy link
Contributor

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR will be delayed and might be rejected due to its size.

@mattkrick mattkrick mentioned this pull request May 16, 2023
1 task
@mattkrick mattkrick merged commit 712abf1 into master May 16, 2023
@mattkrick mattkrick deleted the chore/no-node-fetch branch May 16, 2023 19:50
@mattkrick mattkrick mentioned this pull request May 23, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants