1.3.4 User-Scoped Storage Pattern: Add StorageService integration across modules for improved data management

- Introduced STORAGE_SERVICE token in the DI container for consistent service registration.
- Updated BaseService to include storageService as a dependency, ensuring proper initialization and error handling.
- Refactored ChatService to utilize storageService for managing unread messages and peers, replacing localStorage usage.
- Enhanced MarketStore to save and load orders using storageService, improving data persistence and user experience.
- Registered storageService in the base module, ensuring it is initialized and disposed of correctly.

This integration streamlines data handling across the application, promoting better maintainability and consistency.
This commit is contained in:
padreug 2025-09-06 12:08:39 +02:00
parent 3abdd2d7d9
commit 3cf10b1db4
6 changed files with 285 additions and 103 deletions

View file

@ -45,6 +45,7 @@ export abstract class BaseService {
protected relayHub: any = null
protected authService: any = null
protected visibilityService: any = null
protected storageService: any = null
// Service state
public readonly isInitialized: Ref<boolean> = ref(false)
@ -134,6 +135,7 @@ export abstract class BaseService {
this.relayHub = tryInjectService(SERVICE_TOKENS.RELAY_HUB)
this.authService = tryInjectService(SERVICE_TOKENS.AUTH_SERVICE)
this.visibilityService = tryInjectService(SERVICE_TOKENS.VISIBILITY_SERVICE)
this.storageService = tryInjectService(SERVICE_TOKENS.STORAGE_SERVICE)
// Check if all required dependencies are available
const missingDeps = this.getMissingDependencies()
@ -181,6 +183,9 @@ export abstract class BaseService {
if (deps.includes('VisibilityService') && !this.visibilityService) {
missing.push('VisibilityService')
}
if (deps.includes('StorageService') && !this.storageService) {
missing.push('StorageService')
}
return missing
}
@ -264,6 +269,8 @@ export abstract class BaseService {
this.isInitialized.value = false
this.relayHub = null
this.authService = null
this.visibilityService = null
this.storageService = null
console.log(`♻️ ${this.metadata.name} disposed`)