Skip to content
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

RecyclerView Not Updating Edits and Deletes till Swiperefresh #26

Open
Morons opened this issue Jul 23, 2021 · 6 comments
Open

RecyclerView Not Updating Edits and Deletes till Swiperefresh #26

Morons opened this issue Jul 23, 2021 · 6 comments

Comments

@Morons
Copy link
Contributor

Morons commented Jul 23, 2021

Can you please test Open-Api where you delete a blog, It looks like SHOULD_REFRESH is not refreshing the blogList!, I think you have missed BlogEvent.Refresh, I may be wrong
UpdateBlog Reflect Nicely on ViewBlog But does not filter through to ListBlog

@Zlagi
Copy link

Zlagi commented Jul 25, 2021

remove this bloc from BlogViewModel :
////
init {
onTriggerEvent(BlogEvents.GetOrderAndFilter)
}
////
and add this to the onViewCreated() in BlogFragment :
////
onTriggerEvent(BlogEvents.GetOrderAndFilter)

@Morons
Copy link
Contributor Author

Morons commented Jul 26, 2021

You mean
in BlogFragment
viewModel.onTriggerEvent(BlogEvents.GetOrderAndFilter)

The problem with this it is forced not by trigger!

The problem having this is it generate extra Network traffic - Even if Change was NOT made!
AND Loding keeps Spinnig!!

I'd think Mitch will have a different solution, but it works!
Thanx

@Morons
Copy link
Contributor Author

Morons commented Jul 26, 2021

@Zlagi You put me on the correct Track However

Add in BlogFragment onViewCreated

// If an update occurred from UpdateBlogFragment, refresh the Blog findNavController().currentBackStackEntry?.savedStateHandle?.getLiveData<Boolean>(SHOULD_REFRESH) ?.observe(viewLifecycleOwner) { shouldRefresh -> shouldRefresh?.run { viewModel.onTriggerEvent(BlogEvents.GetOrderAndFilter) findNavController().currentBackStackEntry?.savedStateHandle?.set(SHOULD_REFRESH, null) } }

Remove from ViewBlogFragment the line that re-set the flag SHOULD_REFRESH so that it is still there for the BlogFragment

findNavController().currentBackStackEntry?.savedStateHandle?.set(SHOULD_REFRESH, null)

The BlogFragment will then Re-Set the flag! if needed and would cause NO extra traffic plus the isLoading is working correct!

Works as Intended!

@Morons Morons mentioned this issue Jul 27, 2021
@mitchtabian
Copy link
Owner

It's not as simple as you suggested. If you refresh in BlogFragment the list position is lost. We would need a use-case that only updates that specific blogpost in the list. Feel free to write it :)

@Morons
Copy link
Contributor Author

Morons commented Jul 28, 2021

Ok I guess you will sort that, I have mostly tested on the Top blog 👍

@Morons
Copy link
Contributor Author

Morons commented Sep 9, 2021

I had a thought
Maybe if you refresh the changed data to the Server and re-cache it before returning to the Recycler view you will get the changed record in there and keep your location, Replacing the need for SHOULD_REFRESH 100% all places! @mitchtabian
As us suggested!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants