deleteEntity method
Delete optimistically and restore graph/list membership on failure.
Implementation
Future<void> deleteEntity() async {
final graph = ref.read(entityGraphProvider);
final snapshot = graph.removeEntityOptimistically(type, id);
state = state.copyWith(isSaving: true, clearError: true);
try {
final transport = ref.read(entityTransportRegistryProvider).get<T>(type);
await transport.delete(id);
state = const EditBuffer(original: {});
} on Object catch (error) {
final typed = toEntityGraphError(error);
graph.restoreRemovedEntity(snapshot);
state = state.copyWith(isSaving: false, error: typed);
throw typed;
}
}