From 80b57cf957a2a310a6f17af0c0057bb4e916a55b Mon Sep 17 00:00:00 2001 From: Antoine Moreaux Date: Thu, 19 Dec 2024 15:30:42 +0100 Subject: [PATCH] fix(domain-manager): prioritize non-seed workspaces in selection Updated workspace selection logic to prioritize non-seed workspaces. Returns a seed workspace only if no non-seed workspaces are available to improve filtering consistency and avoid unintended behavior. --- .../domain-manager/service/domain-manager.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/twenty-server/src/engine/core-modules/domain-manager/service/domain-manager.service.ts b/packages/twenty-server/src/engine/core-modules/domain-manager/service/domain-manager.service.ts index 0b0536b5fa..66d8bc28a1 100644 --- a/packages/twenty-server/src/engine/core-modules/domain-manager/service/domain-manager.service.ts +++ b/packages/twenty-server/src/engine/core-modules/domain-manager/service/domain-manager.service.ts @@ -145,7 +145,7 @@ export class DomainManagerService { if (!this.environmentService.get('IS_MULTIWORKSPACE_ENABLED')) { const workspaces = await this.workspaceRepository.find({ order: { - createdAt: 'DESC', + createdAt: 'ASC', }, relations: ['workspaceSSOIdentityProviders'], }); @@ -164,7 +164,7 @@ export class DomainManagerService { ), ); - return nonSeedWorkspace ?? workspaces[workspaces.length - 1]; + return nonSeedWorkspace ?? workspaces[0]; } throw new Error(