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

fix: ensure one default layout in set as default #2575

Merged

Conversation

ainouzgali
Copy link
Contributor

What change does this PR introduce?

In update/create layout, because the db create/update of the new default happens before the SetDefaultLayoutUseCase, there are two at time. It is inconsistent which of them SetDefaultLayoutUseCase finds → so causes a state of two defaults at the same time.

Why was this change needed?

Other information (Screenshots)

@linear
Copy link

linear bot commented Jan 23, 2023

NV-1563 Set as default - does not ensure 1 default

In update/create layout, because the db create/update of the new default happens before the SetDefaultLayoutUseCase, there are two at time. It is inconsistent which of them SetDefaultLayoutUseCase finds → so causes a state of two defaults at the same time.

Copy link
Contributor

@p-fernandez p-fernandez left a comment

Choose a reason for hiding this comment

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

🌟
Well spotted

@@ -10,9 +10,13 @@ export class SetDefaultLayoutUseCase {
constructor(private layoutRepository: LayoutRepository) {}

async execute(command: SetDefaultLayoutCommand) {
const defaultLayoutId = await this.findDefaultLayoutId(command.environmentId, command.organizationId);
const defaultLayoutId = await this.findExistingDefaultLayoutId(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const defaultLayoutId = await this.findExistingDefaultLayoutId(
const existingDefaultLayoutId = await this.findExistingDefaultLayoutId(

…s-default-does-not-ensure-1-default

# Conflicts:
#	apps/api/src/app/layouts/usecases/set-default-layout/set-default-layout.use-case.ts
@ainouzgali ainouzgali merged commit e41e015 into feat-layouts Jan 23, 2023
@ainouzgali ainouzgali deleted the nv-1563-set-as-default-does-not-ensure-1-default branch January 23, 2023 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants