I forgot how these things work
This commit is contained in:
@@ -10,6 +10,7 @@ import androidx.room.Embedded
|
||||
import androidx.room.Relation
|
||||
import androidx.room.Transaction
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlin.time.Clock
|
||||
|
||||
@@ -25,7 +26,7 @@ abstract class NostrDao(
|
||||
relayURLs: List<String>
|
||||
) {
|
||||
logger.i("Publish Nostr Event: $nostrEvent ($relayURLs)")
|
||||
// TODO: Find or create profile with the pubKey... if not found submit a sync request...
|
||||
// Find or create profile with the pubKey... if not found TODO: submit a sync request...
|
||||
val profile = database.profileDao().getProfileByPublicKey(nostrEvent.pubKey)
|
||||
|
||||
if (profile == null) {
|
||||
@@ -48,7 +49,6 @@ abstract class NostrDao(
|
||||
// TODO: Sync to find and update profile
|
||||
}
|
||||
|
||||
|
||||
database.nostrEventDao().upsert(nostrEvent)
|
||||
|
||||
nostrEvent.toPost()?.let { post ->
|
||||
@@ -103,11 +103,7 @@ abstract class NostrDao(
|
||||
nostrEvent.toZap()?.let { zap ->
|
||||
database.zapDao().upsert(zap)
|
||||
}
|
||||
// Submit a broadcastRequest...
|
||||
if (nostrEvent.kind == 0) {
|
||||
// Look busy
|
||||
delay(2_500)
|
||||
}
|
||||
|
||||
relayURLs.forEach { relayURL ->
|
||||
database.broadcastNostrEventRequestDao().upsert(
|
||||
BroadcastNostrEventRequest(
|
||||
|
||||
@@ -78,6 +78,9 @@ data class NostrEvent(
|
||||
return result
|
||||
}
|
||||
|
||||
fun isProfileCreationEvent(): Boolean {
|
||||
return kind == MetadataEvent.KIND && unsignedNostrEventId != null
|
||||
}
|
||||
fun toPost(): Post? = try {
|
||||
if (kind == TextNoteEvent.KIND) {
|
||||
val textNote = EventFactory.create<TextNoteEvent>(
|
||||
|
||||
@@ -52,8 +52,13 @@ class DatabaseNostrRepository(
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
if (unsignedNostrEvent == null) {
|
||||
onError.invoke()
|
||||
} else if (unsignedNostrEvent.kind == 0 ) {
|
||||
// Look busy for the onboarding screen
|
||||
delay(3_500)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ fun UnannouncedProfileScreen(
|
||||
)
|
||||
|
||||
Text(
|
||||
text = "Aux will be broadcast to what you publish to relays so that it's distributed and decentralized.",
|
||||
text = "Aux will be broadcast what you publish to a distributed set of relays so that it's decentralized.",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
|
||||
@@ -73,6 +73,7 @@ class NavigationViewModel(
|
||||
content = unsignedNostrEvent.content
|
||||
)
|
||||
|
||||
|
||||
nostrRepository.publishNostrEvent(
|
||||
NostrEvent(
|
||||
id = event.id,
|
||||
@@ -116,7 +117,7 @@ class NavigationViewModel(
|
||||
broadcastNostrEventReceipt = localProfile.broadcastNostrEventReceipt
|
||||
)
|
||||
} else if (localProfile.broadcastNostrEventRequest != null) {
|
||||
logger.i("We have a profile: ${localProfile.profile}")
|
||||
logger.i("We have a broadcast request: ${localProfile.broadcastNostrEventRequest}")
|
||||
NavigationUIState.UnannouncedProfile(
|
||||
broadcastNostrEventRequest = localProfile.broadcastNostrEventRequest
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user