From 0c221cf60f784f4d3395f13e1844721510798f70 Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Thu, 25 Apr 2024 13:41:57 -0500 Subject: [PATCH] PR-related fixes --- src/background/installer.ts | 6 ++++-- src/contentScript/pageEditor/selectElement.ts | 2 +- src/extensionConsole/pages/UpdateBanner.tsx | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/background/installer.ts b/src/background/installer.ts index c4044a4714..fce835fc4b 100644 --- a/src/background/installer.ts +++ b/src/background/installer.ts @@ -105,9 +105,11 @@ export async function openInstallPage() { // Case 3: there's no Admin Console onboarding tab open if (appOnboardingTab) { - const appOnboardingTabUrl = new URL(appOnboardingTab.url ?? ""); + const appOnboardingTabUrl = appOnboardingTab?.url + ? new URL(appOnboardingTab.url) + : null; - if (appOnboardingTabUrl.pathname === "/start") { + if (appOnboardingTabUrl?.pathname === "/start") { // Case 1a/1b: Admin Console is showing a partner onboarding flow const controlRoomHostname = diff --git a/src/contentScript/pageEditor/selectElement.ts b/src/contentScript/pageEditor/selectElement.ts index f39fea0896..c025c2eea6 100644 --- a/src/contentScript/pageEditor/selectElement.ts +++ b/src/contentScript/pageEditor/selectElement.ts @@ -38,7 +38,7 @@ export default async function selectElement({ root?: string; excludeRandomClasses?: boolean; }): Promise { - const rootElements = $safeFind(root ?? "").get(); + const rootElements = root ? $safeFind(root).get() : []; if (root && rootElements.length === 0) { throw new NoElementsFoundError(root); diff --git a/src/extensionConsole/pages/UpdateBanner.tsx b/src/extensionConsole/pages/UpdateBanner.tsx index 6394ac3e86..3d9f255d37 100644 --- a/src/extensionConsole/pages/UpdateBanner.tsx +++ b/src/extensionConsole/pages/UpdateBanner.tsx @@ -26,7 +26,7 @@ import { getExtensionVersion } from "@/utils/extensionUtils"; // XXX: move this kind of async state to the Redux state. export function useUpdateAvailable(): boolean { - const { data: updateAvailable } = useAsyncState(async () => { + const { data: updateAvailable = false } = useAsyncState(async () => { try { const available = await getAvailableVersion(); const installed = getExtensionVersion(); @@ -37,7 +37,7 @@ export function useUpdateAvailable(): boolean { } }, []); - return Boolean(updateAvailable); + return updateAvailable; } const UpdateBanner: React.FunctionComponent = () => {