Skip to content

Commit

Permalink
App Parameters Coding Improvements (#317)
Browse files Browse the repository at this point in the history
**User-Facing Changes**
N/A

**Description**
Coding improvements:
- The CLIFlags type was created but was not re-used as expected.
- "props" already was unstructured in some lines before, with that, I
just used this structure following this good practice.

<!-- link relevant GitHub issues -->
<!-- add `docs` label if this PR requires documentation updates -->
<!-- add relevant metric tracking for experimental / new features -->

**Checklist**

- [x] The web version was tested and it is running ok
- [x] The desktop version was tested and it is running ok
- [x] This change is covered by unit tests
- [x] Files constants.ts, types.ts and *.style.ts have been checked and
relevant code snippets have been relocated

Signed-off-by: Luiz Bezerra <[email protected]>
  • Loading branch information
luluiz authored Dec 30, 2024
1 parent 7740942 commit 150b401
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions packages/suite-desktop/src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { getExtensions, installExtension, loadExtension, uninstallExtension } fr
import { fetchLayouts } from "./layouts";
import { decodeRendererArg } from "../common/rendererArgs";
import {
CLIFlags,
Desktop,
ForwardedMenuEvent,
ForwardedWindowEvent,
Expand Down Expand Up @@ -117,8 +118,8 @@ export function main(): void {
async updateLanguage() {
await ipcRenderer.invoke("updateLanguage");
},
async getCLIFlags(): Promise<Readonly<Record<string, string>>> {
return await (ipcRenderer.invoke("getCLIFlags") as Promise<Readonly<Record<string, string>>>);
async getCLIFlags(): Promise<CLIFlags> {
return await (ipcRenderer.invoke("getCLIFlags") as Promise<CLIFlags>);
},
getDeepLinks(): string[] {
return deepLinks;
Expand Down
12 changes: 7 additions & 5 deletions packages/suite-desktop/src/renderer/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ const storageBridge = (global as unknown as { storageBridge?: Storage }).storage
const menuBridge = (global as { menuBridge?: NativeMenuBridge }).menuBridge;
const ctxbridge = (global as { ctxbridge?: OsContext }).ctxbridge;

export default function Root(props: {
type RootProps = {
appParameters: CLIFlags;
appConfiguration: IAppConfiguration;
extraProviders: React.JSX.Element[] | undefined;
dataSources: IDataSourceFactory[] | undefined;
}): React.JSX.Element {
};

export default function Root(props: RootProps): React.JSX.Element {
if (!storageBridge) {
throw new Error("storageBridge is missing");
}
const { appConfiguration } = props;
const { appConfiguration, appParameters, extraProviders } = props;

useEffect(() => {
const handler = () => {
Expand Down Expand Up @@ -150,7 +152,7 @@ export default function Root(props: {

return (
<App
appParameters={props.appParameters}
appParameters={appParameters}
deepLinks={deepLinks}
dataSources={dataSources}
appConfiguration={appConfiguration}
Expand All @@ -169,7 +171,7 @@ export default function Root(props: {
onMaximizeWindow={onMaximizeWindow}
onUnmaximizeWindow={onUnmaximizeWindow}
onCloseWindow={onCloseWindow}
extraProviders={props.extraProviders}
extraProviders={extraProviders}
/>
);
}

0 comments on commit 150b401

Please sign in to comment.