diff --git a/packages/suite-base/src/components/PlaybackControls/index.tsx b/packages/suite-base/src/components/PlaybackControls/index.tsx index a7d8f05965..de82047adb 100644 --- a/packages/suite-base/src/components/PlaybackControls/index.tsx +++ b/packages/suite-base/src/components/PlaybackControls/index.tsx @@ -43,6 +43,7 @@ import { useMessagePipeline, } from "@lichtblick/suite-base/components/MessagePipeline"; import PlaybackSpeedControls from "@lichtblick/suite-base/components/PlaybackSpeedControls"; +import ProblematicComponent from "@lichtblick/suite-base/components/ProblematicComponent/ProblematicComponent"; import Stack from "@lichtblick/suite-base/components/Stack"; import { useCurrentUser } from "@lichtblick/suite-base/context/BaseUserContext"; import { EventsStore, useEvents } from "@lichtblick/suite-base/context/EventsContext"; @@ -190,6 +191,7 @@ export default function PlaybackControls(props: { return ( <> +
diff --git a/packages/suite-base/src/components/ProblematicComponent/ProblematicComponent.tsx b/packages/suite-base/src/components/ProblematicComponent/ProblematicComponent.tsx new file mode 100644 index 0000000000..54e142e1c6 --- /dev/null +++ b/packages/suite-base/src/components/ProblematicComponent/ProblematicComponent.tsx @@ -0,0 +1,42 @@ +// SPDX-FileCopyrightText: Copyright (C) 2023-2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// SPDX-License-Identifier: MPL-2.0 + +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/ + +import React, { useState, useEffect } from "react"; + +type Props = { + userName: string; +}; + +const ProblematicComponent: React.FC = ({ userName }) => { + const [count, setCount] = useState(0); + // const [data, setData] = useState(""); + // const [unnusedData,] = useState(null); // unnused var + + // Complexity issue - bad logic + const handleClick = () => { + setCount(0); + }; + + useEffect(() => { + fetch("/api/data") + .then(async (response) => await response.json()) + .catch((error) => { + console.error("Error:", error); + }); + }, []); + + return ( +
+

Hello, {userName}

+

Counter: {count}

+ + {/* {data ?
{data.name}
:

Loading...

} */} +
+ ); +}; + +export default ProblematicComponent; diff --git a/packages/suite-desktop/src/main/index.ts b/packages/suite-desktop/src/main/index.ts index 8a63d4158e..f2dfba174d 100644 --- a/packages/suite-desktop/src/main/index.ts +++ b/packages/suite-desktop/src/main/index.ts @@ -8,6 +8,7 @@ import { app, BrowserWindow, ipcMain, Menu, nativeTheme, session } from "electron"; import fs from "fs"; import i18n from "i18next"; +import path from "path"; import Logger from "@lichtblick/log"; import { AppSetting } from "@lichtblick/suite-base/src/AppSetting"; @@ -138,7 +139,10 @@ export async function main(): Promise { // files our app should open - either from user double-click on a supported fileAssociation // or command line arguments. - const filesToOpen: string[] = process.argv.slice(1).filter(isFileToOpen); + const filesToOpen: string[] = process.argv + .slice(1) + .map((filePath) => path.resolve(filePath)) // Convert to absolute path, linux has some problems to resolve relative paths + .filter(isFileToOpen); // indicates the preloader has setup the file input used to inject which files to open let preloaderFileInputIsReady = false; @@ -172,9 +176,9 @@ export async function main(): Promise { preloaderFileInputIsReady = true; }); - ipcMain.handle("setRepresentedFilename", (ev, path: string | undefined) => { + ipcMain.handle("setRepresentedFilename", (ev, filePath: string | undefined) => { const browserWindow = BrowserWindow.fromId(ev.sender.id); - browserWindow?.setRepresentedFilename(path ?? ""); + browserWindow?.setRepresentedFilename(filePath ?? ""); }); const openUrls: string[] = [];