Skip to content

Commit

Permalink
Fix broken canCreateEntity logic
Browse files Browse the repository at this point in the history
If loading status is `Done`, then it is always OK to insert an entity.

Also rename to canInsertEntity as it is not creating an entity but
inserting one into the list.

Fixes #8277
  • Loading branch information
paw-hub committed Jan 15, 2025
1 parent 4adbb51 commit d52d657
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/common/misc/ListElementListModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class ListElementListModel<ElementType extends ListElement> {
// Wait for any pending loading
return this.listModel.waitLoad(() => {
if (operation === OperationType.CREATE) {
if (this.canCreateEntity(entity)) {
if (this.canInsertEntity(entity)) {
this.listModel.insertLoadedItem(entity)
}
} else if (operation === OperationType.UPDATE) {
Expand All @@ -54,9 +54,9 @@ export class ListElementListModel<ElementType extends ListElement> {
}
}

private canCreateEntity(entity: ElementType): boolean {
if (this.state.loadingStatus !== ListLoadingState.Done) {
return false
private canInsertEntity(entity: ElementType): boolean {
if (this.state.loadingStatus === ListLoadingState.Done) {
return true
}

// new element is in the loaded range or newer than the first element
Expand Down

0 comments on commit d52d657

Please sign in to comment.