From f1d61580a81ecfa91aaece981bcf554ead48efbc Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Tue, 3 Sep 2024 21:47:16 -0400 Subject: [PATCH 1/2] Fix mocking Chrome API for Electron (#1748) * Fix mocking Chrome API for Electron * Create chilled-feet-marry.md --- .changeset/chilled-feet-marry.md | 5 +++++ extension/src/app/Actions.tsx | 10 +++------- extension/src/background/index.ts | 1 + extension/src/chromeApiMock.ts | 20 +++++++++++--------- extension/test/electron/devpanel.spec.js | 10 +++++----- 5 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 .changeset/chilled-feet-marry.md diff --git a/.changeset/chilled-feet-marry.md b/.changeset/chilled-feet-marry.md new file mode 100644 index 00000000..ba1abaad --- /dev/null +++ b/.changeset/chilled-feet-marry.md @@ -0,0 +1,5 @@ +--- +'remotedev-redux-devtools-extension': patch +--- + +Fix mocking Chrome API for Electron diff --git a/extension/src/app/Actions.tsx b/extension/src/app/Actions.tsx index 216e59af..656bb6d6 100644 --- a/extension/src/app/Actions.tsx +++ b/extension/src/app/Actions.tsx @@ -29,11 +29,7 @@ interface OwnProps { } type Props = StateProps & DispatchProps & OwnProps; -declare global { - interface Window { - isElectron?: boolean; - } -} +const isElectron = navigator.userAgent.includes('Electron'); function sendMessage(message: SingleMessage) { chrome.runtime.sendMessage(message); @@ -98,7 +94,7 @@ class Actions extends Component { )} - {!window.isElectron && ( + {!isElectron && ( )} - {!window.isElectron && ( + {!isElectron && (