diff --git a/src/components/App.tsx b/src/components/App.tsx index 0f4f7f056..86e893fd2 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -207,6 +207,9 @@ const gesture: Gesture = { initialScale: null, }; +const shouldEnableNetworkStats = !!( + typeof process !== "undefined" && process.env?.REACT_APP_SOCKET_SERVER_URL +); export type PointerDownState = Readonly<{ // The first position at which pointerDown happened origin: Readonly<{ x: number; y: number }>; @@ -474,6 +477,7 @@ class App extends React.Component { elements={this.scene.getElements()} onClose={this.toggleStats} isCollaborating={this.props.isCollaborating} + shouldEnableNetworkStats={shouldEnableNetworkStats} /> )} {this.state.toastMessage !== null && ( @@ -881,8 +885,9 @@ class App extends React.Component { }); } if ( - prevState.showStats !== this.state.showStats || - prevProps.isCollaborating !== this.props.isCollaborating + shouldEnableNetworkStats && + (prevState.showStats !== this.state.showStats || + prevProps.isCollaborating !== this.props.isCollaborating) ) { const navigator: Navigator & { connection?: { diff --git a/src/components/Stats.tsx b/src/components/Stats.tsx index 09f311345..ff9b4c724 100644 --- a/src/components/Stats.tsx +++ b/src/components/Stats.tsx @@ -37,6 +37,7 @@ export const Stats = (props: { elements: readonly NonDeletedExcalidrawElement[]; onClose: () => void; isCollaborating?: boolean; + shouldEnableNetworkStats: boolean; }) => { const isMobile = useIsMobile(); const [storageSizes, setStorageSizes] = useState({ @@ -177,7 +178,7 @@ export const Stats = (props: { )} - {props.isCollaborating ? ( + {props.shouldEnableNetworkStats && props.isCollaborating ? ( <> {t("stats.collaboration")}