Loading app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt +2 −3 Original line number Diff line number Diff line Loading @@ -103,11 +103,10 @@ class HomeViewModel @Inject constructor( private fun postHomeResult(homeResult: ResultSupreme<List<Home>>) { if (shouldUpdateResult(homeResult)) { homeScreenData.value = homeResult currentHomes = homeResult.data?.map { home -> home.copy() } currentHomes = homeResult.data return } // homeResult is success, but not change is found homeScreenData.value = ResultSupreme.Error("No change is found in homepage") } Loading @@ -122,7 +121,7 @@ class HomeViewModel @Inject constructor( ) private fun compareWithNewData(newHomes: List<Home>): Boolean { currentHomes!!.forEach { currentHomes?.forEach { val fusedHome = newHomes[currentHomes!!.indexOf(it)] if (!it.title.contentEquals(fusedHome.title) || !it.id.contentEquals(fusedHome.id) Loading app/src/test/java/foundation/e/apps/home/HomeViewModelTest.kt +6 −6 Original line number Diff line number Diff line Loading @@ -48,9 +48,9 @@ class HomeViewModelTest { val newAppList = mutableListOf(Application("123"), Application("124")) val oldHomeData = listOf(Home("Top Free Apps", oldAppList), Home("Top Free Games", oldAppList)) listOf(Home("Top Free Apps", oldAppList, id = "123"), Home("Top Free Games", oldAppList, id = "124")) var newHomeData = listOf(Home("Top Free Apps", newAppList), Home("Top Free Games", newAppList)) listOf(Home("Top Free Apps", newAppList, id = "123"), Home("Top Free Games", newAppList, id = "124")) homeViewModel.currentHomes = oldHomeData Loading @@ -64,9 +64,9 @@ class HomeViewModelTest { val newAppList = mutableListOf(Application("123"), Application("124"), Application("125")) val oldHomeData = listOf(Home("Top Free Apps", oldAppList), Home("Top Free Games", oldAppList)) listOf(Home("Top Free Apps", oldAppList, id = "123"), Home("Top Free Games", oldAppList, id = "124")) var newHomeData = listOf(Home("Top Free Apps", newAppList), Home("Top Free Games", newAppList)) listOf(Home("Top Free Apps", newAppList, id = "123"), Home("Top Free Games", newAppList, id = "124")) homeViewModel.currentHomes = oldHomeData Loading @@ -80,9 +80,9 @@ class HomeViewModelTest { val newAppList = mutableListOf(Application("123"), Application("124", status = Status.INSTALLED), Application("125")) val oldHomeData = listOf(Home("Top Free Apps", oldAppList), Home("Top Free Games", oldAppList)) listOf(Home("Top Free Apps", oldAppList, id = "123"), Home("Top Free Games", oldAppList, id = "124")) var newHomeData = listOf(Home("Top Free Apps", newAppList), Home("Top Free Games", newAppList)) listOf(Home("Top Free Apps", newAppList, id = "123"), Home("Top Free Games", newAppList, id = "124")) homeViewModel.currentHomes = oldHomeData Loading Loading
app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt +2 −3 Original line number Diff line number Diff line Loading @@ -103,11 +103,10 @@ class HomeViewModel @Inject constructor( private fun postHomeResult(homeResult: ResultSupreme<List<Home>>) { if (shouldUpdateResult(homeResult)) { homeScreenData.value = homeResult currentHomes = homeResult.data?.map { home -> home.copy() } currentHomes = homeResult.data return } // homeResult is success, but not change is found homeScreenData.value = ResultSupreme.Error("No change is found in homepage") } Loading @@ -122,7 +121,7 @@ class HomeViewModel @Inject constructor( ) private fun compareWithNewData(newHomes: List<Home>): Boolean { currentHomes!!.forEach { currentHomes?.forEach { val fusedHome = newHomes[currentHomes!!.indexOf(it)] if (!it.title.contentEquals(fusedHome.title) || !it.id.contentEquals(fusedHome.id) Loading
app/src/test/java/foundation/e/apps/home/HomeViewModelTest.kt +6 −6 Original line number Diff line number Diff line Loading @@ -48,9 +48,9 @@ class HomeViewModelTest { val newAppList = mutableListOf(Application("123"), Application("124")) val oldHomeData = listOf(Home("Top Free Apps", oldAppList), Home("Top Free Games", oldAppList)) listOf(Home("Top Free Apps", oldAppList, id = "123"), Home("Top Free Games", oldAppList, id = "124")) var newHomeData = listOf(Home("Top Free Apps", newAppList), Home("Top Free Games", newAppList)) listOf(Home("Top Free Apps", newAppList, id = "123"), Home("Top Free Games", newAppList, id = "124")) homeViewModel.currentHomes = oldHomeData Loading @@ -64,9 +64,9 @@ class HomeViewModelTest { val newAppList = mutableListOf(Application("123"), Application("124"), Application("125")) val oldHomeData = listOf(Home("Top Free Apps", oldAppList), Home("Top Free Games", oldAppList)) listOf(Home("Top Free Apps", oldAppList, id = "123"), Home("Top Free Games", oldAppList, id = "124")) var newHomeData = listOf(Home("Top Free Apps", newAppList), Home("Top Free Games", newAppList)) listOf(Home("Top Free Apps", newAppList, id = "123"), Home("Top Free Games", newAppList, id = "124")) homeViewModel.currentHomes = oldHomeData Loading @@ -80,9 +80,9 @@ class HomeViewModelTest { val newAppList = mutableListOf(Application("123"), Application("124", status = Status.INSTALLED), Application("125")) val oldHomeData = listOf(Home("Top Free Apps", oldAppList), Home("Top Free Games", oldAppList)) listOf(Home("Top Free Apps", oldAppList, id = "123"), Home("Top Free Games", oldAppList, id = "124")) var newHomeData = listOf(Home("Top Free Apps", newAppList), Home("Top Free Games", newAppList)) listOf(Home("Top Free Apps", newAppList, id = "123"), Home("Top Free Games", newAppList, id = "124")) homeViewModel.currentHomes = oldHomeData Loading