codeuino / social-platform-donut-frontend

This is an Open Source social Platform where people can interact with Open Source expertise around the globe and work on different projects
207 stars 220 forks source link

[BUG] UI not updated on post Deletion #633

Open ksraj123 opened 4 years ago

ksraj123 commented 4 years ago

Describe the bug The UI does not update when a post is deleted. Request to delete the post to backend works as expected.

Steps to Reproduce Step 1: Create a post Step 2: Hit the API through postman to fetch the list of all posts, the post we created in step 1 would be in this list Step 3: Delete the post though frontend Step 4: Hit the API through postman to fetch the list of all posts, the post we created in step 1 would NOT be in the list but it's still visible on the frontend.

Expected behavior The UI should update on the successful deletion of the post.

Screenshots Peek 2020-09-30 05-07

Desktop:

Additional context Hacktoberfest

trinadhmoganti commented 4 years ago

@ksraj123 and @AuraOfDivinity, I'd like to fix this issue. Could you please assign it to me?

lazycipher commented 4 years ago

@trinadhmoganti I don't think anyone else is working on this issue! So, Maybe go ahead with solving this. But before that may I know how are you planning to solve this?

megabyte98 commented 4 years ago

I would like to fix this bug . Can you please assign this issue to me?

trinadhmoganti commented 4 years ago

@trinadhmoganti I don't think anyone else is working on this issue! So, Maybe go ahead with solving this. But before that may I know how are you planning to solve this?

To me, it looksooks like it's an issue with state. I'm thinking that updating the frontend state after delete success api call should solve this issue.

lazycipher commented 4 years ago

@trinadhmoganti I don't think anyone else is working on this issue! So, Maybe go ahead with solving this. But before that may I know how are you planning to solve this?

To me, it looksooks like it's an issue with state. I'm thinking that updating the frontend state after delete success api call should solve this issue.

I see that in postActions, we're dispatching getAllPost() which is trying to get all posts from the API. I think instead of trying to get all posts again, what we may do is use .filter() to remove the deleted post from the state on success.

@AuraOfDivinity, @ksraj123, @Rupeshiya, what do you say?

Souvikns commented 4 years ago

@lazycipher I would like to work on this issue, I can see that here there is a GET_ALL_POSTS that I guess is fetching the data from the API, If we create another action that takes the id of posts and returns a new list except for the one post, with the matching _id as you said earlier with using filter.

lazycipher commented 4 years ago

Fixed in some PR! Please close @vaibhavdaren.