Skip to content

Commit

Permalink
fix: typo on parent check (#811)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsenta authored Jan 17, 2022
1 parent bd6b53f commit b0544dc
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app/assets/javascripts/ui_models/app_state/tags_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,32 +199,33 @@ export class TagsState {

public async assignParent(
tagUuid: string,
parentUuid: string | undefined
futureParentUuid: string | undefined
): Promise<void> {
const tag = this.application.findItem(tagUuid) as SNTag;

const currentParent = this.application.getTagParent(tag);
const currentParentUuid = currentParent?.parentId;
const currentParentUuid = currentParent?.uuid;

if (currentParentUuid === parentUuid) {
if (currentParentUuid === futureParentUuid) {
return;
}

const parent =
parentUuid && (this.application.findItem(parentUuid) as SNTag);
const futureParent =
futureParentUuid &&
(this.application.findItem(futureParentUuid) as SNTag);

if (!parent) {
if (!futureParent) {
const futureSiblings = rootTags(this.application);
if (!isValidFutureSiblings(this.application, futureSiblings, tag)) {
return;
}
await this.application.unsetTagParent(tag);
} else {
const futureSiblings = this.application.getTagChildren(parent);
const futureSiblings = this.application.getTagChildren(futureParent);
if (!isValidFutureSiblings(this.application, futureSiblings, tag)) {
return;
}
await this.application.setTagParent(parent, tag);
await this.application.setTagParent(futureParent, tag);
}

await this.application.sync();
Expand Down

0 comments on commit b0544dc

Please sign in to comment.