@@ -15,8 +15,9 @@ const fallbackMetaStrings: MetaStrings = {
1515 knowledgeLabels : [ 'Low' , 'Medium' , 'High' ] ,
1616} ;
1717
18- const LOCALSTORAGE_KEY : string = 'meta' ;
19- const PROGRESS_DEFINITIONS_KEY : string = 'progressDefinitions' ;
18+ const STORAGE_TEAMS_KEY : string = 'meta.teams' ;
19+ const STORAGE_GROUPS_KEY : string = 'meta.teamGroups' ;
20+ const STORAGE_PROGRESS_DEFINITIONS_KEY : string = 'meta.progressDefinitions' ;
2021
2122export class MetaStore {
2223 private yamlService : YamlService = new YamlService ( ) ;
@@ -71,16 +72,16 @@ export class MetaStore {
7172
7273 public saveProgressDefinition ( definitions : ProgressDefinitions ) : void {
7374 this . progressDefinition = definitions ;
74- localStorage . setItem ( PROGRESS_DEFINITIONS_KEY , JSON . stringify ( definitions ) ) ;
75+ localStorage . setItem ( STORAGE_PROGRESS_DEFINITIONS_KEY , JSON . stringify ( definitions ) ) ;
7576 }
7677
7778 public resetProgressDefinition ( ) : void {
7879 this . progressDefinition = { ...this . defaultProgressDefinition } ;
79- localStorage . removeItem ( PROGRESS_DEFINITIONS_KEY ) ;
80+ localStorage . removeItem ( STORAGE_PROGRESS_DEFINITIONS_KEY ) ;
8081 }
8182
8283 private loadStoredProgressDefinition ( ) : void {
83- const stored = localStorage . getItem ( PROGRESS_DEFINITIONS_KEY ) ;
84+ const stored = localStorage . getItem ( STORAGE_PROGRESS_DEFINITIONS_KEY ) ;
8485 if ( stored ) {
8586 try {
8687 this . progressDefinition = JSON . parse ( stored ) ;
@@ -96,35 +97,42 @@ export class MetaStore {
9697 public updateTeamsAndGroups ( teams : TeamNames , teamGroups : TeamGroups ) : void {
9798 this . teams = teams ;
9899 this . teamGroups = teamGroups ;
99- this . saveToLocalStorage ( ) ;
100+ this . saveTeamsAndGroups ( ) ;
100101 }
101102
102103 public asStorableYamlString ( ) : string {
103104 return this . yamlService . stringify ( { teams : this . teams , teamGroups : this . teamGroups } ) ;
104105 }
105106
106- public saveToLocalStorage ( ) {
107- let yamlStr : string = this . asStorableYamlString ( ) ;
108- localStorage . setItem ( LOCALSTORAGE_KEY , yamlStr ) ;
107+ public saveTeamsAndGroups ( ) {
108+ let yamlStr : string = this . yamlService . stringify ( this . teams ) ;
109+ localStorage . setItem ( STORAGE_TEAMS_KEY , yamlStr ) ;
110+ yamlStr = this . yamlService . stringify ( this . teamGroups ) ;
111+ localStorage . setItem ( STORAGE_GROUPS_KEY , yamlStr ) ;
109112 this . hasLocalStorage = true ;
110113 }
111114
112- public deleteLocalStorage ( ) {
113- localStorage . removeItem ( LOCALSTORAGE_KEY ) ;
115+ public deleteTeamsAndGroups ( ) {
116+ localStorage . removeItem ( STORAGE_TEAMS_KEY ) ;
117+ localStorage . removeItem ( STORAGE_GROUPS_KEY ) ;
114118 this . hasLocalStorage = false ;
115119 }
116120
117- public loadStoredMeta ( ) : void {
118- let storedMeta : string | null = localStorage . getItem ( LOCALSTORAGE_KEY ) ;
119- if ( storedMeta ) {
120- try {
121- let metaData = this . yamlService . parse ( storedMeta ) ;
122- this . addMeta ( metaData ) ;
123- this . hasLocalStorage = true ;
124- console . log ( 'Loaded stored meta from localStorage' ) ;
125- } catch ( error ) {
126- console . error ( 'Failed to load stored meta from localStorage:' , error ) ;
127- }
121+ public loadTeamsAndGroups ( ) : void {
122+ let storedTeams : string | null = localStorage . getItem ( STORAGE_TEAMS_KEY ) ;
123+ let storedGroups : string | null = localStorage . getItem ( STORAGE_GROUPS_KEY ) ;
124+ try {
125+ let metaTeams : TeamNames | null = null ;
126+ let metaGroups : TeamGroups | null = null ;
127+
128+ if ( storedTeams ) metaTeams = this . yamlService . parse ( storedTeams ) ;
129+ if ( storedGroups ) metaGroups = this . yamlService . parse ( storedGroups ) ;
130+
131+ this . addMeta ( { teams : metaTeams , teamGroups : metaGroups } ) ;
132+ this . hasLocalStorage = true ;
133+ console . log ( 'Loaded stored meta from localStorage' ) ;
134+ } catch ( error ) {
135+ console . error ( 'Failed to load stored meta from localStorage:' , error ) ;
128136 }
129137 }
130138
0 commit comments