Skip to content

Commit

Permalink
Disable highlighting if ad unit is available.
Browse files Browse the repository at this point in the history
  • Loading branch information
amovar18 committed Jan 20, 2025
1 parent 0dd8245 commit 25fac8c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ import { InspectActiveIcon, InspectIcon, InspectWhiteIcon } from '../../icons';

interface InspectButtonProps {
isInspecting: boolean;
selectedAdUnit: string | null;
setIsInspecting: React.Dispatch<React.SetStateAction<boolean>>;
isTabFocused: boolean;
}

const InspectButton = ({
isInspecting,
selectedAdUnit,
setIsInspecting,
isTabFocused,
}: InspectButtonProps) => {
Expand All @@ -44,7 +46,11 @@ const InspectButton = ({
setIsInspecting(!isInspecting);
}}
>
{isInspecting ? <InspectActiveIcon /> : <InactiveInspectIcon />}
{isInspecting && !selectedAdUnit ? (
<InspectActiveIcon />
) : (
<InactiveInspectIcon />
)}
</span>
);
};
Expand Down
12 changes: 11 additions & 1 deletion packages/extension/src/view/devtools/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ import classNames from 'classnames';
*/
import Cookies from './cookies';
import useFrameOverlay from '../hooks/useFrameOverlay';
import { useCookie, useSettings } from '../stateProviders';
import {
useCookie,
useProtectedAudience,
useSettings,
} from '../stateProviders';
import { getCurrentTabId } from '../../../utils/getCurrentTabId';

interface LayoutProps {
Expand All @@ -55,6 +59,10 @@ const Layout = ({ setSidebarData }: LayoutProps) => {
const [sidebarWidth, setSidebarWidth] = useState(200);
const mainRef = useRef<HTMLElement>(null);

const { selectedAdUnit } = useProtectedAudience(({ state }) => ({
selectedAdUnit: state.selectedAdUnit,
}));

const { settingsChanged, handleSettingsChange } = useSettings(
({ state, actions }) => ({
settingsChanged: state.settingsChanged,
Expand Down Expand Up @@ -146,6 +154,7 @@ const Layout = ({ setSidebarData }: LayoutProps) => {
Element: InspectButton,
props: {
isInspecting,
selectedAdUnit,
setIsInspecting,
isTabFocused:
isSidebarFocused && isKeySelected(SIDEBAR_ITEMS_KEYS.COOKIES),
Expand All @@ -158,6 +167,7 @@ const Layout = ({ setSidebarData }: LayoutProps) => {
return data;
});
}, [
selectedAdUnit,
canStartInspecting,
frameHasCookies,
isInspecting,
Expand Down

0 comments on commit 25fac8c

Please sign in to comment.