refactor: Use hooks with refetched record for app config

This commit is contained in:
Faruk AYDIN
2024-10-24 16:46:08 +02:00
parent e0e313b8d1
commit 997e729535

View File

@@ -55,15 +55,21 @@ class AppConfig extends Base {
}
async computeConnectionAllowedProperty() {
const appAuthClients = await this.$relatedQuery('appAuthClients');
const refetchedRecord = await AppConfig.query().findOne({ key: this.key });
if (!refetchedRecord) return;
const appAuthClients = await refetchedRecord.$relatedQuery(
'appAuthClients'
);
const hasSomeActiveAppAuthClients =
appAuthClients?.some((appAuthClient) => appAuthClient.active) || false;
const conditions = [
hasSomeActiveAppAuthClients,
this.shared,
!this.disabled,
refetchedRecord.shared,
!refetchedRecord.disabled,
];
const connectionAllowed = conditions.every(Boolean);