refactor: Use hooks with refetched record for app config
This commit is contained in:
@@ -55,15 +55,21 @@ class AppConfig extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async computeConnectionAllowedProperty() {
|
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 =
|
const hasSomeActiveAppAuthClients =
|
||||||
appAuthClients?.some((appAuthClient) => appAuthClient.active) || false;
|
appAuthClients?.some((appAuthClient) => appAuthClient.active) || false;
|
||||||
|
|
||||||
const conditions = [
|
const conditions = [
|
||||||
hasSomeActiveAppAuthClients,
|
hasSomeActiveAppAuthClients,
|
||||||
this.shared,
|
refetchedRecord.shared,
|
||||||
!this.disabled,
|
!refetchedRecord.disabled,
|
||||||
];
|
];
|
||||||
|
|
||||||
const connectionAllowed = conditions.every(Boolean);
|
const connectionAllowed = conditions.every(Boolean);
|
||||||
|
Reference in New Issue
Block a user