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

feat: promisify dialog.showOpenDialog() #16973

Merged
merged 3 commits into from Mar 5, 2019
Merged

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Feb 14, 2019

Description of Change

Promisifies dialog.showOpenDialog().

cc @ckerr @MarshallOfSound @deepak1556

Checklist

Release Notes

Notes: Split dialog.showOpenDialog() into a synchronous version and a version that returns a Promise

@codebytere codebytere requested review from a team February 14, 2019 20:07
@codebytere codebytere changed the title [wip] feat: promisify dialog.showOpenDialog() feat: promisify dialog.showOpenDialog() Feb 14, 2019
@codebytere codebytere changed the title feat: promisify dialog.showOpenDialog() [wip] feat: promisify dialog.showOpenDialog() Feb 15, 2019
@codebytere codebytere added the semver/major incompatible API changes label Feb 15, 2019
@codebytere codebytere force-pushed the promisify-showopendialog branch 2 times, most recently from f0169e8 to 0cca779 Compare February 15, 2019 16:47
@codebytere codebytere changed the title [wip] feat: promisify dialog.showOpenDialog() feat: promisify dialog.showOpenDialog() Feb 15, 2019
@codebytere codebytere changed the title feat: promisify dialog.showOpenDialog() [wip] feat: promisify dialog.showOpenDialog() Feb 16, 2019
@codebytere codebytere changed the title [wip] feat: promisify dialog.showOpenDialog() feat: promisify dialog.showOpenDialog() Feb 16, 2019
@codebytere
Copy link
Member Author

codebytere commented Feb 19, 2019

Needs rebase on #17050 once it's merged.

@codebytere codebytere force-pushed the promisify-showopendialog branch 2 times, most recently from d3f91d1 to 2bca51f Compare February 25, 2019 08:27
atom/browser/ui/file_dialog_gtk.cc Outdated Show resolved Hide resolved
atom/browser/ui/file_dialog_win.cc Outdated Show resolved Hide resolved
@codebytere codebytere force-pushed the promisify-showopendialog branch 3 times, most recently from ac6dc6e to 6f4ba16 Compare February 27, 2019 09:01
Copy link
Contributor

@miniak miniak left a comment

Choose a reason for hiding this comment

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

can you please include this change as well a757e25?
it refactors the ELECTRON_INSPECTOR_SELECT_FILE IPC handler to use the promisified version of dialog.showOpenDialog()

atom/browser/ui/file_dialog_gtk.cc Outdated Show resolved Hide resolved
atom/browser/ui/file_dialog_gtk.cc Outdated Show resolved Hide resolved
@codebytere
Copy link
Member Author

codebytere commented Mar 4, 2019

@miniak i'd rather that be a separate PR once this gets merged so they can be reviewed separately and not create scope creep

@miniak
Copy link
Contributor

miniak commented Mar 4, 2019

@codebytere ok

lib/browser/api/dialog.js Outdated Show resolved Hide resolved
lib/browser/api/dialog.js Show resolved Hide resolved
docs/api/dialog.md Outdated Show resolved Hide resolved
Copy link
Contributor

@miniak miniak left a comment

Choose a reason for hiding this comment

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

this fix needs to be included to avoid breaking devtools

diff --git a/lib/browser/chrome-devtools.js b/lib/browser/chrome-devtools.js
index f2db33344..b3aa84f0f 100644
--- a/lib/browser/chrome-devtools.js
+++ b/lib/browser/chrome-devtools.js
@@ -86,9 +86,9 @@ ipcMainUtils.handle('ELECTRON_INSPECTOR_SELECT_FILE', function (event) {
   return new Promise((resolve, reject) => {
     assertChromeDevTools(event.sender, 'window.UI.createFileSelectorElement()')
 
-    dialog.showOpenDialog({}, function (files) {
-      if (files) {
-        const path = files[0]
+    dialog.showOpenDialog({}, function (result) {
+      if (!result.canceled) {
+        const path = result.filePaths[0]
         fs.readFile(path, (error, data) => {
           if (error) {
             reject(error)

@codebytere codebytere merged commit e059851 into master Mar 5, 2019
@release-clerk
Copy link

release-clerk bot commented Mar 5, 2019

Release Notes Persisted

Split dialog.showOpenDialog() into a synchronous version and a version that returns a Promise

@codebytere codebytere deleted the promisify-showopendialog branch March 5, 2019 13:54
kiku-jw pushed a commit to kiku-jw/electron that referenced this pull request May 16, 2019
* feat: promisify dialog.showOpenDialog()

* address feedback from review

* address feedback from review
briandk added a commit to briandk/transcriptase that referenced this pull request Oct 11, 2019
jtojnar added a commit to jtojnar/markdown-image-insertion that referenced this pull request Apr 14, 2021
Electron 6 used by Atom 1.54 splits the methods:
- electron/electron#17298
- electron/electron#16973

Fixes: #5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/major incompatible API changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants