From 82156ebe961564d958cb870630a3b6ba1d839b9f Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Wed, 17 Apr 2024 13:24:42 -0500 Subject: [PATCH] Fix screenshare notice window and gracefully fallback mock test env Co-authored-by: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com> --- ts/environment.ts | 7 +++++-- ts/windows/screenShare/app.tsx | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ts/environment.ts b/ts/environment.ts index a92249c6e9..e3ee9f44df 100644 --- a/ts/environment.ts +++ b/ts/environment.ts @@ -2,6 +2,7 @@ // SPDX-License-Identifier: AGPL-3.0-only import { makeEnumParser } from './util/enum'; +import * as log from './logging/log'; // Many places rely on this enum being a string. export enum Environment { @@ -49,7 +50,9 @@ export const isTestEnvironment = (env: Environment): boolean => export const isTestOrMockEnvironment = (): boolean => { if (isMockTestEnvironment == null) { - throw new Error('Mock test environment not set'); + log.error('Mock test environment not set'); } - return isTestEnvironment(getEnvironment()) || isMockTestEnvironment; + return ( + isTestEnvironment(getEnvironment()) || (isMockTestEnvironment ?? false) + ); }; diff --git a/ts/windows/screenShare/app.tsx b/ts/windows/screenShare/app.tsx index 0f29bcca6e..60e8dac794 100644 --- a/ts/windows/screenShare/app.tsx +++ b/ts/windows/screenShare/app.tsx @@ -7,11 +7,17 @@ import ReactDOM from 'react-dom'; import { CallingScreenSharingController } from '../../components/CallingScreenSharingController'; import { i18n } from '../sandboxedInit'; import { strictAssert } from '../../util/assert'; +import { parseEnvironment, setEnvironment } from '../../environment'; const { ScreenShareWindowProps } = window.Signal; strictAssert(ScreenShareWindowProps, 'window values not provided'); +setEnvironment( + parseEnvironment(window.SignalContext.getEnvironment()), + window.SignalContext.isTestOrMockEnvironment() +); + ReactDOM.render(