Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force getting relay transport key on launch and restore #717

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ interface RepositoryDashboard {

suspend fun didCancelRestore()

fun getAndSaveTransportKey()
fun getAndSaveTransportKey(forceGet: Boolean = false)
fun saveTransportKey()
fun getOrCreateHMacKey(forceGet: Boolean = false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6892,10 +6892,12 @@ abstract class SphinxRepository(
}
}

override fun getAndSaveTransportKey() {
override fun getAndSaveTransportKey(forceGet: Boolean) {
applicationScope.launch(io) {
relayDataHandler.retrieveRelayTransportKey()?.let {
return@launch
if (!forceGet) {
relayDataHandler.retrieveRelayTransportKey()?.let {
return@launch
}
}
saveTransportKey()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ internal class DashboardViewModel @Inject constructor(
}

private fun getRelayKeys() {
repositoryDashboard.getAndSaveTransportKey()
repositoryDashboard.getAndSaveTransportKey(forceGet = true)
repositoryDashboard.getOrCreateHMacKey(forceGet = true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ internal class OnBoardConnectingViewModel @Inject constructor(

is Response.Success -> {
transportKey = RsaPublicKey(loadResponse.value.transport_key.toCharArray())

relayDataHandler.persistRelayTransportKey(transportKey)
}
}
}
Expand Down
Loading