fix: port disconnecting

This commit is contained in:
fbwoolf
2023-07-11 08:53:28 -05:00
committed by Fara Woolf
parent 8fc248cf0c
commit da3a2f5406

View File

@@ -21,9 +21,16 @@ import {
} from '@shared/message-types';
import { RouteUrls } from '@shared/route-urls';
let backgroundPort: any;
// Connection to background script - fires onConnect event in background script
// and establishes two-way communication
const backgroundPort = chrome.runtime.connect({ name: CONTENT_SCRIPT_PORT });
function connect() {
backgroundPort = chrome.runtime.connect({ name: CONTENT_SCRIPT_PORT });
backgroundPort.onDisconnect.addListener(connect);
}
connect();
// Sends message to background script that an event has fired
function sendMessageToBackground(message: LegacyMessageFromContentScript) {