Minor bug fixes

This commit is contained in:
Kgothatso Ngako
2026-07-27 00:52:22 +02:00
parent 57652b98e1
commit 5e92e7f613
6 changed files with 25 additions and 11 deletions

View File

@@ -330,6 +330,7 @@ abstract class NostrDao(
}
nostrEvent.toProfile()?.let { profile ->
logger.d("Profile: $profile")
database.profileDao().upsert(profile)
}

View File

@@ -111,8 +111,11 @@ class DatabaseNostrRepository(
override suspend fun createNewProfile(
publicKey: HexKey,
name: String?,
biography: String?
biography: String?,
onCompletion: suspend () -> Unit
) {
logger.d("createNewProfile: $publicKey")
val profileEventTemplate = MetadataEvent.createNew(
name = name,
about = biography,
@@ -202,6 +205,8 @@ class DatabaseNostrRepository(
)
saveUnsignedNostrEvents(unsignedNostrEvents)
onCompletion.invoke()
}
override suspend fun signInToProfile(
@@ -356,7 +361,6 @@ class DatabaseNostrRepository(
override suspend fun saveUnsignedNostrEvents(unsignedNostrEvents: List<UnsignedNostrEvent>) {
logger.d("saveUnsignedNostrEvents: $unsignedNostrEvents")
delay(2_100)
database.unsignedNostrEventDao().insert(
unsignedNostrEvents

View File

@@ -45,7 +45,8 @@ interface NostrRepository {
suspend fun createNewProfile(
publicKey: HexKey,
name: String?,
biography: String?
biography: String?,
onCompletion: suspend () -> Unit
)
suspend fun signInToProfile(
@@ -190,7 +191,8 @@ interface NostrRepository {
override suspend fun createNewProfile(
publicKey: HexKey,
name: String?,
biography: String?
biography: String?,
onCompletion: suspend () -> Unit
) {
TODO("")
}

View File

@@ -24,7 +24,9 @@ import fr.acinq.phoenix.utils.MnemonicLanguage
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.time.Duration.Companion.seconds
class CreateProfileViewModel(
val initialCreateProfileUIState: CreateProfileUIState,
@@ -106,15 +108,19 @@ class CreateProfileViewModel(
val pubkey = localKeyManager.nostrPublicKey()
logger.d("Pubkey: $pubkey" )
nostrRepository.createNewProfile(
pubkey,
name = createProfileFormState.nameField.textFieldState.text.toString(),
biography = createProfileFormState.biographyField.textFieldState.text.toString()
)
biography = createProfileFormState.biographyField.textFieldState.text.toString(),
onCompletion = {
logger.d("Created: $pubkey" )
marmotRepository.publishMarmotKeyPackageBundle(
publicKey = pubkey,
nsecPassword = localKeyManager.nsecPassword()
marmotRepository.publishMarmotKeyPackageBundle(
publicKey = pubkey,
nsecPassword = localKeyManager.nsecPassword()
)
}
)
}
}

View File

@@ -20,6 +20,7 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.launch
import press.mantra.compose.database.model.NostrEvent
import kotlin.time.Instant
class NotaryViewModel(
@@ -99,7 +100,7 @@ class NotaryViewModel(
nostrRepository.publishNostrEvent(
unsignedNostrEvent,
_root_ide_package_.press.mantra.compose.database.model.NostrEvent(
NostrEvent(
id = event.id,
pubKey = event.pubKey,
kind = event.kind,

View File

@@ -53,7 +53,7 @@ class ShareProfileViewModel(
fun rebroadcastProfile(localNostrEvent: LocalNostrEvent) {
viewModelScope.launch(Dispatchers.IO) {
// Rebroadcast
// Rebroadcast localNostrEvent and relays
nostrRepository.rescheduleBroadcastNostrEventRequests(
Relays.eventFinderRelaySet.map {
BroadcastNostrEventRequest(