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

Commit 3efa7a2

Browse files
kamikopimgechev
authored andcommitted
fix: Support Electron (#849)
Following suggestion from the issue thread, created an empty polyfills to the chrome.browserAction calls, which are not available in the electron.
1 parent 780279c commit 3efa7a2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

projects/shell-chrome/src/app/background.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import { AngularDetection } from './ng-validate';
22

3+
// Electron does not expose browserAction object,
4+
// Use empty calls as fallback if they are not defined.
5+
const browserAction = chrome.browserAction || {
6+
setIcon: () => {},
7+
setPopup: () => {}
8+
};
9+
310
// By default use the black and white icon.
411
// Replace it only when we detect an Angular app.
5-
chrome.browserAction.setIcon({
12+
browserAction.setIcon({
613
path: {
714
16: `assets/icon-bw16.png`,
815
48: `assets/icon-bw48.png`,
@@ -120,13 +127,13 @@ chrome.runtime.onMessage.addListener((req, sender) => {
120127
return;
121128
}
122129
if (sender && sender.tab) {
123-
chrome.browserAction.setPopup({
130+
browserAction.setPopup({
124131
tabId: sender.tab.id,
125132
popup: `popups/${getPopUpName(req)}`,
126133
});
127134
}
128135
if (sender && sender.tab && req.isAngular) {
129-
chrome.browserAction.setIcon({
136+
browserAction.setIcon({
130137
tabId: sender.tab.id,
131138
path: {
132139
16: `assets/icon16.png`,

0 commit comments

Comments
 (0)