Skip to content

Commit 81a08ab

Browse files
committed
[Feature] [Credentials] Remove dead code
1 parent 60a9720 commit 81a08ab

File tree

2 files changed

+3
-36
lines changed

2 files changed

+3
-36
lines changed

feature/credentials/src/main/kotlin/de/davis/keygo/feature/credentials/presentation/create/activity/CreatePasskeyActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ internal class CreatePasskeyActivity : FragmentActivity() {
115115
confirmButton = {
116116
Button(
117117
onClick = {
118-
viewModel.onItemSelected(event.itemId)
118+
viewModel.associatePasskeyAndFinish(event.itemId)
119119
confirmationEvent = null
120120
}
121121
) {
@@ -163,7 +163,7 @@ internal class CreatePasskeyActivity : FragmentActivity() {
163163
composable<CreateItem> {
164164
PasswordScreen(
165165
passwordCreated = {
166-
viewModel.onItemSelected(it)
166+
viewModel.associatePasskeyAndFinish(it)
167167
},
168168
navigateBack = { cancel("User cancelled passkey creation") }
169169
)

feature/credentials/src/main/kotlin/de/davis/keygo/feature/credentials/presentation/create/activity/CreatePasskeyViewModel.kt

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,14 @@ import de.davis.keygo.core.item.domain.alias.ItemId
88
import de.davis.keygo.core.item.domain.model.Passkey
99
import de.davis.keygo.core.item.domain.model.PasskeyUser
1010
import de.davis.keygo.core.item.domain.model.SecretData
11-
import de.davis.keygo.core.item.domain.model.lite.LiteItem
1211
import de.davis.keygo.core.item.domain.repository.PasskeyRepository
1312
import de.davis.keygo.core.item.domain.repository.PasswordRepository
1413
import de.davis.keygo.core.security.domain.model.CiphertextData
1514
import de.davis.keygo.core.util.getOrNull
1615
import de.davis.keygo.rust.passkey.PasskeyManager
1716
import de.davis.keygo.rust.passkey.model.KeyGoRegistrationResponse
18-
import kotlinx.coroutines.ExperimentalCoroutinesApi
1917
import kotlinx.coroutines.channels.Channel
20-
import kotlinx.coroutines.flow.Flow
21-
import kotlinx.coroutines.flow.MutableStateFlow
22-
import kotlinx.coroutines.flow.SharingStarted
23-
import kotlinx.coroutines.flow.first
24-
import kotlinx.coroutines.flow.flatMapLatest
25-
import kotlinx.coroutines.flow.flowOf
2618
import kotlinx.coroutines.flow.receiveAsFlow
27-
import kotlinx.coroutines.flow.stateIn
2819
import kotlinx.coroutines.launch
2920
import org.koin.core.annotation.KoinViewModel
3021

@@ -40,19 +31,6 @@ internal class CreatePasskeyViewModel(
4031
private val _event = Channel<CreatePasskeyEvent>()
4132
val event = _event.receiveAsFlow()
4233

43-
private val allItems = passwordRepository.observeLitePasswords()
44-
45-
private val submittedSearchQuery = MutableStateFlow("")
46-
47-
@OptIn(ExperimentalCoroutinesApi::class)
48-
private val itemSource = submittedSearchQuery.flatMapLatest(::queryToItems)
49-
50-
val listItemState = itemSource.stateIn(
51-
scope = viewModelScope,
52-
started = SharingStarted.WhileSubscribed(5_000),
53-
initialValue = emptyList()
54-
)
55-
5634
private var registrationResponse: KeyGoRegistrationResponse? = null
5735
private var key: CiphertextData? = null
5836

@@ -82,22 +60,12 @@ internal class CreatePasskeyViewModel(
8260
}
8361

8462

85-
private suspend fun queryToItems(query: String): Flow<List<LiteItem>> =
86-
if (query.isBlank()) allItems
87-
else flowOf(passwordRepository.searchPasswordItem(query))
88-
89-
fun onSearchSubmit(query: String) {
90-
submittedSearchQuery.value = query
91-
}
92-
93-
suspend fun searcher(query: String): List<LiteItem> = queryToItems(query).first()
94-
9563
fun passkeyEncrypted(key: CiphertextData) {
9664
this.key = key
9765
_event.trySend(CreatePasskeyEvent.ShowList)
9866
}
9967

100-
fun onItemSelected(itemId: ItemId) {
68+
fun associatePasskeyAndFinish(itemId: ItemId) {
10169
viewModelScope.launch {
10270
val registrationResponse =
10371
registrationResponse ?: return@launch abort("Response was null")
@@ -126,7 +94,6 @@ internal class CreatePasskeyViewModel(
12694
}
12795
}
12896

129-
// TODO: why onItemClicked and onItemSelected???
13097
fun onItemClicked(itemId: ItemId) {
13198
_event.trySend(
13299
CreatePasskeyEvent.OpenConfirmationDialog(

0 commit comments

Comments
 (0)