mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 06:13:38 +00:00
fix(notifications): [PM-25424] Fix unnecessary quick reconnect
* Ensure we don't reconnect on feature flag emissions of the same value * Harden notification processing * Do error for both
This commit is contained in:
@@ -172,6 +172,7 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer
|
|||||||
|
|
||||||
private hasAccessToken$(userId: UserId) {
|
private hasAccessToken$(userId: UserId) {
|
||||||
return this.configService.getFeatureFlag$(FeatureFlag.PushNotificationsWhenLocked).pipe(
|
return this.configService.getFeatureFlag$(FeatureFlag.PushNotificationsWhenLocked).pipe(
|
||||||
|
distinctUntilChanged(),
|
||||||
switchMap((featureFlagEnabled) => {
|
switchMap((featureFlagEnabled) => {
|
||||||
if (featureFlagEnabled) {
|
if (featureFlagEnabled) {
|
||||||
return this.authService.authStatusFor$(userId).pipe(
|
return this.authService.authStatusFor$(userId).pipe(
|
||||||
@@ -305,11 +306,23 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer
|
|||||||
startListening() {
|
startListening() {
|
||||||
return this.notifications$
|
return this.notifications$
|
||||||
.pipe(
|
.pipe(
|
||||||
mergeMap(async ([notification, userId]) => this.processNotification(notification, userId)),
|
mergeMap(async ([notification, userId]) => {
|
||||||
|
try {
|
||||||
|
await this.processNotification(notification, userId);
|
||||||
|
} catch (err: unknown) {
|
||||||
|
this.logService.error(
|
||||||
|
`Problem processing notification of type ${notification.type}`,
|
||||||
|
err,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
error: (e: unknown) =>
|
error: (err: unknown) =>
|
||||||
this.logService.warning("Error in server notifications$ observable", e),
|
this.logService.error(
|
||||||
|
"Fatal error in server notifications$ observable, notifications won't be recieved anymore.",
|
||||||
|
err,
|
||||||
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user