From 708c93ed831efd839051846709d88573fa5c985f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Sun, 6 Jul 2025 21:59:18 +0200 Subject: [PATCH] Fix --- packages/example/src/todo/Todo.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/example/src/todo/Todo.tsx b/packages/example/src/todo/Todo.tsx index bb34ac4..7767e32 100644 --- a/packages/example/src/todo/Todo.tsx +++ b/packages/example/src/todo/Todo.tsx @@ -58,11 +58,9 @@ export const Todo = Component.make(function* Todo(props: TodoProps) { onClick={() => Runtime.runSync(runtime)( SubscriptionRef.updateEffect(state.ref, todos => Effect.gen(function*() { if (props.index <= 0) return yield* Option.none() - const toSwapIndex = props.index - 1 - const toSwap = yield* Chunk.get(todos, toSwapIndex) return todos.pipe( - Chunk.replace(props.index, toSwap), - Chunk.replace(toSwapIndex, yield* ref), + Chunk.replace(props.index, yield* Chunk.get(todos, props.index - 1)), + Chunk.replace(props.index - 1, yield* ref), ) })) )} @@ -75,11 +73,9 @@ export const Todo = Component.make(function* Todo(props: TodoProps) { onClick={() => Runtime.runSync(runtime)( SubscriptionRef.updateEffect(state.ref, todos => Effect.gen(function*() { if (props.index >= size - 1) return yield* Option.none() - const toSwapIndex = props.index + 1 - const toSwap = yield* Chunk.get(todos, toSwapIndex) return todos.pipe( - Chunk.replace(props.index, toSwap), - Chunk.replace(toSwapIndex, yield* ref), + Chunk.replace(props.index, yield* Chunk.get(todos, props.index + 1)), + Chunk.replace(props.index + 1, yield* ref), ) })) )}