Skip to content

feat: promisify dialog.showOpenDialog() - #16973

Merged
codebytere merged 3 commits into
masterfrom
promisify-showopendialog
Mar 5, 2019
Merged

codebytere merged 3 commits into
masterfrom
promisify-showopendialog

Conversation

@codebytere

@codebytere codebytere commented Feb 14, 2019 •

Copy link
Copy Markdown
Member

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 force-pushed the promisify-showopendialog branch from 4bcec77 to bb9cbc7 Compare February 14, 2019 23:36
@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 force-pushed the promisify-showopendialog branch from 4fd58e0 to c056a03 Compare February 16, 2019 16:45
@codebytere codebytere changed the title [wip] feat: promisify dialog.showOpenDialog() feat: promisify dialog.showOpenDialog() Feb 16, 2019
@codebytere
codebytere force-pushed the promisify-showopendialog branch from c056a03 to 10cc766 Compare February 19, 2019 13:44
@codebytere

codebytere commented Feb 19, 2019 •

Copy link
Copy Markdown
Member Author

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
Comment thread atom/browser/ui/file_dialog_gtk.cc Resolved
Comment thread atom/browser/ui/file_dialog_win.cc Resolved
@zcbenz zcbenz mentioned this pull request Feb 25, 2019
5 of 6 tasks
@codebytere
codebytere force-pushed the promisify-showopendialog branch from f517b0e to 271d772 Compare February 26, 2019 12:27
Comment thread atom/browser/ui/file_dialog_gtk.cc Resolved
@codebytere
codebytere force-pushed the promisify-showopendialog branch 3 times, most recently from ac6dc6e to 6f4ba16 Compare February 27, 2019 09:01
@codebytere
codebytere force-pushed the promisify-showopendialog branch from 6f4ba16 to 9d9098a Compare March 1, 2019 08:37

@miniak miniak left a comment •

Copy link
Copy Markdown
Contributor

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()

Comment thread atom/browser/ui/file_dialog_gtk.cc Resolved
Comment thread atom/browser/ui/file_dialog_gtk.cc Resolved
@codebytere

codebytere commented Mar 4, 2019 •

Copy link
Copy Markdown
Member Author

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

@codebytere
codebytere force-pushed the promisify-showopendialog branch from 0efad7d to 674cb11 Compare March 4, 2019 06:31
@miniak

miniak commented Mar 4, 2019

Copy link
Copy Markdown
Contributor

@codebytere ok

Comment thread lib/browser/api/dialog.js Resolved
Comment thread lib/browser/api/dialog.js Resolved
Comment thread docs/api/dialog.md Resolved

@miniak miniak left a comment •

Copy link
Copy Markdown
Contributor

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

release-clerk Bot commented Mar 5, 2019

Copy link
Copy Markdown

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
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.

3 participants