Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
/githubPublic archive

Update to promise api for some methods in the electron API#2626

Merged
smashwilson merged 6 commits intoatom:masterfromasturur:promisification
Feb 14, 2021
Merged
Show file tree
Hide file tree
Changes from5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletionslib/views/directory-select.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -45,15 +45,13 @@ export default class DirectorySelect extends React.Component {
);
}

chooseDirectory =() => new Promise(resolve => {
this.props.showOpenDialog(this.props.currentWindow, {
chooseDirectory =async () => {
const {filePaths} = awaitthis.props.showOpenDialog(this.props.currentWindow, {
defaultPath: this.props.buffer.getText(),
properties: ['openDirectory', 'createDirectory', 'promptToCreate'],
}, filePaths => {
if (filePaths !== undefined) {
this.props.buffer.setText(filePaths[0]);
}
resolve();
});
});
if (filePaths.length) {
this.props.buffer.setText(filePaths[0]);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Perfect!

}
12 changes: 6 additions & 6 deletionslib/views/git-timings-view.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -328,9 +328,9 @@ class WaterfallWidget extends React.Component {
const buffer = new TextBuffer({text: json});
dialog.showSaveDialog({
defaultPath: 'git-timings.json',
}, filename => {
if (!filename) { return; }
buffer.saveAs(filename);
}).then(({filePath}) => {
if (!filePath) { return; }
buffer.saveAs(filePath);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use async/await here too?

});
}
}
Expand DownExpand Up@@ -423,9 +423,9 @@ export default class GitTimingsView extends React.Component {
e.preventDefault();
dialog.showOpenDialog({
properties: ['openFile'],
},asyncfilenames => {
if (!filenames) { return; }
const filename =filenames[0];
}).then(async({filePaths}) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

And here ☝🏻

Sorry, should have clarified that I meant at all three callsites on the first review 👀

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

oh ok no issue, i can convert them, i m still here.

if (!filePaths.length) { return; }
const filename =filePaths[0];
try {
const contents = await fs.readFile(filename, {encoding: 'utf8'});
const data = JSON.parse(contents);
Expand Down
6 changes: 3 additions & 3 deletionstest/views/directory-select.test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ describe('DirectorySelect', function() {
<DirectorySelect
currentWindow={atomEnv.getCurrentWindow()}
buffer={buffer}
showOpenDialog={() =>{}}
showOpenDialog={() =>Promise.resolve()}
tabGroup={new TabGroup()}
{...override}
/>
Expand All@@ -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().callsArgWith(2, ['/some/directory/path']);
const showOpenDialog = sinon.stub().returns(Promise.resolve({filePaths: ['/some/directory/path']}));
Copy link
Contributor

Choose a reason for hiding this comment

The 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}));
Expand All@@ -58,7 +58,7 @@ describe('DirectorySelect', function() {
});

it('leaves the destination path buffer unmodified on cancel', async function() {
const showOpenDialog = sinon.stub().callsArgWith(2, undefined);
const showOpenDialog = sinon.stub().returns(Promise.resolve({filePaths: []}));
const buffer = new TextBuffer({text: '/original'});

const wrapper = shallow(buildApp({showOpenDialog, buffer}));
Expand Down
2 changes: 1 addition & 1 deletiontest/worker-manager.test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -167,7 +167,7 @@ describe('WorkerManager', function() {
});
`;

awaitnew Promise(resolve =>browserWindow.webContents.executeJavaScript(script, resolve));
await browserWindow.webContents.executeJavaScript(script);
Copy link
Contributor

Choose a reason for hiding this comment

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

🙇🏻


workerManager.destroy(true);
workerManager = new WorkerManager();
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp