social-platform-donut-frontend icon indicating copy to clipboard operation
social-platform-donut-frontend copied to clipboard

[BUG] UI not updated on post Deletion

Open ksraj123 opened this issue 5 years ago • 7 comments

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:

  • OS: Ubuntu 20.04
  • Browser: Chrome
  • Version: 85

Additional context Hacktoberfest

ksraj123 avatar Sep 29 '20 23:09 ksraj123

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

trinadhmoganti avatar Sep 30 '20 04:09 trinadhmoganti

@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?

lazycipher avatar Oct 01 '20 11:10 lazycipher

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

megabyte98 avatar Oct 01 '20 12:10 megabyte98

@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.

trinadhmoganti avatar Oct 01 '20 13:10 trinadhmoganti

@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?

lazycipher avatar Oct 01 '20 14:10 lazycipher

@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.

Souvikns avatar Oct 04 '20 10:10 Souvikns

Fixed in some PR! Please close @vaibhavdaren.

lazycipher avatar Nov 30 '20 02:11 lazycipher