Merge pull request #3553 from Bnyro/master

Fix duplicating downloads
This commit is contained in:
Bnyro 2023-04-14 10:58:21 +02:00 committed by GitHub
commit 2cafe23c5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 16 deletions

View File

@ -23,10 +23,10 @@ import com.github.libretube.helpers.DownloadHelper
import com.github.libretube.helpers.PreferenceHelper import com.github.libretube.helpers.PreferenceHelper
import com.github.libretube.util.TextUtils import com.github.libretube.util.TextUtils
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import java.io.IOException
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import java.io.IOException
import retrofit2.HttpException import retrofit2.HttpException
class DownloadDialog( class DownloadDialog(

View File

@ -74,9 +74,10 @@ class DownloadsFragment : Fragment() {
val dbDownloads = runBlocking(Dispatchers.IO) { val dbDownloads = runBlocking(Dispatchers.IO) {
Database.downloadDao().getAll() Database.downloadDao().getAll()
} }.takeIf { it.isNotEmpty() } ?: return
downloads.clear()
downloads.addAll(dbDownloads) downloads.addAll(dbDownloads)
if (downloads.isEmpty()) return
binding.downloadsEmpty.visibility = View.GONE binding.downloadsEmpty.visibility = View.GONE
binding.downloads.visibility = View.VISIBLE binding.downloads.visibility = View.VISIBLE