Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f894013a authored by Hasib Prince's avatar Hasib Prince
Browse files

Merge branch '5110_crash_appdetail_progress' into epic_176-all-refactorAndGplay

parents 074f51fc 134013db
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -163,12 +163,12 @@ class ApplicationViewModel @Inject constructor(

    suspend fun calculateProgress(progress: DownloadProgress): Pair<Long, Long> {
        fusedApp.value?.let { app ->
            val appDownload = fusedManagerRepository.getDownloadList().single { it.id.contentEquals(app._id) }
            val appDownload = fusedManagerRepository.getDownloadList().singleOrNull { it.id.contentEquals(app._id) }
            val downloadingMap = progress.totalSizeBytes.filter { item ->
                appDownload.downloadIdMap.keys.contains(item.key)
                appDownload?.downloadIdMap?.keys?.contains(item.key) == true
            }
            val totalSizeBytes = downloadingMap.values.sum()
            val downloadedSoFar = progress.bytesDownloadedSoFar.filter { item -> appDownload.downloadIdMap.keys.contains(item.key) }.values.sum()
            val downloadedSoFar = progress.bytesDownloadedSoFar.filter { item -> appDownload?.downloadIdMap?.keys?.contains(item.key) == true }.values.sum()

            return Pair(totalSizeBytes, downloadedSoFar)
        }