Skip to content

Commit

Permalink
Fix getDevice method signature
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Oct 26, 2023
1 parent cf39670 commit 00312d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ForegroundNotificationManager(
jobTracker.newBackgroundJob("notificationLoggedInJob") {
daemon
?.deviceStateUpdates
?.onStart { emit(daemon.getAndEmitDeviceState()) }
?.onStart { daemon.getAndEmitDeviceState()?.let { emit(it) } }
?.collect { deviceState -> loggedIn = deviceState is DeviceState.LoggedIn }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ class MullvadDaemon(
}
}

fun getAndEmitDeviceState(): DeviceState {
return getDevice(daemonInterfaceAddress).also { deviceState ->
fun getAndEmitDeviceState(): DeviceState? {
return getDevice(daemonInterfaceAddress)?.also { deviceState ->
_deviceStateUpdates.tryEmit(deviceState)
}
}
Expand Down Expand Up @@ -257,7 +257,9 @@ class MullvadDaemon(
accountToken: String?
): List<Device>?

private external fun getDevice(daemonInterfaceAddress: Long): DeviceState
// TODO: Remove this method when reviewing Daemon communication, it can be null which was not
// considered when this method was initially added.
private external fun getDevice(daemonInterfaceAddress: Long): DeviceState?

private external fun updateDevice(daemonInterfaceAddress: Long)

Expand Down

0 comments on commit 00312d3

Please sign in to comment.