Skip to content

Commit

Permalink
organization status changed code changes (#12249)
Browse files Browse the repository at this point in the history
* organization status changed code changes

* Remove the stop so a reconnect can be made
  • Loading branch information
cyprain-okeke authored Dec 18, 2024
1 parent 903b5c8 commit 12b698b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
14 changes: 14 additions & 0 deletions apps/web/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,20 @@ export class AppComponent implements OnDestroy, OnInit {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.router.navigate(["/remove-password"]);
break;
case "syncOrganizationStatusChanged": {
const { organizationId, enabled } = message;
const organizations = await firstValueFrom(this.organizationService.organizations$);
const organization = organizations.find((org) => org.id === organizationId);

if (organization) {
const updatedOrganization = {
...organization,
enabled: enabled,
};
await this.organizationService.upsert(updatedOrganization);
}
break;
}
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export class AdjustPaymentDialogComponent {
}
});
await response;
await new Promise((resolve) => setTimeout(resolve, 10000));
this.toastService.showToast({
variant: "success",
title: null,
Expand Down
1 change: 1 addition & 0 deletions libs/common/src/enums/notification-type.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export enum NotificationType {
AuthRequestResponse = 16,

SyncOrganizations = 17,
SyncOrganizationStatusChanged = 18,
}
14 changes: 14 additions & 0 deletions libs/common/src/models/response/notification.response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export class NotificationResponse extends BaseResponse {
case NotificationType.AuthRequestResponse:
this.payload = new AuthRequestPushNotification(payload);
break;
case NotificationType.SyncOrganizationStatusChanged:
this.payload = new OrganizationStatusPushNotification(payload);
break;
default:
break;
}
Expand Down Expand Up @@ -112,3 +115,14 @@ export class AuthRequestPushNotification extends BaseResponse {
this.userId = this.getResponseProperty("UserId");
}
}

export class OrganizationStatusPushNotification extends BaseResponse {
organizationId: string;
enabled: boolean;

constructor(response: any) {
super(response);
this.organizationId = this.getResponseProperty("OrganizationId");
this.enabled = this.getResponseProperty("Enabled");
}
}
5 changes: 5 additions & 0 deletions libs/common/src/services/notifications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ export class NotificationsService implements NotificationsServiceAbstraction {
});
}
break;
case NotificationType.SyncOrganizationStatusChanged:
if (isAuthenticated) {
await this.syncService.fullSync(true);
}
break;
default:
break;
}
Expand Down

0 comments on commit 12b698b

Please sign in to comment.