Skip to content

Commit

Permalink
Use random device id when initializing QuickConnect
Browse files Browse the repository at this point in the history
(cherry picked from commit 02b9fb6)
  • Loading branch information
nielsvanvelzen committed Sep 6, 2022
1 parent c1b103e commit 4e82f10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/src/main/java/org/jellyfin/androidtv/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ val appModule = module {
single<NotificationsRepository> { NotificationsRepositoryImpl(get(), get()) }

viewModel { StartupViewModel(get(), get(), get(), get()) }
viewModel { UserLoginViewModel(get(), get(), get()) }
viewModel { UserLoginViewModel(get(), get(), get(), get(defaultDeviceInfo)) }
viewModel { ServerAddViewModel(get()) }
viewModel { NextUpViewModel(get(), get(), get(), get()) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ import org.jellyfin.androidtv.auth.model.UnknownQuickConnectState
import org.jellyfin.androidtv.auth.model.User
import org.jellyfin.androidtv.auth.repository.AuthenticationRepository
import org.jellyfin.androidtv.auth.repository.ServerRepository
import org.jellyfin.androidtv.util.sdk.forUser
import org.jellyfin.sdk.Jellyfin
import org.jellyfin.sdk.api.client.exception.ApiClientException
import org.jellyfin.sdk.api.client.extensions.quickConnectApi
import org.jellyfin.sdk.model.DeviceInfo
import timber.log.Timber
import java.util.UUID
import kotlin.time.Duration.Companion.seconds
Expand All @@ -33,6 +35,7 @@ class UserLoginViewModel(
jellyfin: Jellyfin,
private val serverRepository: ServerRepository,
private val authenticationRepository: AuthenticationRepository,
private val defaultDeviceInfo: DeviceInfo,
) : ViewModel() {
private val _loginState = MutableStateFlow<LoginState?>(null)
val loginState = _loginState.asStateFlow()
Expand Down Expand Up @@ -74,6 +77,7 @@ class UserLoginViewModel(
_quickConnectState.emit(UnknownQuickConnectState)
quickConnectSecret = null
quickConnectApi.baseUrl = server.address
quickConnectApi.deviceInfo = defaultDeviceInfo.forUser(UUID.randomUUID())

try {
val response by quickConnectApi.quickConnectApi.initiate()
Expand Down

0 comments on commit 4e82f10

Please sign in to comment.