@@ -9,8 +9,10 @@ import { IsProductionVersion } from './util'
99 * on the state of the browser extension.
1010 */
1111
12- /** State of the Sourcegraph browser extension, as represented by the browser
13- * action icon. */
12+ /**
13+ * State of the Sourcegraph browser extension, as represented by the browser
14+ * action icon.
15+ */
1416export type BrowserActionIconState = 'active' | 'active-with-alert' | 'inactive'
1517interface BrowserActionIconPaths {
1618 '32' : string
@@ -21,36 +23,36 @@ interface BrowserActionIconPaths {
2123const browserActionIconPaths : Record < BrowserActionIconState , BrowserActionIconPaths > = IsProductionVersion
2224 ? {
2325 active : {
24- '32' : 'img/icon-32.png' ,
25- '48' : 'img/icon-48.png' ,
26- '128' : 'img/icon-128.png' ,
26+ '32' : '/ img/icon-32.png' ,
27+ '48' : '/ img/icon-48.png' ,
28+ '128' : '/ img/icon-128.png' ,
2729 } ,
2830 'active-with-alert' : {
29- '32' : 'img/icon-active-with-alert-32.png' ,
30- '48' : 'img/icon-active-with-alert-48.png' ,
31- '128' : 'img/icon-active-with-alert-128.png' ,
31+ '32' : '/ img/icon-active-with-alert-32.png' ,
32+ '48' : '/ img/icon-active-with-alert-48.png' ,
33+ '128' : '/ img/icon-active-with-alert-128.png' ,
3234 } ,
3335 inactive : {
34- '32' : 'img/icon-inactive-32.png' ,
35- '48' : 'img/icon-inactive-48.png' ,
36- '128' : 'img/icon-inactive-128.png' ,
36+ '32' : '/ img/icon-inactive-32.png' ,
37+ '48' : '/ img/icon-inactive-48.png' ,
38+ '128' : '/ img/icon-inactive-128.png' ,
3739 } ,
3840 }
3941 : {
4042 active : {
41- '32' : 'img/dev/icon-32.png' ,
42- '48' : 'img/dev/icon-48.png' ,
43- '128' : 'img/dev/icon-128.png' ,
43+ '32' : '/ img/dev/icon-32.png' ,
44+ '48' : '/ img/dev/icon-48.png' ,
45+ '128' : '/ img/dev/icon-128.png' ,
4446 } ,
4547 'active-with-alert' : {
46- '32' : 'img/dev/icon-active-with-alert-32.png' ,
47- '48' : 'img/dev/icon-active-with-alert-48.png' ,
48- '128' : 'img/dev/icon-active-with-alert-128.png' ,
48+ '32' : '/ img/dev/icon-active-with-alert-32.png' ,
49+ '48' : '/ img/dev/icon-active-with-alert-48.png' ,
50+ '128' : '/ img/dev/icon-active-with-alert-128.png' ,
4951 } ,
5052 inactive : {
51- '32' : 'img/dev/icon-inactive-32.png' ,
52- '48' : 'img/dev/icon-inactive-48.png' ,
53- '128' : 'img/dev/icon-inactive-128.png' ,
53+ '32' : '/ img/dev/icon-inactive-32.png' ,
54+ '48' : '/ img/dev/icon-inactive-48.png' ,
55+ '128' : '/ img/dev/icon-inactive-128.png' ,
5456 } ,
5557 }
5658
@@ -60,7 +62,7 @@ const browserActionIconPaths: Record<BrowserActionIconState, BrowserActionIconPa
6062export function setBrowserActionIconState ( iconState : BrowserActionIconState ) : void {
6163 const iconPaths = browserActionIconPaths [ iconState ]
6264 console . log ( 'Setting icons to' , iconPaths )
63- browser . action . setIcon ( { path : iconPaths } ) . catch ( error => {
65+ ; ( browser . action ?? browser . browserAction ) . setIcon ( { path : iconPaths } ) . catch ( error => {
6466 console . error ( error )
6567 } )
6668}
0 commit comments