Skip to content

Conversation

@Swapnil-2001
Copy link
Contributor

@Swapnil-2001 Swapnil-2001 commented Nov 17, 2020

Fixes #1677

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • is from a uniquely-named feature branch and has been rebased on top of the latest develop branch. (If I was asked to make more changes, I have made sure to rebase onto develop then too)
  • is descriptively named and links to an issue number, i.e. Fixes #123

@catarak kindly let me know if the changes are alright.

.then(res => res.json())
.then(data => resolve({
files: data.files,
const currentUser = getState().user.username;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is the right solution—what if a user is duplicating a sketch that doesn't belong to them?

Copy link
Contributor Author

@Swapnil-2001 Swapnil-2001 Nov 17, 2020

Choose a reason for hiding this comment

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

I see...yes I hadn't thought of that, sorry!

I went through the GET routes specified on the server side and the appropriate one appeared to be router.get('/:username/projects/:project_id', ...), so I thought of implementing it this way.

Copy link
Member

Choose a reason for hiding this comment

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

Sketches/projects (you can use the terms interchangeably) are unique by id so you shouldn't need to include the username. I don't think this is the reason it's failing—I would look at how it's different when calling cloneProject from SketchList.jsx versus Nav.jsx.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree the route should remain '/projects/:project_id', however, I couldn't find an implementation that would allow fetching of projects only by their ID. So I took the liberty of adding another controller and GET route for the same.

Could you please take a look?

@catarak
Copy link
Member

catarak commented Nov 19, 2020

Thanks for working on this! In reviewing your code, I realized it didn't make any sense to make the extra API call when frontend already has the sketch, so I made a new PR: #1686. Want to take a look at that one?

@Swapnil-2001
Copy link
Contributor Author

I realized it didn't make any sense to make the extra API call when frontend already has the sketch

Ah of course. The new PR looks good!

@catarak catarak closed this Nov 19, 2020
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.

"Duplicate Sketch" button broken

2 participants