| author | |
| committer | |
| log | 549043863a3ca1f955c66fd31bda27ea3dc97c18 |
| tree | 8d997e4a1e9ea752315592908d3d247d7fcf33e5 |
| parent | b7df3dfca0b6368587ce1c0322111c4df49ff3e8 |
| signature | Signed by PGP key B5690EEEBB952194 |
4 files changed, 18 insertions(+), 5 deletions(-)
apps/desktop/src/clientPersistence.ts+15-2| ... | @@ -1,8 +1,13 @@ | ... | @@ -1,8 +1,13 @@ |
| 1 | import * as FS from "node:fs"; | 1 | import * as FS from "node:fs"; |
| 2 | import * as Path from "node:path"; | 2 | import * as Path from "node:path"; |
| 3 | 3 | ||
| 4 | import type { ClientSettings, PersistedSavedEnvironmentRecord } from "@t3tools/contracts"; | 4 | import { |
| 5 | ClientSettingsSchema, | ||
| 6 | type ClientSettings, | ||
| 7 | type PersistedSavedEnvironmentRecord, | ||
| 8 | } from "@t3tools/contracts"; | ||
| 5 | import { Predicate } from "effect"; | 9 | import { Predicate } from "effect"; |
| 10 | import * as Schema from "effect/Schema"; | ||
| 6 | 11 | ||
| 7 | interface ClientSettingsDocument { | 12 | interface ClientSettingsDocument { |
| 8 | readonly settings: ClientSettings; | 13 | readonly settings: ClientSettings; |
| ... | @@ -83,7 +88,15 @@ function toPersistedSavedEnvironmentRecord( | ... | @@ -83,7 +88,15 @@ function toPersistedSavedEnvironmentRecord( |
| 83 | } | 88 | } |
| 84 | 89 | ||
| 85 | export function readClientSettings(settingsPath: string): ClientSettings | null { | 90 | export function readClientSettings(settingsPath: string): ClientSettings | null { |
| 86 | return readJsonFile<ClientSettingsDocument>(settingsPath)?.settings ?? null; | 91 | const raw = readJsonFile<ClientSettingsDocument>(settingsPath)?.settings; |
| 92 | if (!raw) { | ||
| 93 | return null; | ||
| 94 | } | ||
| 95 | try { | ||
| 96 | return Schema.decodeUnknownSync(ClientSettingsSchema)(raw); | ||
| 97 | } catch { | ||
| 98 | return null; | ||
| 99 | } | ||
| 87 | } | 100 | } |
| 88 | 101 | ||
| 89 | export function writeClientSettings(settingsPath: string, settings: ClientSettings): void { | 102 | export function writeClientSettings(settingsPath: string, settings: ClientSettings): void { |
apps/web/src/components/Sidebar.tsx+1-1| ... | @@ -1379,7 +1379,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec | ... | @@ -1379,7 +1379,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec |
| 1379 | const overrideKey = deriveProjectGroupingOverrideKey(member); | 1379 | const overrideKey = deriveProjectGroupingOverrideKey(member); |
| 1380 | setProjectGroupingTarget(member); | 1380 | setProjectGroupingTarget(member); |
| 1381 | setProjectGroupingSelection( | 1381 | setProjectGroupingSelection( |
| 1382 | projectGroupingSettings.sidebarProjectGroupingOverrides[overrideKey] ?? "inherit", | 1382 | projectGroupingSettings.sidebarProjectGroupingOverrides?.[overrideKey] ?? "inherit", |
| 1383 | ); | 1383 | ); |
| 1384 | }, | 1384 | }, |
| 1385 | [projectGroupingSettings.sidebarProjectGroupingOverrides], | 1385 | [projectGroupingSettings.sidebarProjectGroupingOverrides], |
apps/web/src/hooks/useSettings.ts+1-1| ... | @@ -64,7 +64,7 @@ async function hydrateClientSettings(): Promise<void> { | ... | @@ -64,7 +64,7 @@ async function hydrateClientSettings(): Promise<void> { |
| 64 | try { | 64 | try { |
| 65 | const persistedSettings = await ensureLocalApi().persistence.getClientSettings(); | 65 | const persistedSettings = await ensureLocalApi().persistence.getClientSettings(); |
| 66 | if (persistedSettings) { | 66 | if (persistedSettings) { |
| 67 | replaceClientSettingsSnapshot(persistedSettings); | 67 | replaceClientSettingsSnapshot({ ...DEFAULT_CLIENT_SETTINGS, ...persistedSettings }); |
| 68 | } | 68 | } |
| 69 | } catch (error) { | 69 | } catch (error) { |
| 70 | console.error(`${CLIENT_SETTINGS_PERSISTENCE_ERROR_SCOPE} hydrate failed`, error); | 70 | console.error(`${CLIENT_SETTINGS_PERSISTENCE_ERROR_SCOPE} hydrate failed`, error); |
apps/web/src/logicalProject.ts+1-1| ... | @@ -70,7 +70,7 @@ export function resolveProjectGroupingMode( | ... | @@ -70,7 +70,7 @@ export function resolveProjectGroupingMode( |
| 70 | settings: ProjectGroupingSettings, | 70 | settings: ProjectGroupingSettings, |
| 71 | ): SidebarProjectGroupingMode { | 71 | ): SidebarProjectGroupingMode { |
| 72 | return ( | 72 | return ( |
| 73 | settings.sidebarProjectGroupingOverrides[deriveProjectGroupingOverrideKey(project)] ?? | 73 | settings.sidebarProjectGroupingOverrides?.[deriveProjectGroupingOverrideKey(project)] ?? |
| 74 | settings.sidebarProjectGroupingMode | 74 | settings.sidebarProjectGroupingMode |
| 75 | ); | 75 | ); |
| 76 | } | 76 | } |