@ -63,10 +63,10 @@ const componentCaches = new WeakMap<any, Map<string, CacheEntry<any>>>();
* Cache configuration constants
* Cache configuration constants
* /
* /
const CACHE_DEFAULTS = {
const CACHE_DEFAULTS = {
settings : 30000 , // 30 seconds TTL for settings
settings : 30000 , // 30 seconds TTL for settings
contacts : 60000 , // 60 seconds TTL for contacts
contacts : 60000 , // 60 seconds TTL for contacts
accounts : 30000 , // 30 seconds TTL for accounts
accounts : 30000 , // 30 seconds TTL for accounts
default : 15000 , // 15 seconds default TTL
default : 15000 , // 15 seconds default TTL
} as const ;
} as const ;
/ * *
/ * *
@ -434,13 +434,15 @@ export const PlatformServiceMixin = {
* @returns Cached mapped array of all contacts
* @returns Cached mapped array of all contacts
* /
* /
async $contacts ( ) : Promise < any [ ] > {
async $contacts ( ) : Promise < any [ ] > {
const cacheKey = 'contacts_all' ;
const cacheKey = "contacts_all" ;
const cached = this . _getCached < any [ ] > ( cacheKey ) ;
const cached = this . _getCached < any [ ] > ( cacheKey ) ;
if ( cached ) {
if ( cached ) {
return cached ;
return cached ;
}
}
const contacts = await this . $query ( "SELECT * FROM contacts ORDER BY name" ) ;
const contacts = await this . $query (
"SELECT * FROM contacts ORDER BY name" ,
) ;
return this . _setCached ( cacheKey , contacts , CACHE_DEFAULTS . contacts ) ;
return this . _setCached ( cacheKey , contacts , CACHE_DEFAULTS . contacts ) ;
} ,
} ,
@ -458,7 +460,11 @@ export const PlatformServiceMixin = {
}
}
const settings = await this . $getSettings ( MASTER_SETTINGS_KEY , defaults ) ;
const settings = await this . $getSettings ( MASTER_SETTINGS_KEY , defaults ) ;
return ( this as any ) . _setCached ( cacheKey , settings , CACHE_DEFAULTS . settings ) ;
return ( this as any ) . _setCached (
cacheKey ,
settings ,
CACHE_DEFAULTS . settings ,
) ;
} ,
} ,
/ * *
/ * *
@ -469,7 +475,7 @@ export const PlatformServiceMixin = {
* /
* /
async $accountSettings ( did? : string , defaults : any = { } ) : Promise < any > {
async $accountSettings ( did? : string , defaults : any = { } ) : Promise < any > {
const currentDid = did || ( this as any ) . activeDid ;
const currentDid = did || ( this as any ) . activeDid ;
const cacheKey = ` account_settings_ ${ currentDid || 'default' } ` ;
const cacheKey = ` account_settings_ ${ currentDid || "default" } ` ;
const cached = this . _getCached < any > ( cacheKey ) ;
const cached = this . _getCached < any > ( cacheKey ) ;
if ( cached ) {
if ( cached ) {
@ -480,7 +486,11 @@ export const PlatformServiceMixin = {
if ( ! currentDid ) {
if ( ! currentDid ) {
settings = await this . $settings ( defaults ) ;
settings = await this . $settings ( defaults ) ;
} else {
} else {
settings = await this . $getMergedSettings ( MASTER_SETTINGS_KEY , currentDid , defaults ) ;
settings = await this . $getMergedSettings (
MASTER_SETTINGS_KEY ,
currentDid ,
defaults ,
) ;
}
}
return this . _setCached ( cacheKey , settings , CACHE_DEFAULTS . settings ) ;
return this . _setCached ( cacheKey , settings , CACHE_DEFAULTS . settings ) ;
@ -559,7 +569,7 @@ export const PlatformServiceMixin = {
* Forces reload of contacts from database
* Forces reload of contacts from database
* /
* /
async $refreshContacts ( ) : Promise < any [ ] > {
async $refreshContacts ( ) : Promise < any [ ] > {
this . _invalidateCache ( 'contacts_all' ) ;
this . _invalidateCache ( "contacts_all" ) ;
return await this . $contacts ( ) ;
return await this . $contacts ( ) ;
} ,
} ,