From e98edfeb9eb8db79587b74ab92f4bef0232c00c2 Mon Sep 17 00:00:00 2001 From: Hasib Prince Date: Tue, 14 Nov 2023 17:52:02 +0600 Subject: [PATCH] fixed: overriding currentHomes --- app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt index c7261da58..b4197164c 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt @@ -103,7 +103,10 @@ class HomeViewModel @Inject constructor( private fun postHomeResult(homeResult: ResultSupreme>) { if (shouldUpdateResult(homeResult)) { homeScreenData.value = homeResult - currentHomes = homeResult.data + // Here, homeResult.data is a mutableList which can be changed anytime. + // That's why we're setting copy of the list, so that currentHomes isn't changed, + // when homeresult.data is changed. + currentHomes = homeResult.data?.map { it.copy() } return } -- GitLab