Skip to content

Buggy default reload method #134

@gerchicov-bp

Description

@gerchicov-bp

Checklist

Expected Behavior

Table reloads

Current Behavior

Table reloading failed with exception:
Thread 1: "attempt to insert row 0 into section 1, but there are only 0 rows in section 1 after the update"

Steps to Reproduce

Code example:

class Item { ... }
class Group {
var isExpanded = true
var items: [Item] = ...
func visibleItems() -> [Item] { isExpanded ? self.items : [] }
...
}
var groups: [Group] = {
  let group = Group()
  group.items = Item()
  return [group]
}()

Where groups represent sections and items represent rows. Just expand-collapse a section (isExpanded changed), calc the diff and try to reload the table with these data using any method in this library.

Detailed Description (Include Screenshots)

The problem is in your reload method which attempts to reload data step-by-step. In my case it means on expand it attempts to add one Item and insert it into the table immediately ignoring isExpanded value which should be updated in the next run loop.

Reproducible Demo Project

I don't have but it seems the task is trivial to reproduce.

Environments

Doesn't matter because there is an error inside this library algo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions