diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/database/dao/NostrDao.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/database/dao/NostrDao.kt index 53f4b8b8..a9de3d82 100644 --- a/composeApp/src/commonMain/kotlin/ac/aux/compose/database/dao/NostrDao.kt +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/database/dao/NostrDao.kt @@ -115,6 +115,7 @@ abstract class NostrDao( if (profile == null) { val placeHolderProfile = Profile( publicKey = nostrEvent.pubKey, + createdAt = GENESIS_AT, nostrEventId = nostrEvent.id, // Will get overwriting by sync, ) database.profileDao().insertPlaceholderProfile(placeHolderProfile) @@ -134,6 +135,8 @@ abstract class NostrDao( } ) } + } else { + logger.w("We somehow have an unsignedNostrEvent: $nostrEvent") } // Sync tagged events and authors... @@ -223,9 +226,11 @@ abstract class NostrDao( if (replyingToPost == null) { // Persist PlaceHolder and sync + // TODO: Get replyingToAuthorPublicKey database.postDao().insert( Post( id = post.replyToId, + createdAt = GENESIS_AT, nostrEventId = nostrEvent.id, // Will get overwriting by sync handled by tagged events... content = post.replyToId, profilePublicKey = nostrEvent.pubKey // Will get overwriting by sync handled by tagged events... @@ -245,6 +250,7 @@ abstract class NostrDao( database.postDao().insert( Post( id = reaction.replyToId, + createdAt = GENESIS_AT, nostrEventId = nostrEvent.id, // Will get overwriting by sync handled by tagged events... content = reaction.replyToId, profilePublicKey = nostrEvent.pubKey // Will get overwriting by sync handled by tagged events... @@ -263,6 +269,7 @@ abstract class NostrDao( database.postDao().insert( Post( id = repost.repostedPostId, + createdAt = GENESIS_AT, nostrEventId = nostrEvent.id, // Will get overwriting by sync handled by tagged events... content = repost.repostedPostId, profilePublicKey = nostrEvent.pubKey // Will get overwriting by sync handled by tagged events... @@ -277,6 +284,7 @@ abstract class NostrDao( database.profileDao().insertPlaceholderProfile( Profile( publicKey = nostrEvent.pubKey, + createdAt = GENESIS_AT, nostrEventId = nostrEvent.id, // Will get overwriting by sync handled by tagged events... ) ) @@ -308,6 +316,7 @@ abstract class NostrDao( database.postDao().insert( Post( id = zap.postId, + createdAt = GENESIS_AT, nostrEventId = nostrEvent.id, // Will get overwriting by sync, content = zap.postId, profilePublicKey = nostrEvent.pubKey // Will get overwriting by sync, diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/database/model/intermdiate/LocalNostrEvent.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/database/model/intermdiate/LocalNostrEvent.kt index 4335e815..4a4483fe 100644 --- a/composeApp/src/commonMain/kotlin/ac/aux/compose/database/model/intermdiate/LocalNostrEvent.kt +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/database/model/intermdiate/LocalNostrEvent.kt @@ -14,7 +14,7 @@ data class LocalNostrEvent( parentColumn = "pubKey", entityColumn = "publicKey" ) - val profile: Profile, + val profile: Profile?, @Relation( parentColumn = "id", diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/widgets/detail/MetadataEventDetail.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/widgets/detail/MetadataEventDetail.kt index 7a0fde8a..a874fbcf 100644 --- a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/widgets/detail/MetadataEventDetail.kt +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/widgets/detail/MetadataEventDetail.kt @@ -90,11 +90,11 @@ fun MetadataEventDetail( verticalArrangement = Arrangement.Center ) { Text( - text = profile.displayName ?: profile.userName ?: profile.publicKey, + text = profile?.displayName ?: profile?.userName ?: localNostrEvent.nostrEvent.pubKey, style = MaterialTheme.typography.titleLarge ) - profile.nip05?.let { + profile?.nip05?.let { Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp) @@ -141,7 +141,7 @@ fun MetadataEventDetail( Icon( Icons.Default.Person, modifier = Modifier.size(50.dp), - contentDescription = profile.displayName ?: profile.userName ?: "Profile picture" + contentDescription = profile?.displayName ?: profile?.userName ?: "Profile picture" ) @@ -164,8 +164,10 @@ fun MetadataEventDetail( modifier = Modifier.fillMaxWidth().padding( horizontal = 20.dp ), + maxLines = 2, + overflow = TextOverflow.Ellipsis, textAlign = TextAlign.Start, - text = profile.about ?: "" + text = profile?.about ?: "" ) } } diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/widgets/detail/TextNoteEventDetail.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/widgets/detail/TextNoteEventDetail.kt index da7c8e84..784618e9 100644 --- a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/widgets/detail/TextNoteEventDetail.kt +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/widgets/detail/TextNoteEventDetail.kt @@ -94,18 +94,18 @@ fun TextNoteEventDetail( Icon( Icons.Default.Person, modifier = Modifier.size(50.dp), - contentDescription = profile.displayName ?: profile.userName ?: "Profile picture" + contentDescription = profile?.displayName ?: profile?.userName ?: "Profile picture" ) Column( modifier = Modifier.weight(1f) ) { Text( - text = profile.displayName ?: profile.userName ?: profile.publicKey, + text = profile?.displayName ?: profile?.userName ?: localNostrEvent.nostrEvent.pubKey, style = MaterialTheme.typography.bodyLarge ) - profile.nip05?.let { + profile?.nip05?.let { Text( text = profile.nip05 ?: "", style = MaterialTheme.typography.labelMedium diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/widgets/feed/EventListView.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/widgets/feed/EventListView.kt index 049b1077..99c958bb 100644 --- a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/widgets/feed/EventListView.kt +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/widgets/feed/EventListView.kt @@ -52,13 +52,14 @@ fun LocalNostrEvent.ListView( modifier = Modifier.fillMaxWidth().clickable( enabled = true, onClick = { - onNavigateToEvent.invoke(profile.nostrEventId) + onNavigateToEvent.invoke(profile?.nostrEventId ?: nostrEvent.id) + // TODO: Show error } ) ) { Text( modifier = Modifier.weight(1f), - text = profile.displayName ?: profile.userName ?: profile.publicKey, + text = profile?.displayName ?: profile?.userName ?: nostrEvent.pubKey, style = MaterialTheme.typography.labelSmall ) Text( diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/view/model/NavigationViewModel.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/view/model/NavigationViewModel.kt index 5798242d..8e89db13 100644 --- a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/view/model/NavigationViewModel.kt +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/view/model/NavigationViewModel.kt @@ -192,7 +192,7 @@ class NavigationViewModel( ) } else -> { - logger.d("Unhandled message: $nostrIncomingMessage") + logger.d("Unhandled message ${synchronizeNostrEventRequest.relayURL}: $nostrIncomingMessage") } } }