Skip to content

Commit

Permalink
[PM-13764] - Update Collection Settings (#12734)
Browse files Browse the repository at this point in the history
* Updating org when collection settings change.
  • Loading branch information
jrmccannon authored Jan 9, 2025
1 parent 20c8eda commit 3550a90
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
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 @@ -231,6 +231,20 @@ export class AppComponent implements OnDestroy, OnInit {
}
break;
}
case "syncOrganizationCollectionSettingChanged": {
const { organizationId, limitCollectionCreation, limitCollectionDeletion } = message;
const organizations = await firstValueFrom(this.organizationService.organizations$);
const organization = organizations.find((org) => org.id === organizationId);

if (organization) {
await this.organizationService.upsert({
...organization,
limitCollectionCreation: limitCollectionCreation,
limitCollectionDeletion: limitCollectionDeletion,
});
}
break;
}
default:
break;
}
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 @@ -23,4 +23,5 @@ export enum NotificationType {

SyncOrganizations = 17,
SyncOrganizationStatusChanged = 18,
SyncOrganizationCollectionSettingChanged = 19,
}
17 changes: 17 additions & 0 deletions libs/common/src/models/response/notification.response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export class NotificationResponse extends BaseResponse {
case NotificationType.SyncOrganizationStatusChanged:
this.payload = new OrganizationStatusPushNotification(payload);
break;
case NotificationType.SyncOrganizationCollectionSettingChanged:
this.payload = new OrganizationCollectionSettingChangedPushNotification(payload);
break;
default:
break;
}
Expand Down Expand Up @@ -126,3 +129,17 @@ export class OrganizationStatusPushNotification extends BaseResponse {
this.enabled = this.getResponseProperty("Enabled");
}
}

export class OrganizationCollectionSettingChangedPushNotification extends BaseResponse {
organizationId: string;
limitCollectionCreation: boolean;
limitCollectionDeletion: boolean;

constructor(response: any) {
super(response);

this.organizationId = this.getResponseProperty("OrganizationId");
this.limitCollectionCreation = this.getResponseProperty("LimitCollectionCreation");
this.limitCollectionDeletion = this.getResponseProperty("LimitCollectionDeletion");
}
}
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 @@ -227,6 +227,11 @@ export class NotificationsService implements NotificationsServiceAbstraction {
await this.syncService.fullSync(true);
}
break;
case NotificationType.SyncOrganizationCollectionSettingChanged:
if (isAuthenticated) {
await this.syncService.fullSync(true);
}
break;
default:
break;
}
Expand Down

0 comments on commit 3550a90

Please sign in to comment.