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

Re-add setting sourceUrl to null in uploaded images #20795

Merged
merged 8 commits into from Feb 27, 2018

Conversation

epeach
Copy link

@epeach epeach commented Feb 21, 2018

After, this PR and its revert, adding back making uploaded images have null sourceUrls. Including additional unit test. Not including the version re-routing which caused the error initially. We are still not able to handle situations where uploaded images have a non-null sourceUrl and a version, but we will no longer create images with that state.

@epeach
Copy link
Author

epeach commented Feb 21, 2018

Note: I'm working on a PR with a small UI test suite to check for breaking changes to gamelab animations. Will probably end up merging that to staging before this one.

Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

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

Change looks good as-is. I've got cleanup suggestions that could be in this PR or a followup.

// TODO (bbuchanan): This sequencing feels backwards. Eventually, we
// ought to preview and get dimensions from the local filesystem, async
// with the upload itself, but that will mean refactoring away from the
// jQuery uploader.
Copy link
Contributor

Choose a reason for hiding this comment

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

I tore out this comment in #20713 - let's not reintroduce it.


var onMetadataLoaded = animationPickerModule.buildOnImageMetadataLoaded(
"filename.jpg", Goal.NEW_ANIMATION, "filename.jpg",
{filename: "filename.jpg", result: 0, versionId: "string"}, store.dispatch);
Copy link
Contributor

Choose a reason for hiding this comment

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

Style nit: It may seem verbose, but when we have to wrap arguments like this we often just place one argument per line.

var onMetadataLoaded = animationPickerModule.buildOnMetadataLoaded(
  "filename.jpg",
  Goal.NEW_ANIMATION,
  "filename.jpg",
  {
    filename: "filename.jpg",
    result: 0,
    versionId: "string"
  },
  store.dispatch
);

}
dispatch(hide());
}, () => {
const onImageMetadataLoaded = buildOnImageMetadataLoaded(uploadFilename, goal, key, result, dispatch);
Copy link
Contributor

Choose a reason for hiding this comment

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

Reviewing now, I'm questioning our choice of arguments to this method:

  • key is derived from result and its only use is to be passed into this method, which also receives result. Maybe we should compute key within the buildOnImageMetadataLoaded function.
  • Likewise, uploadFilename and goal aren't actually needed in this method and they should still be in the state when the onImageMetadataLoaded callback fires.

It's possible want we really want here is to call

buildOnImageMetadataLoaded(dispatch, getState, result);

which echoes the signature and redux-thunk return value of handleUploadComplete, and then derive the other values in our helper. In fact, that might make it easier to test that we derive those values correctly.

It does mean you'd need to make sure the animationPicker module's redux state is set up correctly in your unit test.

Copy link
Author

Choose a reason for hiding this comment

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

Moving the look-up of goal and uploadFilename makes a lot of sense for organization and I believe the test already supports this state-wise, so that'll be quick and easy to change.

For 'key', since it's used to look-up the sourceUrl in handleUploadComplete, I think it makes more sense to still compute it there and pass it into buildOnImageMetadataLoaded. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 My bad, missed the transitive dependency there.

Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

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

LGTM after addressing Brad's comments.

@epeach epeach merged commit c21b059 into staging Feb 27, 2018
@epeach epeach deleted the gl-anim-loss-upload-url branch March 8, 2018 00:25
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.

None yet

3 participants