Skip to content

Commit

Permalink
refactor(annotation): getLeftSibling() and getRightSibling() now uses…
Browse files Browse the repository at this point in the history
… index as parameter

BREAKING CHANGE: check your calls of getLeftSibling() and
getRightSibling() and change parameters to index values.
  • Loading branch information
julianpoemp committed Jan 11, 2024
1 parent 4e2c5cd commit 828b984
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 4 additions & 4 deletions libs/annotation/src/lib/annotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,12 +717,12 @@ export class OctraAnnotationLevel<T extends OLevel<S>, S extends OItem> {
return this;
}

getLeftSibling(item: S) {
return this.level.getLeftSibling(item);
getLeftSibling(index: number) {
return this.level.getLeftSibling(index);
}

getRightSibling(item: S) {
return this.level.getRightSibling(item);
getRightSibling(index: number) {
return this.level.getRightSibling(index);
}
}

Expand Down
6 changes: 2 additions & 4 deletions libs/annotation/src/lib/annotjson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,11 @@ export class OLevel<T extends OItem> implements ILevel {
);
}

getLeftSibling(item: OItem): T | undefined {
const index = this.items.findIndex((a) => a.id === item.id);
getLeftSibling(index: number): T | undefined {
return index > 0 ? this.items[index - 1] : undefined;
}

getRightSibling(item: OItem): T | undefined {
const index = this.items.findIndex((a) => a.id === item.id);
getRightSibling(index: number): T | undefined {
return index > -1 && index < this.items.length - 1 ? this.items[index + 1] : undefined;
}
}
Expand Down

0 comments on commit 828b984

Please sign in to comment.