Skip to content

Commit afc5f46

Browse files
feat: memoize tab computations and fix empty strings not showing up
1 parent 9f6c7ed commit afc5f46

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

clients/web/src/components/tauri/configuration-view.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { MissingConfigurationParameterDialog } from "./dialogs/missing-configura
99
import { MissingConfigurationDialog } from "./dialogs/missing-configuration-dialog";
1010
import { Heading } from "../heading";
1111
import { TauriConfig } from "~/lib/tauri/config/tauri-conf";
12+
import { createMemo } from "solid-js";
1213

1314
export function ConfigurationView() {
1415
const params = useParams<{
@@ -23,17 +24,24 @@ export function ConfigurationView() {
2324

2425
const config = () => retrieveConfigurationByKey(params.config);
2526

26-
const tab = () => {
27+
const tab = createMemo(() => {
2728
const config = retrieveConfigurationByKey(params.config);
28-
if (config && config.data && config.data[params.selected])
29+
if (
30+
config &&
31+
config.data &&
32+
(config.data[params.selected] ||
33+
typeof config.data[params.selected] === "string")
34+
)
2935
return config.data[params.selected];
3036
return undefined;
31-
};
37+
});
3238

33-
const tabWithKeys = (currentTab: ReturnType<typeof tab>) => {
39+
const tabWithKeys = createMemo(() => {
40+
const currentTab = tab();
41+
if (typeof currentTab === "string" && currentTab === "") return "empty";
3442
if (!currentTab || !(Object.keys(currentTab).length > 0)) return undefined;
3543
return currentTab;
36-
};
44+
});
3745

3846
createEffect(() => {
3947
const data = tab();
@@ -55,7 +63,7 @@ export function ConfigurationView() {
5563
<h1 class="text-3xl">{config()?.label}</h1>
5664
<ConfigurationErrors error={config()?.error} />
5765
</Match>
58-
<Match when={tabWithKeys(tab())}>
66+
<Match when={tabWithKeys()}>
5967
{(t) => (
6068
<>
6169
<header>

0 commit comments

Comments
 (0)