Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

organization status changed code changes #12249

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 @@ -241,6 +241,20 @@
// 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);

Check warning on line 247 in apps/web/src/app/app.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/app.component.ts#L245-L247

Added lines #L245 - L247 were not covered by tests

if (organization) {
const updatedOrganization = {

Check warning on line 250 in apps/web/src/app/app.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/app.component.ts#L250

Added line #L250 was not covered by tests
...organization,
enabled: enabled,
};
await this.organizationService.upsert(updatedOrganization);

Check warning on line 254 in apps/web/src/app/app.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/app.component.ts#L254

Added line #L254 was not covered by tests
}
break;

Check warning on line 256 in apps/web/src/app/app.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/app.component.ts#L256

Added line #L256 was not covered by tests
}
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,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 @@
case NotificationType.AuthRequestResponse:
this.payload = new AuthRequestPushNotification(payload);
break;
case NotificationType.SyncOrganizationStatusChanged:
this.payload = new OrganizationStatusPushNotification(payload);
break;

Check warning on line 47 in libs/common/src/models/response/notification.response.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/models/response/notification.response.ts#L46-L47

Added lines #L46 - L47 were not covered by tests
default:
break;
}
Expand Down Expand Up @@ -112,3 +115,14 @@
this.userId = this.getResponseProperty("UserId");
}
}

export class OrganizationStatusPushNotification extends BaseResponse {

Check warning on line 119 in libs/common/src/models/response/notification.response.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/models/response/notification.response.ts#L119

Added line #L119 was not covered by tests
organizationId: string;
enabled: boolean;

constructor(response: any) {
super(response);
this.organizationId = this.getResponseProperty("OrganizationId");
this.enabled = this.getResponseProperty("Enabled");

Check warning on line 126 in libs/common/src/models/response/notification.response.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/models/response/notification.response.ts#L124-L126

Added lines #L124 - L126 were not covered by tests
}
}
7 changes: 7 additions & 0 deletions libs/common/src/services/notifications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@
});
}
break;
case NotificationType.SyncOrganizationStatusChanged:
if (isAuthenticated) {
await this.syncService.fullSync(true);

Check warning on line 221 in libs/common/src/services/notifications.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/services/notifications.service.ts#L221

Added line #L221 was not covered by tests
// Stop so a reconnect can be made
await this.signalrConnection.stop();

Check warning on line 223 in libs/common/src/services/notifications.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/services/notifications.service.ts#L223

Added line #L223 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think this is needed.

Suggested change
// Stop so a reconnect can be made
await this.signalrConnection.stop();

}
break;

Check warning on line 225 in libs/common/src/services/notifications.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/services/notifications.service.ts#L225

Added line #L225 was not covered by tests
default:
break;
}
Expand Down