Fix screenshare notice window and gracefully fallback mock test env

This commit is contained in:
ayumi-signal 2024-04-17 10:53:54 -07:00 committed by GitHub
parent 154254f471
commit 968d8d8911
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View file

@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
import { makeEnumParser } from './util/enum'; import { makeEnumParser } from './util/enum';
import * as log from './logging/log';
// Many places rely on this enum being a string. // Many places rely on this enum being a string.
export enum Environment { export enum Environment {
@ -49,7 +50,9 @@ export const isTestEnvironment = (env: Environment): boolean =>
export const isTestOrMockEnvironment = (): boolean => { export const isTestOrMockEnvironment = (): boolean => {
if (isMockTestEnvironment == null) { 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)
);
}; };

View file

@ -7,11 +7,17 @@ import ReactDOM from 'react-dom';
import { CallingScreenSharingController } from '../../components/CallingScreenSharingController'; import { CallingScreenSharingController } from '../../components/CallingScreenSharingController';
import { i18n } from '../sandboxedInit'; import { i18n } from '../sandboxedInit';
import { strictAssert } from '../../util/assert'; import { strictAssert } from '../../util/assert';
import { parseEnvironment, setEnvironment } from '../../environment';
const { ScreenShareWindowProps } = window.Signal; const { ScreenShareWindowProps } = window.Signal;
strictAssert(ScreenShareWindowProps, 'window values not provided'); strictAssert(ScreenShareWindowProps, 'window values not provided');
setEnvironment(
parseEnvironment(window.SignalContext.getEnvironment()),
window.SignalContext.isTestOrMockEnvironment()
);
ReactDOM.render( ReactDOM.render(
<div className="App dark-theme"> <div className="App dark-theme">
<CallingScreenSharingController <CallingScreenSharingController