Skip to content

Possible issue with NSTableView binding #653

Description

@killev

Working on collections/changesets I found a possible issue:

               case .next(let element):
                   let newCollection = element
                   if let collection = collection {
                       let diff = generateDiff(collection, newCollection)
                       observer.receive(OrderedCollectionChangeset(collection: newCollection, patch: [], diff: diff))
                   } else {
                       observer.receive(OrderedCollectionChangeset(collection: newCollection, patch: []))
                   }
                   collection = newCollection

Line:

observer.receive(OrderedCollectionChangeset(collection: newCollection, patch: [], diff: diff))

I think this is a mistake. You shouldn't pass patch option there.
Then this patch will be used here:

 open func apply(changeset: Changeset) {
        guard let tableView = tableView else { return }
        let patch = changeset.patch
        if patch.isEmpty {
            collection = clone(changeset.collection)
            tableView.reloadData()
        } else {
            tableView.beginUpdates()
            patch.forEach(apply)
            tableView.endUpdates()
        }
    }

And as far as it's empty it always reloadData.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions