feat: track updating selections with row IDs#831
feat: track updating selections with row IDs#831zamderax wants to merge 6 commits intotuist:mainfrom
Conversation
|
I updated the mise task headers from to to silence the deprecation warning in newer mise versions. Happy to revert if you’d rather keep the old header. |
fortmarek
left a comment
There was a problem hiding this comment.
Thanks a lot for the PR and sorry for taking longer to review this. I wonder if we can take the opportunity to rethink the API a bit to make supporting this use case more elegant 👀
| /// An interactive table that keeps updating as new data arrives. | ||
| struct UpdatingSelectableTable<Updates: AsyncSequence> where Updates.Element == TableData { | ||
| /// @unchecked Sendable: rendering and state access are serialized by internal queues. | ||
| struct UpdatingSelectableTable<Updates: AsyncSequence>: @unchecked Sendable where Updates.Element == TableData { |
There was a problem hiding this comment.
I'd love us to figure out a way not to add the @unchecked Sendable – is there a way to implement the behavior with structured concurrency constructs?
| public let rows: [TableRow] | ||
|
|
||
| /// Optional row identifiers aligned to `rows` (used for selection tracking in updating tables) | ||
| public let rowIDs: [AnyHashable]? |
There was a problem hiding this comment.
instead of a rowIDs property, I'd consider making the TableRow conform to Identifiable and basically make it more like a SwiftUI List. I'd love the API to be more like:
TableData(
data,
columns: columns,
rows: [
TerminalRow { element in
element.title
},
TerminalRow { element in
element.subtitle
}
])And if data would be Identifiable, the selection could work based on the ID (without having an explicit rowIDs property). It would require some type gymnastics to make this non-breaking, but I think it should be possible.
Wdyt? cc @pepicrft
There was a problem hiding this comment.
Agree. The ergonomy of the API that you suggest feels right.
|
I made some changes to actors and removed the unchecked Sendables. I also ran swiftformat and linting |
72a12f6 to
7c5cf8c
Compare
|
@pepicrft any chance we can get a review on this? It's quite the frustrating UX right now. |
|
Thanks a lot for the PR @zamderax, and apologies for the delayed response @Joannis. This PR slipped through the cracks. @zamderax some comments:
|
| updates: updates, | ||
| pageSize: 8 | ||
| ) | ||
| let selectedWiFiID = table.rows[selectedIndex].id.unwrap(UUID.self) |
There was a problem hiding this comment.
Should this be?
| let selectedWiFiID = table.rows[selectedIndex].id.unwrap(UUID.self) | |
| let selectedWiFiID = latest.rows[selectedIndex].id.unwrap(UUID.self) |
rowIDswithTableRowidentifiers (TableRowID) for stable selection trackingTableData(data, columns:rows:)withTerminalRowbuilders for Identifiable data@unchecked Sendable)