|
|
@ -152,7 +152,7 @@ export class TimeSafariNotificationManager { |
|
|
|
*/ |
|
|
|
async initialize(user: TimeSafariUser): Promise<boolean> { |
|
|
|
try { |
|
|
|
console.log('Initializing TimeSafariNotificationManager for:', user.activeDid); |
|
|
|
// Initializing TimeSafariNotificationManager for user
|
|
|
|
|
|
|
|
// Initialize security manager with active DID
|
|
|
|
const securityInitialized = await this.securityManager.initialize(user.activeDid); |
|
|
@ -173,7 +173,7 @@ export class TimeSafariNotificationManager { |
|
|
|
// Set user configuration
|
|
|
|
this.user = user; |
|
|
|
|
|
|
|
console.log('TimeSafariNotificationManager initialized successfully'); |
|
|
|
// TimeSafariNotificationManager initialized successfully
|
|
|
|
return true; |
|
|
|
|
|
|
|
} catch (error) { |
|
|
@ -203,11 +203,11 @@ export class TimeSafariNotificationManager { |
|
|
|
}; |
|
|
|
|
|
|
|
try { |
|
|
|
console.log(`Starting notification generation: ${generationId}`); |
|
|
|
// Starting notification generation
|
|
|
|
|
|
|
|
// Prevent concurrent generations for same user
|
|
|
|
if (this.activeGeneration.has(this.user.activeDid)) { |
|
|
|
console.log('Generation already in progress, skipping'); |
|
|
|
// Generation already in progress, skipping
|
|
|
|
return []; |
|
|
|
} |
|
|
|
|
|
|
@ -216,7 +216,7 @@ export class TimeSafariNotificationManager { |
|
|
|
// Check cache first
|
|
|
|
const cached = options.forceFetch ? null : this.getCachedNotifications(); |
|
|
|
if (cached) { |
|
|
|
console.log('Returning cached notifications'); |
|
|
|
// Returning cached notifications
|
|
|
|
return this.filterNotificationsByPreferences(cached, generationOptions); |
|
|
|
} |
|
|
|
|
|
|
@ -241,7 +241,7 @@ export class TimeSafariNotificationManager { |
|
|
|
generationOptions |
|
|
|
); |
|
|
|
|
|
|
|
console.log(`Generated ${filteredNotifications.length} notifications out of ${allNotifications.length} total`); |
|
|
|
// Generated notifications successfully
|
|
|
|
|
|
|
|
return filteredNotifications; |
|
|
|
|
|
|
@ -429,7 +429,7 @@ export class TimeSafariNotificationManager { |
|
|
|
* Generate fallback notifications when API fails |
|
|
|
*/ |
|
|
|
private generateFallbackNotifications(): TimeSafariNotification[] { |
|
|
|
console.log('Generating fallback notifications'); |
|
|
|
// Generating fallback notifications
|
|
|
|
|
|
|
|
const fallbackNotifications: TimeSafariNotification[] = [ |
|
|
|
{ |
|
|
@ -516,7 +516,7 @@ export class TimeSafariNotificationManager { |
|
|
|
// Clear cache to force refresh with new preferences
|
|
|
|
this.clearCache(); |
|
|
|
|
|
|
|
console.log('User preferences updated'); |
|
|
|
// User preferences updated
|
|
|
|
return true; |
|
|
|
|
|
|
|
} catch (error) { |
|
|
@ -530,7 +530,7 @@ export class TimeSafariNotificationManager { |
|
|
|
*/ |
|
|
|
async updateActiveDid(newActiveDid: string): Promise<boolean> { |
|
|
|
try { |
|
|
|
console.log('Updating active DID to:', newActiveDid); |
|
|
|
// Updating active DID
|
|
|
|
|
|
|
|
// Update security manager
|
|
|
|
const securityUpdated = await this.securityManager.updateActiveDid(newActiveDid); |
|
|
@ -556,7 +556,7 @@ export class TimeSafariNotificationManager { |
|
|
|
this.user.activeDid = newActiveDid; |
|
|
|
} |
|
|
|
|
|
|
|
console.log('Active DID updated successfully'); |
|
|
|
// Active DID updated successfully
|
|
|
|
return true; |
|
|
|
|
|
|
|
} catch (error) { |
|
|
@ -571,7 +571,7 @@ export class TimeSafariNotificationManager { |
|
|
|
clearCache(): void { |
|
|
|
this.cache.clear(); |
|
|
|
this.apiClient.clearCache(); |
|
|
|
console.log('TimeSafari notification cache cleared'); |
|
|
|
// TimeSafari notification cache cleared
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -610,7 +610,7 @@ export class TimeSafariNotificationManager { |
|
|
|
await this.securityManager.reset(); |
|
|
|
this.clearCache(); |
|
|
|
this.user = undefined; |
|
|
|
console.log('TimeSafariNotificationManager reset completed'); |
|
|
|
// TimeSafariNotificationManager reset completed
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
console.error('Error resetting TimeSafariNotificationManager:', error); |
|
|
|