Skip to content

upload: add before-remove function #8788

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

Merged
merged 2 commits into from
Dec 13, 2017

Conversation

firesh
Copy link
Contributor

@firesh firesh commented Dec 12, 2017

upload: add before-remove function. It can support a function returns a boolean or Promise.
#8399 requests this feature.

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow Element's contributing guide (中文 | English | Español).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer relative issues for you PR.

@firesh
Copy link
Contributor Author

firesh commented Dec 12, 2017

@Leopoldthecoder Both Chinese and English document are updated. But I was not able to translate it to Spanish. So I just Keep it for others folks.

doRemove();
}, () => {
// do nothing
});
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use noop here:

before.then(() => {
  doRemove();
}, noop);

doRemove();
} else {
// do nothing
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This else block can be removed entirely.

handleBeforeRemove(file, fileList) {
return new Promise((resolve, reject) => {
if (confirm('It looks good, are you sure to remove?')) {
resolve()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a semicolon here. Also applies to the other 7 resolve()s and reject()s.

@Leopoldthecoder
Copy link
Contributor

Thanks for contributing.

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