- Notifications
You must be signed in to change notification settings - Fork406
Update to promise api for some methods in the electron API#2626
Uh oh!
There was an error while loading.Please reload this page.
Changes from5 commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -45,15 +45,13 @@ export default class DirectorySelect extends React.Component { | ||
); | ||
} | ||
chooseDirectory =async () => { | ||
const {filePaths} = awaitthis.props.showOpenDialog(this.props.currentWindow, { | ||
defaultPath: this.props.buffer.getText(), | ||
properties: ['openDirectory', 'createDirectory', 'promptToCreate'], | ||
}); | ||
if (filePaths.length) { | ||
this.props.buffer.setText(filePaths[0]); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. 👍 Perfect! | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -328,9 +328,9 @@ class WaterfallWidget extends React.Component { | ||
const buffer = new TextBuffer({text: json}); | ||
dialog.showSaveDialog({ | ||
defaultPath: 'git-timings.json', | ||
}).then(({filePath}) => { | ||
if (!filePath) { return; } | ||
buffer.saveAs(filePath); | ||
| ||
}); | ||
} | ||
} | ||
@@ -423,9 +423,9 @@ export default class GitTimingsView extends React.Component { | ||
e.preventDefault(); | ||
dialog.showOpenDialog({ | ||
properties: ['openFile'], | ||
}).then(async({filePaths}) => { | ||
| ||
if (!filePaths.length) { return; } | ||
const filename =filePaths[0]; | ||
try { | ||
const contents = await fs.readFile(filename, {encoding: 'utf8'}); | ||
const data = JSON.parse(contents); | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -24,7 +24,7 @@ describe('DirectorySelect', function() { | ||
<DirectorySelect | ||
currentWindow={atomEnv.getCurrentWindow()} | ||
buffer={buffer} | ||
showOpenDialog={() =>Promise.resolve()} | ||
tabGroup={new TabGroup()} | ||
{...override} | ||
/> | ||
@@ -47,7 +47,7 @@ describe('DirectorySelect', function() { | ||
describe('clicking the directory button', function() { | ||
it('populates the destination path buffer on accept', async function() { | ||
const showOpenDialog = sinon.stub().returns(Promise.resolve({filePaths: ['/some/directory/path']})); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. 👍 Perfect. | ||
const buffer = new TextBuffer({text: '/original'}); | ||
const wrapper = shallow(buildApp({showOpenDialog, buffer})); | ||
@@ -58,7 +58,7 @@ describe('DirectorySelect', function() { | ||
}); | ||
it('leaves the destination path buffer unmodified on cancel', async function() { | ||
const showOpenDialog = sinon.stub().returns(Promise.resolve({filePaths: []})); | ||
const buffer = new TextBuffer({text: '/original'}); | ||
const wrapper = shallow(buildApp({showOpenDialog, buffer})); | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -167,7 +167,7 @@ describe('WorkerManager', function() { | ||
}); | ||
`; | ||
await browserWindow.webContents.executeJavaScript(script); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. 🙇🏻 | ||
workerManager.destroy(true); | ||
workerManager = new WorkerManager(); | ||