Skip to content

Commit

Permalink
fix(scripts): add webNavigation listener after firefox restart
Browse files Browse the repository at this point in the history
  • Loading branch information
stoically committed Aug 10, 2020
1 parent a19e634 commit e832ae5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions src/background/event-listeners.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { TemporaryContainers } from './tmp';
import { Debug, Permissions } from '~/types';
import { Debug } from '~/types';

// to have persistent listeners we need to register them early+sync
// and wait for tmp to fully initialize before handling events
Expand Down Expand Up @@ -166,15 +166,14 @@ export class EventListeners {
this.registerPermissionedListener();
}

registerPermissionedListener(permissions?: Permissions): void {
permissions?.webNavigation &&
browser.webNavigation?.onCommitted.addListener(
this.wrap(
browser.webNavigation?.onCommitted,
this.background.scripts,
'maybeExecute'
)
);
registerPermissionedListener(): void {
browser.webNavigation?.onCommitted.addListener(
this.wrap(
browser.webNavigation?.onCommitted,
this.background.scripts,
'maybeExecute'
)
);
}

wrap(
Expand Down
2 changes: 1 addition & 1 deletion src/background/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class Preferences {
}
if (!this.permissions.webNavigation && newPreferences.scripts.active) {
this.permissions.webNavigation = true;
this.eventlisteners.registerPermissionedListener(this.permissions);
this.eventlisteners.registerPermissionedListener();
}

if (
Expand Down

0 comments on commit e832ae5

Please sign in to comment.