TBD54566975 / incubating-web5-labs

Apache License 2.0
25 stars 16 forks source link

Delete in TODO app always deletes the first item #54

Closed ALRubinger closed 1 year ago

ALRubinger commented 1 year ago

This is not on main, but on upstream branch issue-47/update-sdk:

I deleted 4:

image
bobbilee19 commented 1 year ago

@kirahsapong weird, what's this issue I wonder

chris-tbd commented 1 year ago

I just looked over the delete code, did you step through and verify it's getting the right todoRecordId passed in and deleting the right todo? https://github.com/TBD54566975/incubating-web5-labs/blob/main/todo-app/src/App.vue

ALRubinger commented 1 year ago

@chris-tbd:

Note: this is on upstream branch issue-47/update-sdk, not main.

If todo.dWebMessage.recordId is the right way to get the ID, I think so? Here's the relevant code where it loops over TODOs:

<div v-if="(todos.length > 0)" class="border-gray-200 border-t border-x mt-16 rounded-lg shadow-md sm:max-w-xl sm:mx-auto sm:w-full">
          <div v-for="todo in todos" :key="todo.dWebMessage.recordId" class="border-b border-gray-200 flex items-center p-4">
            <div @click="toggleTodoComplete(todo.dWebMessage.recordId)" class="cursor-pointer">
              <CheckCircleIcon class="h-8 text-gray-200 w-8" :class="{ 'text-green-500': todo.data.completed }" />
            </div>
            <div class="font-light ml-3 text-gray-500 text-xl">
              {{ todo.data.description }}
            </div>
            <!-- Delete Todo goes here later -->
            <div class="ml-auto">
              <div @click="deleteTodo(todo.dWebMessage.recordId)" class="cursor-pointer">
                <TrashIcon class="h-8 text-gray-200 w-8" :class="'text-red-500'" />
              </div>
            </div>
          </div>
        </div>
kirahsapong commented 1 year ago

This commit should resolve it! The todo item wasn't able to get the recordId properly

ALRubinger commented 1 year ago

Rebased as c929cc3063cabb960dbc254ddb8268abd1aef2c9; works great!