Skip to content

Commit

Permalink
chore: Inject userAgent if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
sirambd committed Dec 26, 2024
1 parent b7e884e commit ccd7d80
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ import androidx.compose.runtime.snapshots.SnapshotStateMap
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.infomaniak.core2.DownloadManagerUtils
import com.infomaniak.core2.buildUserAgent
import com.infomaniak.multiplatform_swisstransfer.SharedApiUrlCreator
import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.TransferUi
import com.infomaniak.multiplatform_swisstransfer.common.models.TransferDirection
import com.infomaniak.multiplatform_swisstransfer.managers.TransferManager
import com.infomaniak.sentry.SentryLog
import com.infomaniak.swisstransfer.BuildConfig
import com.infomaniak.swisstransfer.di.UserAgent
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.*
Expand All @@ -40,6 +39,7 @@ import javax.inject.Inject
class TransferDetailsViewModel @Inject constructor(
private val transferManager: TransferManager,
private val sharedApiUrlCreator: SharedApiUrlCreator,
@UserAgent private val userAgent: String,
) : ViewModel() {

private val _transferUuidFlow = MutableSharedFlow<String>(1)
Expand Down Expand Up @@ -75,11 +75,6 @@ class TransferDetailsViewModel @Inject constructor(
fun startDownloadingAllFiles(transfer: TransferUi) {
viewModelScope.launch {
val url = sharedApiUrlCreator.downloadFilesUrl(transfer.uuid) ?: return@launch
val userAgent = buildUserAgent(
appId = BuildConfig.APPLICATION_ID,
appVersionCode = BuildConfig.VERSION_CODE,
appVersionName = BuildConfig.VERSION_NAME,
)

when (transfer.files.size) {
1 -> {
Expand Down

0 comments on commit ccd7d80

Please sign in to comment.