Replies: 1 comment 1 reply
-
Hi @jestspoko, good catch! Here's one potential solution: case let .delete(indexSet):
let filteredTodos = state.filteredTodos
for index in indexSet {
state.todos.remove(id: filteredTodos[index].id)
}
return .none It's a little extra work because we have to compute the filtered todos again, but it's not so bad. A full solution probably would beef up the data structure holding todos so that it could more efficiently access views into the data, but that may not be super appropriate for such a simple demo that's just meant to convey some basic TCA ideas. We'll think about it a bit more to see how we want to address this. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I think there might be an issue in Todos example. When trying to interact with row in "completed" section (deleting item in this case), item with different index is being deleted. This is probably because "all" section is powered by "todos" array while "completed" view is using
filteredTodos
which is just a slice of originaltodos
database.This issue also could appear if we decide to filter out completed todos right after completion. This would also lead to a issue with
todos
indexes.Possible solution would be to have separate arrays with filtered todos (similar to: #1627 ) but it will require a lot of moving/removing which just feels wrong.
Any ideas how to solve this puzzle?
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2022-11-25.at.23.38.08.mp4
Beta Was this translation helpful? Give feedback.
All reactions