-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete a single list from shopping lists #51
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great, could see the change on the home page and Firebase!
Something I noticed out of curiosity of what happens to lists that were shared, is that It wouldn't remove from other user's sharedList
. I'm assuming because in this case we want to look through the current user's list and wanting to delete it for that user. I think this can definitely be a future issue, just wanted to put it out there!
if (window.confirm(`Are you sure you want to delete ${list.name}?`)) { | ||
await deleteList(userEmail, list.path); | ||
const updatedData = data.filter( | ||
(eachList) => eachList.path !== list.path, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool idea using filter to find the list path!
Works great! I noticed a console.log message -- that can be removed before merged. Otherwise, nice job! -AR |
Visit the preview URL for this PR (updated for commit d172510): https://tcl-76-smart-shopping-list--pr51-eb-delete-list-from-a6w8hq53.web.app (expires Wed, 09 Oct 2024 05:19:50 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 512b1a88be8ae05fd3e727b99332819df760271d |
Description
Users are able to delete an entire list from their collection from the home page by the click of a Delete button.
The selected list will be deleted from two locations in the database:
From the document associated with the user's email, specifically in the sharedLists array.
From the document representing the shopping lists for that user.
I learned that understanding the Firebase data structure would be crucial for completing this ticket. Initially, I could only delete items from the users' shopping lists, but I wasn't able to remove them from the sharedLists array associated with the users. While the UI updated successfully and one part of the database changed, refreshing the page caused all the deleted shopping lists to reappear. This happened because, upon refresh, the app fetches data from the sharedLists array using useShoppingList. By reviewing the parent component code and tracing where the data was coming from, I was finally able to debug the issue and complete this ticket.
Related Issue
closes #47
Acceptance Criteria
Type of Changes
Use one or more labels to help your team understand the nature of the change(s) you’re proposing. E.g.,
bug fix
orenhancement
are common ones.feature
enhancement
Updates
After
Testing Steps / QA Criteria