@@ -25,8 +25,7 @@ export class SettingsService {
2525
2626 this . timer = new RefreshTimer ( {
2727 callback : async ( ) => {
28- await this . fetchSettings ( callback )
29- return true
28+ return await this . fetchSettings ( callback )
3029 } ,
3130 successInterval : 30000 ,
3231 initialBackoffMs : 1000 ,
@@ -42,10 +41,6 @@ export class SettingsService {
4241 this . removeSettings ( )
4342 }
4443
45- this . authService . on ( "attempting-session" , ( ) => {
46- this . timer . start ( )
47- } )
48-
4944 this . authService . on ( "active-session" , ( ) => {
5045 this . timer . start ( )
5146 } )
@@ -55,16 +50,16 @@ export class SettingsService {
5550 this . removeSettings ( )
5651 } )
5752
58- if ( this . authService . hasOrIsAcquiringActiveSession ( ) ) {
53+ if ( this . authService . hasActiveSession ( ) ) {
5954 this . timer . start ( )
6055 }
6156 }
6257
63- private async fetchSettings ( callback : ( ) => void ) : Promise < void > {
58+ private async fetchSettings ( callback : ( ) => void ) : Promise < boolean > {
6459 const token = this . authService . getSessionToken ( )
6560
6661 if ( ! token ) {
67- return
62+ return false
6863 }
6964
7065 try {
@@ -76,15 +71,15 @@ export class SettingsService {
7671
7772 if ( ! response . ok ) {
7873 console . error ( `Failed to fetch organization settings: ${ response . status } ${ response . statusText } ` )
79- return
74+ return false
8075 }
8176
8277 const data = await response . json ( )
8378 const result = organizationSettingsSchema . safeParse ( data )
8479
8580 if ( ! result . success ) {
8681 console . error ( "Invalid organization settings format:" , result . error )
87- return
82+ return false
8883 }
8984
9085 const newSettings = result . data
@@ -94,8 +89,11 @@ export class SettingsService {
9489 await this . cacheSettings ( )
9590 callback ( )
9691 }
92+
93+ return true
9794 } catch ( error ) {
9895 console . error ( "Error fetching organization settings:" , error )
96+ return false
9997 }
10098 }
10199
0 commit comments