Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Tejada committed Oct 15, 2021
1 parent 10904e6 commit 16b2f62
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
13 changes: 8 additions & 5 deletions packages/react-devtools-extensions/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ function createPanelIfReactLoaded() {

function onDuplicateExtensionMessage(message) {
if (message === SHOW_DUPLICATE_EXTENSION_WARNING) {
chrome.runtime.onMessage.removeListener(
onDuplicateExtensionMessage,
);

if (warnIfDuplicateInstallation === true) {
return;
}
Expand All @@ -134,14 +138,14 @@ function createPanelIfReactLoaded() {
chrome.devtools.inspectedWindow.eval(
`console.error("${errorMessage}")`,
);
render();
if (render != null) {
render();
}
}
}
chrome.runtime.onMessage.addListener(onDuplicateExtensionMessage);

function initBridgeAndStore() {
chrome.runtime.onMessage.removeListener(onDuplicateExtensionMessage);
chrome.runtime.onMessage.addListener(onDuplicateExtensionMessage);

const port = chrome.runtime.connect({
name: String(tabId),
});
Expand Down Expand Up @@ -398,7 +402,6 @@ function createPanelIfReactLoaded() {
browserTheme: getBrowserTheme(),
componentsPortalContainer,
enabledInspectedElementContextMenu: true,
isInternalBuild: EXTENSION_INSTALLATION_TYPE === 'internal',
fetchFileWithCaching,
hookNamesModuleLoaderFunction,
overrideTab,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export type Props = {|
canViewElementSourceFunction?: ?CanViewElementSource,
defaultTab?: TabID,
enabledInspectedElementContextMenu?: boolean,
isInternalBuild?: boolean,
showTabBar?: boolean,
store: Store,
warnIfDuplicateInstallation?: boolean,
Expand Down Expand Up @@ -129,7 +128,6 @@ export default function DevTools({
componentsPortalContainer,
defaultTab = 'components',
enabledInspectedElementContextMenu = false,
isInternalBuild = false,
fetchFileWithCaching,
hookNamesModuleLoaderFunction,
overrideTab,
Expand Down Expand Up @@ -324,11 +322,7 @@ export default function DevTools({
</ViewElementSourceContext.Provider>
</SettingsContextController>
<UnsupportedBridgeProtocolDialog />
{warnIfDuplicateInstallation && (
<DuplicateInstallationDialog
isInternalBuild={isInternalBuild}
/>
)}
{warnIfDuplicateInstallation && <DuplicateInstallationDialog />}
{warnIfLegacyBackendDetected && <WarnIfLegacyBackendDetected />}
{warnIfUnsupportedVersionDetected && <UnsupportedVersionDialog />}
</ModalDialogContextController>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@

import * as React from 'react';
import {Fragment, useContext, useEffect} from 'react';
import {isInternalFacebookBuild} from 'react-devtools-feature-flags';
import {ModalDialogContext} from './ModalDialog';

type Props = {|isInternalBuild: boolean|};

export default function DuplicateInstallationDialog(props: Props) {
export default function DuplicateInstallationDialog(_: {||}) {
const {dispatch} = useContext(ModalDialogContext);

useEffect(() => {
Expand All @@ -22,21 +21,21 @@ export default function DuplicateInstallationDialog(props: Props) {
id: 'DuplicateInstallationDialog',
type: 'SHOW',
title: 'Duplicate Installations of DevTools Detected',
content: <DialogContent isInternalBuild={props.isInternalBuild} />,
content: <DialogContent />,
});
}, []);
return null;
}

function DialogContent(props: Props) {
function DialogContent(_: {||}) {
return (
<Fragment>
<p>
We detected that there are multiple versions of React Developer Tools
installed and enabled in your browser at the same time, which will cause
issues while using the extension.
</p>
{props.isInternalBuild ? (
{isInternalFacebookBuild ? (
<p>
Before proceeding, please ensure that the only enabled version of
React Developer Tools is the internal (Chef-installed) version. To
Expand Down

0 comments on commit 16b2f62

Please sign in to comment.