Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 017f59a

Browse files
committed
Update shell.openExternal to promise due to electron update on atom
1 parent 044931d commit 017f59a

File tree

5 files changed

+19
-57
lines changed

5 files changed

+19
-57
lines changed

lib/controllers/issueish-list-controller.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,9 @@ export class BareIssueishListController extends React.Component {
9090
return null;
9191
}
9292

93-
openOnGitHub = url => {
94-
return new Promise((resolve, reject) => {
95-
shell.openExternal(url, {}, err => {
96-
if (err) { reject(err); } else {
97-
resolve();
98-
addEvent('open-issueish-in-browser', {package: 'github', component: this.constructor.name});
99-
}
100-
});
101-
});
93+
openOnGitHub = async url => {
94+
await shell.openExternal(url);
95+
addEvent('open-issueish-in-browser', {package: 'github', component: this.constructor.name});
10296
}
10397

10498
showActionsMenu = /* istanbul ignore next */ issueish => {

lib/controllers/issueish-searches-controller.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,8 @@ export default class IssueishSearchesController extends React.Component {
113113
});
114114
}
115115

116-
onOpenSearch = search => {
116+
onOpenSearch = async search => {
117117
const searchURL = search.getWebURL(this.props.remote);
118-
119-
return new Promise((resolve, reject) => {
120-
shell.openExternal(searchURL, {}, err => {
121-
if (err) { reject(err); } else { resolve(); }
122-
});
123-
});
118+
await shell.openExternal(searchURL);
124119
}
125120
}

lib/controllers/remote-controller.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,7 @@ export default class RemoteController extends React.Component {
6767
createPrUrl += '/compare/' + encodeURIComponent(currentBranch.getName());
6868
createPrUrl += '?expand=1';
6969

70-
return new Promise((resolve, reject) => {
71-
shell.openExternal(createPrUrl, {}, err => {
72-
if (err) {
73-
reject(err);
74-
} else {
75-
incrementCounter('create-pull-request');
76-
resolve();
77-
}
78-
});
79-
});
70+
await shell.openExternal(createPrUrl);
71+
incrementCounter('create-pull-request');
8072
}
8173
}

lib/views/actionable-review-view.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -124,28 +124,17 @@ export default class ActionableReviewView extends React.Component {
124124
}
125125
}
126126

127-
reportAbuse = (commentUrl, author) => {
128-
return new Promise((resolve, reject) => {
129-
const url = 'https://github.com/contact/report-content?report=' +
130-
`${encodeURIComponent(author)}&content_url=${encodeURIComponent(commentUrl)}`;
131-
shell.openExternal(url, {}, err => {
132-
if (err) { reject(err); } else {
133-
resolve();
134-
addEvent('report-abuse', {package: 'github', component: this.constructor.name});
135-
}
136-
});
137-
});
127+
reportAbuse = async (commentUrl, author) => {
128+
const url = 'https://github.com/contact/report-content?report=' +
129+
`${encodeURIComponent(author)}&content_url=${encodeURIComponent(commentUrl)}`;
130+
131+
await shell.openExternal(url);
132+
addEvent('report-abuse', {package: 'github', component: this.constructor.name});
138133
}
139134

140-
openOnGitHub = url => {
141-
return new Promise((resolve, reject) => {
142-
shell.openExternal(url, {}, err => {
143-
if (err) { reject(err); } else {
144-
resolve();
145-
addEvent('open-comment-in-browser', {package: 'github', component: this.constructor.name});
146-
}
147-
});
148-
});
135+
openOnGitHub = async url => {
136+
await shell.openExternal(url);
137+
addEvent('open-comment-in-browser', {package: 'github', component: this.constructor.name});
149138
}
150139

151140
showActionsMenu = (event, content, author) => {

lib/views/issueish-link.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,9 @@ export function openIssueishLinkInNewTab(url, options = {}) {
4444
}
4545
}
4646

47-
export function openLinkInBrowser(uri) {
48-
return new Promise((resolve, reject) => {
49-
shell.openExternal(uri, {}, err => {
50-
if (err) {
51-
reject(err);
52-
} else {
53-
addEvent('open-issueish-in-browser', {package: 'github', from: 'issueish-link'});
54-
resolve();
55-
}
56-
});
57-
});
47+
export async function openLinkInBrowser(uri) {
48+
await shell.openExternal(uri);
49+
addEvent('open-issueish-in-browser', {package: 'github', from: 'issueish-link'});
5850
}
5951

6052
function getAtomUriForGithubUrl(githubUrl) {

0 commit comments

Comments
 (0)