@@ -126,24 +126,36 @@ async function getCurrentProfileConfig() {
126126 logConfigurationRelatedStuff ( 'Retrieving current profile from storage' ) ;
127127 try {
128128 const result = await chrome . storage . sync . get ( [ 'currentProfile' ] ) ;
129- const currentProfile = result . currentProfile ;
129+ const profileName = result . currentProfile ;
130130
131- if ( currentProfile ) {
132- logConfigurationRelatedStuff ( `Current profile found: ${ currentProfile } ` ) ;
133- const profile = await loadProfileConfig ( currentProfile ) ;
131+ if ( profileName ) {
132+ logConfigurationRelatedStuff ( `Current profile found: ${ profileName } ` ) ;
133+ let profile = await loadProfileConfig ( profileName ) ;
134134 if ( profile ) {
135+ // Ensure the profile has a 'customButtons' property
136+ if ( ! profile . customButtons ) {
137+ profile . customButtons = [ ] ;
138+ logConfigurationRelatedStuff ( `Initialized missing 'customButtons' for profile: ${ profileName } ` ) ;
139+ }
135140 return profile ;
136141 }
137142 }
138143
139- logConfigurationRelatedStuff ( 'No current profile found. Creating default profile' ) ;
140- return await createDefaultProfile ( ) ;
144+ logConfigurationRelatedStuff ( 'No valid current profile found. Creating default profile' ) ;
145+ const defaultProfile = await createDefaultProfile ( ) ;
146+ // Ensure the default profile includes 'customButtons'
147+ if ( ! defaultProfile . customButtons ) {
148+ defaultProfile . customButtons = [ ] ;
149+ logConfigurationRelatedStuff ( "Initialized missing 'customButtons' for default profile" ) ;
150+ }
151+ return defaultProfile ;
141152 } catch ( error ) {
142153 handleStorageError ( error ) ;
143154 throw new Error ( 'Unable to retrieve current profile configuration.' ) ;
144155 }
145156}
146157
158+
147159// Function to list all available profiles
148160async function listProfiles ( ) {
149161 try {
0 commit comments