File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,24 +64,28 @@ const DashboardPreferences = z.object({
6464
6565export type DashboardPreferences = z . infer < typeof DashboardPreferences > ;
6666
67- const DEFAULT_PREFERENCES : DashboardPreferences = {
68- version : "1" ,
69- projects : { } ,
70- } ;
67+ /* A function, not a shared constant: the writers mutate through these objects,
68+ so each caller needs its own container */
69+ function defaultPreferences ( ) : DashboardPreferences {
70+ return {
71+ version : "1" ,
72+ projects : { } ,
73+ } ;
74+ }
7175
7276/** Parses the stored JSON, falling back to defaults on missing or invalid data. */
7377export function parseDashboardPreferences (
7478 data ?: any | null ,
7579 onError ?: ( error : z . ZodError ) => void
7680) : DashboardPreferences {
7781 if ( ! data ) {
78- return { ... DEFAULT_PREFERENCES } ;
82+ return defaultPreferences ( ) ;
7983 }
8084
8185 const result = DashboardPreferences . safeParse ( data ) ;
8286 if ( ! result . success ) {
8387 onError ?.( result . error ) ;
84- return { ... DEFAULT_PREFERENCES } ;
88+ return defaultPreferences ( ) ;
8589 }
8690
8791 return result . data ;
You can’t perform that action at this time.
0 commit comments