Cleanup code

This commit is contained in:
Kgothatso Ngako committed 2026-06-20 14:59:46 +02:00
1 parent 6c2609254d
commit 9def2cbe33
115 files changed
+371 -416

No files matched your search

@@ -46,9 +46,9 @@ class MainActivity : ComponentActivity() {
}
fun stopNfcReader() {
if (_root_ide_package_.com.machankura.compose.ui.composable.widgets.nfc.NfcStateRepository.isReading()) {
_root_ide_package_.com.machankura.compose.ui.composable.widgets.nfc.NfcStateRepository.updateState(
_root_ide_package_.com.machankura.compose.ui.composable.widgets.nfc.NfcState.Inactive)
if (com.machankura.compose.ui.composable.widgets.nfc.NfcStateRepository.isReading()) {
com.machankura.compose.ui.composable.widgets.nfc.NfcStateRepository.updateState(
com.machankura.compose.ui.composable.widgets.nfc.NfcState.Inactive)
}
nfcAdapter?.disableReaderMode(this@MainActivity)
}
@@ -6,4 +6,4 @@ class AndroidPlatform : Platform {
override val name: String = "Android ${Build.VERSION.SDK_INT}"
}
actual fun getPlatform(): Platform = _root_ide_package_.at.torch.compose.AndroidPlatform()
actual fun getPlatform(): Platform = AndroidPlatform()
@@ -75,7 +75,7 @@ class HceService : HostApduService() {
}
}
}
return Service.START_NOT_STICKY
return START_NOT_STICKY
}
@OptIn(ExperimentalStdlibApi::class)
@@ -135,7 +135,7 @@ class PaymentsForegroundService : Service() {
}
// show a notification -- this is mandatory!
val notif = SystemNotificationHelper.notifyRunningHeadless(applicationContext)
SystemNotificationHelper.notifyRunningHeadless(applicationContext)
// startForeground(notif)
// service will automatically shutdown -- delay is short if the message is ignored
@@ -149,7 +149,7 @@ object SystemNotificationHelper {
// amountIncoming.toPrettyString(BitcoinUnit.Sat, withUnit = true)),
message = when {
source == LiquidityEvents.Source.OnChainWallet && nextTimeoutRemainingBlocks != null && nextTimeoutRemainingBlocks < SWAP_TIMEOUT_THRESHOLD_IN_BLOCKS -> {
val remainingTimeMillis = nextTimeoutRemainingBlocks * 10 * DateUtils.MINUTE_IN_MILLIS
nextTimeoutRemainingBlocks * 10 * DateUtils.MINUTE_IN_MILLIS
// TODO: context.getString(R.string.notif_rejected_policy_disabled_timeout, (currentTimestampMillis() + remainingTimeMillis).toAbsoluteDateString())
"Rejected policy disabled timeout"
}
@@ -2,6 +2,4 @@ package at.torch.compose
class TorchGlobal(
val platformContext: PlatformContext
) {
}
)
@@ -8,12 +8,12 @@ import com.vitorpamplona.quartz.nip19Bech32.bech32.Bech32
import com.vitorpamplona.quartz.nip51Lists.encryption.PrivateTagsInContent
import kotlin.time.Instant
fun at.torch.compose.database.model.UnsignedNostrEvent.signOrThrow(nsec: String): at.torch.compose.database.model.NostrEvent {
fun at.torch.compose.database.model.UnsignedNostrEvent.signOrThrow(nsec: String): NostrEvent {
val hexPrivateKey = Bech32.decodeBytes(nsec).second
return this.signOrThrow(hexPrivateKey)
}
fun at.torch.compose.database.model.UnsignedNostrEvent.signOrThrow(hexPrivateKey: ByteArray): at.torch.compose.database.model.NostrEvent {
fun at.torch.compose.database.model.UnsignedNostrEvent.signOrThrow(hexPrivateKey: ByteArray): NostrEvent {
val tempSigner = NostrSignerSync(
KeyPair(
privKey = hexPrivateKey
@@ -53,7 +53,7 @@ abstract class NostrDao(
@Transaction
open suspend fun publishNostrEvent(
unsignedNostrEvent: at.torch.compose.database.model.UnsignedNostrEvent,
nostrEvent: at.torch.compose.database.model.NostrEvent,
nostrEvent: NostrEvent,
relayURLs: List<String>,
activeKeyPair: KeyPair
) {
@@ -88,7 +88,7 @@ abstract class NostrDao(
@Transaction
open suspend fun storeNostrEvent(
nostrEvent: at.torch.compose.database.model.NostrEvent,
nostrEvent: NostrEvent,
relayURL: String,
synchronizationRelayURLs: List<String>,
level: Int,
@@ -136,7 +136,7 @@ abstract class NostrDao(
}
private suspend fun indexNostrEvent(
nostrEvent: at.torch.compose.database.model.NostrEvent,
nostrEvent: NostrEvent,
relayURL: String,
synchronizationRelayURLs: List<String>,
level: Int,
@@ -711,7 +711,7 @@ abstract class NostrDao(
chatMessageRelayListEvent.relays()
.map { normalizedRelayUrl ->
NegentropySynchronizeRequest(
id = NegentropySynchronizeRequest.Companion.computeId(
id = NegentropySynchronizeRequest.computeId(
relayURL = normalizedRelayUrl.url,
synchronizationFilter = synchronizationFilter
),
@@ -1023,7 +1023,7 @@ abstract class NostrDao(
)
negentropySynchronizeRequests.add(
NegentropySynchronizeRequest(
id = _root_ide_package_.at.torch.compose.database.model.NegentropySynchronizeRequest.Companion.computeId(
id = NegentropySynchronizeRequest.computeId(
relayUrlProfilePublicKey.key,
synchronizationFilter
),
@@ -1044,7 +1044,7 @@ abstract class NostrDao(
Clock.System.now().toEpochMilliseconds()
negentropySynchronizeRequests.add(
NegentropySynchronizeRequest(
id = _root_ide_package_.at.torch.compose.database.model.NegentropySynchronizeRequest.Companion.computeId(
id = NegentropySynchronizeRequest.computeId(
relayUrlEventIds.key,
synchronizationFilter
),
@@ -46,5 +46,4 @@ data class ChatMessage(
override val savedAt: Instant = Clock.System.now(),
override val viewedAt: Instant? = null,
override val deletedAt: Instant? = null, // Who this message should be seen by (used to derive conversationId)
): TimestampedEntity, LocalStoreEntity, UserViewableEntity, SoftDeletableEntity {
}
): TimestampedEntity, LocalStoreEntity, UserViewableEntity, SoftDeletableEntity
@@ -59,6 +59,4 @@ data class InReplyToRelation(
): at.torch.compose.database.model.traits.TimestampedEntity,
at.torch.compose.database.model.traits.LocalStoreEntity,
at.torch.compose.database.model.traits.UserViewableEntity,
at.torch.compose.database.model.traits.SoftDeletableEntity {
}
at.torch.compose.database.model.traits.SoftDeletableEntity
@@ -37,6 +37,4 @@ data class MarmotKeyPackageBundle(
override val savedAt: Instant = Clock.System.now(),
override val deletedAt: Instant? = null,
override val broadcastedAt: Instant? = null,
): TimestampedEntity, LocalStoreEntity, BroadcastableEntity, SoftDeletableEntity {
}
): TimestampedEntity, LocalStoreEntity, BroadcastableEntity, SoftDeletableEntity
@@ -21,7 +21,7 @@ import kotlin.uuid.Uuid
entity = NostrEvent::class,
parentColumns = ["id"],
childColumns = ["nostrEventId"],
onDelete = ForeignKey.Companion.CASCADE,
onDelete = ForeignKey.CASCADE,
),
],
indices = [
@@ -333,7 +333,7 @@ data class NostrEvent(
}
}
val quotedNotes = _root_ide_package_.at.torch.compose.ui.composable.widgets.content.ContentParser.parse(content.trimEnd('\n', '\r'), emptyMap(), emptyMap(), trimBlankLines = true)
val quotedNotes = at.torch.compose.ui.composable.widgets.content.ContentParser.parse(content.trimEnd('\n', '\r'), emptyMap(), emptyMap(), trimBlankLines = true)
.filterIsInstance<at.torch.compose.ui.composable.widgets.content.ContentSegment.NostrNoteSegment>()
.firstOrNull()
@@ -386,7 +386,7 @@ data class NostrEvent(
}
fun toZap(): Zap? = try {
if (kind == LnZapEvent.KIND) {
val zapEvent = EventFactory.create<LnZapEvent>(
EventFactory.create<LnZapEvent>(
id = id,
pubKey = pubKey,
createdAt = createdAt.epochSeconds,
@@ -441,7 +441,7 @@ data class NostrEvent(
fun fromEvent(event: Event, synchronizeNostrEventRequest: SynchronizeNostrEventRequest? = null): NostrEvent? = try {
// TODO: Check for unsupported kind
val taggedEvent = event.firstTaggedEvent()
event.firstTaggedEvent()
val quotedEvent = when (val taggedQuote = event.firstTaggedQuote()) {
is QEventTag -> {
@@ -32,7 +32,4 @@ data class NostrEventRelay(
override val createdAt: Instant = Clock.System.now(),
override val updatedAt: Instant = createdAt,
): NostrEventEntity, TimestampedEntity {
}
): NostrEventEntity, TimestampedEntity
@@ -172,7 +172,7 @@ data class Profile(
Text(
text = staticIdentifier,
style = MaterialTheme.typography.labelMedium,
color = _root_ide_package_.at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(publicKey)
color = at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(publicKey)
)
}
@@ -49,6 +49,4 @@ data class QuotedRelation(
at.torch.compose.database.model.traits.LocalStoreEntity,
at.torch.compose.database.model.traits.UserViewableEntity,
at.torch.compose.database.model.traits.BroadcastableEntity,
at.torch.compose.database.model.traits.SoftDeletableEntity {
}
at.torch.compose.database.model.traits.SoftDeletableEntity
@@ -48,6 +48,4 @@ data class RepostedRelation(
at.torch.compose.database.model.traits.LocalStoreEntity,
at.torch.compose.database.model.traits.UserViewableEntity,
at.torch.compose.database.model.traits.BroadcastableEntity,
at.torch.compose.database.model.traits.SoftDeletableEntity {
}
at.torch.compose.database.model.traits.SoftDeletableEntity
@@ -12,7 +12,7 @@ data class LocalChatRoom(
@Embedded val chatRoom: at.torch.compose.database.model.ChatRoom,
@Relation(
entity = _root_ide_package_.at.torch.compose.database.model.Participant::class,
entity = at.torch.compose.database.model.Participant::class,
parentColumns = ["id"],
entityColumns = ["chatRoomId"],
)
@@ -23,7 +23,7 @@ data class LocalChatRoom(
if (chatRoom.subject != null) {
Text(
text = chatRoom.subject,
color = _root_ide_package_.at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(chatRoom.id)
color = at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(chatRoom.id)
)
} else {
if (localParticipants.size == 1) {
@@ -33,7 +33,7 @@ data class LocalChatRoom(
} else {
// Remove the active user publicKey from participants...
val participantNames = localParticipants.filter { it.participant.participantPublicKey != chatRoom.userPublicKey }.map { buildAnnotatedString {
withStyle(style = SpanStyle(color = _root_ide_package_.at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(it.participant.participantPublicKey))) {
withStyle(style = SpanStyle(color = at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(it.participant.participantPublicKey))) {
append(it.profile?.humanReadableNameOrPubkey() ?: "unknown participant")
}
} }
@@ -33,7 +33,7 @@ data class LocalInReplyToNostrEvent(
val profile: at.torch.compose.database.model.Profile?,
@Relation(
entity = _root_ide_package_.at.torch.compose.database.model.Mention::class,
entity = at.torch.compose.database.model.Mention::class,
parentColumns = ["inReplyToNostrEventId"],
entityColumns = ["mentioningNostrEventId"],
)
@@ -26,28 +26,28 @@ data class LocalNostrEvent(
val profile: at.torch.compose.database.model.Profile?,
@Relation(
entity = _root_ide_package_.at.torch.compose.database.model.RepostedRelation::class,
entity = at.torch.compose.database.model.RepostedRelation::class,
parentColumns = ["id"],
entityColumns = ["repostingNostrEventId"]
)
val localRepostedNostrEvent: LocalRepostedNostrEvent? = null,
@Relation(
entity = _root_ide_package_.at.torch.compose.database.model.QuotedRelation::class,
entity = at.torch.compose.database.model.QuotedRelation::class,
parentColumns = ["id"],
entityColumns = ["quotingNostrEventId"]
)
val localQuotedNostrEvent: LocalQuotedNostrEvent? = null,
@Relation(
entity = _root_ide_package_.at.torch.compose.database.model.InReplyToRelation::class,
entity = at.torch.compose.database.model.InReplyToRelation::class,
parentColumns = ["id"],
entityColumns = ["replyingNostrEventId"]
)
val localInReplyToNostrEvent: LocalInReplyToNostrEvent? = null,
@Relation(
entity = _root_ide_package_.at.torch.compose.database.model.Mention::class,
entity = at.torch.compose.database.model.Mention::class,
parentColumns = ["id"],
entityColumns = ["mentioningNostrEventId"],
)
@@ -17,7 +17,7 @@ data class LocalProfileWithFollowers(
parentColumns = ["pubKey"],
entityColumns = ["publicKey"],
associateBy = Junction(
value = _root_ide_package_.at.torch.compose.database.model.Connection::class,
value = at.torch.compose.database.model.Connection::class,
parentColumns = ["destinationPublicKey"],
entityColumns = ["sourcePublicKey"]
)
@@ -17,7 +17,7 @@ data class LocalProfileWithFollowing(
parentColumns = ["pubKey"],
entityColumns = ["publicKey"],
associateBy = Junction(
value = _root_ide_package_.at.torch.compose.database.model.Connection::class,
value = at.torch.compose.database.model.Connection::class,
parentColumns = ["sourcePublicKey"],
entityColumns = ["destinationPublicKey"]
)
@@ -34,7 +34,7 @@ data class LocalQuotedNostrEvent(
val profile: at.torch.compose.database.model.Profile?,
@Relation(
entity = _root_ide_package_.at.torch.compose.database.model.Mention::class,
entity = at.torch.compose.database.model.Mention::class,
parentColumns = ["quotedNostrEventId"],
entityColumns = ["mentioningNostrEventId"],
)
@@ -73,7 +73,7 @@ data class LocalQuotedNostrEvent(
Text(
text = staticIdentifier,
style = MaterialTheme.typography.bodySmall,
color = _root_ide_package_.at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromProfile(profile)
color = at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromProfile(profile)
)
}
}
@@ -33,7 +33,7 @@ data class LocalRepostedNostrEvent(
val profile: at.torch.compose.database.model.Profile?,
@Relation(
entity = _root_ide_package_.at.torch.compose.database.model.Mention::class,
entity = at.torch.compose.database.model.Mention::class,
parentColumns = ["repostedNostrEventId"],
entityColumns = ["mentioningNostrEventId"],
)
@@ -89,7 +89,7 @@ class DatabaseNostrRepository(
database.connectionDao().delete(connection)
}
override suspend fun observeUnsignedNostrEvents(publicKey: HexKey): Flow<at.torch.compose.database.model.UnsignedNostrEvent?> {
override suspend fun observeUnsignedNostrEvents(publicKey: HexKey): Flow<UnsignedNostrEvent?> {
return database.unsignedNostrEventDao().observeUnsignedNostrEvents(publicKey)
}
@@ -131,7 +131,7 @@ class DatabaseNostrRepository(
followUsers.map { it.toTagArray() }
unsignedNostrEvents.add(
_root_ide_package_.at.torch.compose.database.model.UnsignedNostrEvent(
UnsignedNostrEvent(
pubKey = publicKey,
kind = ContactListEvent.KIND,
tags = contactListTagList.toTypedArray(),
@@ -142,11 +142,11 @@ class DatabaseNostrRepository(
)
unsignedNostrEvents.add(
_root_ide_package_.at.torch.compose.database.model.UnsignedNostrEvent(
UnsignedNostrEvent(
pubKey = publicKey,
kind = ChatMessageRelayListEvent.KIND,
tags = ChatMessageRelayListEvent.createTagArray(
_root_ide_package_.at.torch.compose.nostr.Relays.DefaultDMRelayList
Relays.DefaultDMRelayList
),
content = ""
)
@@ -189,7 +189,7 @@ class DatabaseNostrRepository(
tags = arrayOf(
AltTag.assemble(RelayFeedsListEvent.ALT)
),
privateTags = _root_ide_package_.at.torch.compose.nostr.Relays.DefaultGlobalRelays.map {
privateTags = Relays.DefaultGlobalRelays.map {
RelayTag.assemble(
it
)
@@ -199,7 +199,7 @@ class DatabaseNostrRepository(
)
// KeyPackage...
val slot = KeyPackageUtils.PRIMARY_SLOT
KeyPackageUtils.PRIMARY_SLOT
val dTag = KeyPackageUtils.generateRandomDTag() // TODO: Persist this...
val identity = publicKey.hexToByteArray()
val bundle = generateKeyPackage(identity, dTag)
@@ -312,7 +312,7 @@ class DatabaseNostrRepository(
val profileEventTemplate = MetadataEvent.createNew()
saveUnsignedNostrEvent(
_root_ide_package_.at.torch.compose.database.model.UnsignedNostrEvent(
UnsignedNostrEvent(
pubKey = publicKey,
kind = profileEventTemplate.kind,
createdAt = Instant.fromEpochSeconds(profileEventTemplate.createdAt),
@@ -417,7 +417,7 @@ class DatabaseNostrRepository(
val unsignedNostrEvent = saveUnsignedNostrEvent(
_root_ide_package_.at.torch.compose.database.model.UnsignedNostrEvent(
UnsignedNostrEvent(
pubKey = publicKey,
kind = textNote.kind,
createdAt = Instant.fromEpochSeconds(textNote.createdAt),
@@ -441,7 +441,7 @@ class DatabaseNostrRepository(
}
}
override suspend fun saveUnsignedNostrEvent(unsignedNostrEvent: at.torch.compose.database.model.UnsignedNostrEvent): at.torch.compose.database.model.UnsignedNostrEvent? = try {
override suspend fun saveUnsignedNostrEvent(unsignedNostrEvent: UnsignedNostrEvent): UnsignedNostrEvent? = try {
logger.d("Save unsigned: ${unsignedNostrEvent.kind}")
// TODO: We can actually check the unsignedNostrEvent.pubKey for support... if it's writeable
if (unsignedNostrEvent.kind == MetadataEvent.KIND){
@@ -456,7 +456,7 @@ class DatabaseNostrRepository(
null
}
override suspend fun saveUnsignedNostrEvents(unsignedNostrEvents: List<at.torch.compose.database.model.UnsignedNostrEvent>) {
override suspend fun saveUnsignedNostrEvents(unsignedNostrEvents: List<UnsignedNostrEvent>) {
logger.d("saveUnsignedNostrEvents: $unsignedNostrEvents")
delay(2_100)
@@ -470,7 +470,7 @@ class DatabaseNostrRepository(
}
override suspend fun publishNostrEvent(
unsignedNostrEvent: at.torch.compose.database.model.UnsignedNostrEvent,
unsignedNostrEvent: UnsignedNostrEvent,
nostrEvent: at.torch.compose.database.model.NostrEvent,
relayURLs: List<String>,
activeKeyPair: KeyPair
@@ -2,6 +2,4 @@ package at.torch.compose.database.repository
class DatabasePostRepository(
private val database: at.torch.compose.database.TorchDatabase
): at.torch.compose.repository.PostRepository {
}
): at.torch.compose.repository.PostRepository
@@ -1,4 +1,3 @@
package at.torch.compose.exceptions
open class GiftWrapImpersonationException(message: String? = null, cause: Throwable? = null) : Exception(message, cause) {
}
open class GiftWrapImpersonationException(message: String? = null, cause: Throwable? = null) : Exception(message, cause)
@@ -1,4 +1,3 @@
package at.torch.compose.exceptions
open class GiftWrapSealDecryptionException(message: String? = null, cause: Throwable? = null) : Exception(message, cause) {
}
open class GiftWrapSealDecryptionException(message: String? = null, cause: Throwable? = null) : Exception(message, cause)
@@ -1,4 +1,3 @@
package at.torch.compose.exceptions
open class GiftWrapUnsealException(message: String? = null, cause: Throwable? = null) : Exception(message, cause) {
}
open class GiftWrapUnsealException(message: String? = null, cause: Throwable? = null) : Exception(message, cause)
@@ -1,4 +1,3 @@
package at.torch.compose.exceptions
open class SignatureException(message: String? = null, cause: Throwable? = null) : Exception(message, cause) {
}
open class SignatureException(message: String? = null, cause: Throwable? = null) : Exception(message, cause)
@@ -4,5 +4,3 @@ class SigningKeyNotFoundException(message: String? = null, cause: Throwable? = n
message,
cause,
)
{
}
@@ -1,4 +1,3 @@
package at.torch.compose.exceptions
class SigningRejectedException(message: String? = null, cause: Throwable? = null) : SignatureException(message, cause) {
}
class SigningRejectedException(message: String? = null, cause: Throwable? = null) : SignatureException(message, cause)
@@ -5,7 +5,7 @@ class AuxDatabaseManager(
) {
val auxDatabase by lazy {
_root_ide_package_.at.torch.compose.database.builder.getRoomDatabase(
_root_ide_package_.at.torch.compose.database.builder.PlatformDatabaseBuilder.getDatabaseBuilder(
at.torch.compose.database.builder.PlatformDatabaseBuilder.getDatabaseBuilder(
torchGlobal.platformContext
)
)
@@ -18,7 +18,7 @@ class AuxDatabaseManager(
*/
val inMemoryAuxDatabase by lazy {
_root_ide_package_.at.torch.compose.database.builder.getRoomDatabase(
_root_ide_package_.at.torch.compose.database.builder.PlatformDatabaseBuilder.getInMemoryDatabaseBuilder(
at.torch.compose.database.builder.PlatformDatabaseBuilder.getInMemoryDatabaseBuilder(
torchGlobal.platformContext
)
)
@@ -157,7 +157,7 @@ class RelayPool(
)
}
@Throws(_root_ide_package_.at.torch.compose.exceptions.NostrPublishException::class)
@Throws(at.torch.compose.exceptions.NostrPublishException::class)
suspend fun publishEvent(nostrEvent: at.torch.compose.database.model.NostrEvent, relays: Set<at.torch.compose.network.dto.RelayDTO> = emptySet()): Flow<NostrPublishResult> {
val relayUrls = relays.map { NormalizedRelayUrl(it.url).displayUrl() }
@@ -27,7 +27,7 @@ import kotlinx.coroutines.sync.withLock
*
* https://github.com/PrimalHQ/primal-android-app/blob/6db2e6862239335dede4162338d7c4f10ad35031/app/src/main/kotlin/net/primal/android/networking/relays/RelaysSocketManager.kt
*/
class RelaysSocketManager constructor(
class RelaysSocketManager(
private val activeWalletStateFlow: StateFlow<ActiveWallet?>,
private val nostrSocketClientFactory: at.torch.compose.network.sockets.NostrSocketClientFactory,
private val cachingImportRepository: at.torch.compose.repository.CachingImportRepository,
@@ -101,7 +101,7 @@ class RelaysSocketManager constructor(
relayPool.closePool()
}
@Throws(_root_ide_package_.at.torch.compose.exceptions.NostrPublishException::class)
@Throws(at.torch.compose.exceptions.NostrPublishException::class)
suspend fun publishEvent(nostrEvent: at.torch.compose.database.model.NostrEvent): Flow<NostrPublishResult> {
return if (userRelays.isNotEmpty()) {
relayPool.publishEvent(
@@ -116,7 +116,7 @@ class RelaysSocketManager constructor(
}
}
@Throws(_root_ide_package_.at.torch.compose.exceptions.NostrPublishException::class)
@Throws(at.torch.compose.exceptions.NostrPublishException::class)
suspend fun publishEvent(nostrEvent: at.torch.compose.database.model.NostrEvent, relays: Set<at.torch.compose.network.dto.RelayDTO>): Flow<NostrPublishResult> {
logger.d("publishEvent: $nostrEvent")
return relayPool.publishEvent(
@@ -74,7 +74,7 @@ private fun JsonArray.takeAsEventIncomingMessage(): NostrIncomingMessage? {
if (subscriptionId == null || kind == null) return null
val nostrEvent = _root_ide_package_.at.torch.compose.database.model.NostrEvent.Companion.fromEvent(
val nostrEvent = at.torch.compose.database.model.NostrEvent.fromEvent(
Event.fromJson(
event.toString()
)
@@ -95,7 +95,7 @@ private fun JsonArray.takeAsEventsIncomingMessage(): NostrIncomingMessage? {
val nostrEvents = mutableListOf<at.torch.compose.database.model.NostrEvent>()
events.map { it.jsonObject }.forEach { jsonEvent ->
_root_ide_package_.at.torch.compose.database.model.NostrEvent.Companion.fromEvent(
at.torch.compose.database.model.NostrEvent.fromEvent(
Event.fromJson(
jsonEvent.toString()
)
@@ -7,7 +7,7 @@ import kotlinx.serialization.json.Json
internal val defaultSocketsHttpClient by lazy {
HttpClient() {
HttpClient {
install(WebSockets) {
contentConverter = KotlinxWebsocketSerializationConverter(Json {
isLenient = true
@@ -70,7 +70,7 @@ class NostrNotaryRepository(
walletManager.keyManager.value?.nostrPrivateKey()?.value?.toByteArray()?.toNsec()
}.getOrNull() ?: throw _root_ide_package_.at.torch.compose.exceptions.SigningKeyNotFoundException()
private fun signNostrEvent(publicKey: String, event: at.torch.compose.database.model.UnsignedNostrEvent): at.torch.compose.database.model.NostrEvent? {
private fun signNostrEvent(publicKey: String, event: at.torch.compose.database.model.UnsignedNostrEvent): at.torch.compose.database.model.NostrEvent {
val isExternalSignerLogin = runCatching {
// credentialsStore.isExternalSignerCredential(npub = publicKey.hexToNpubHrp())
false
@@ -100,7 +100,7 @@ class NostrNotaryRepository(
}
)
}
.toTypedArray() + listOf(_root_ide_package_.at.torch.compose.network.UserAgent.CLIENT_NAME.asClientTag()),
.toTypedArray() + listOf(at.torch.compose.network.UserAgent.CLIENT_NAME.asClientTag()),
),
)
}
@@ -30,7 +30,7 @@ class NostrPublisherRepository(
}
}
@Throws(_root_ide_package_.at.torch.compose.exceptions.NostrPublishException::class)
@Throws(at.torch.compose.exceptions.NostrPublishException::class)
private suspend fun publishAndImportEvent(signedNostrEvent: at.torch.compose.database.model.NostrEvent, outboxRelays: List<String> = emptyList()) {
relaysSocketManager.publishEvent(signedNostrEvent)
importEvent(signedNostrEvent)
@@ -52,7 +52,7 @@ class NostrPublisherRepository(
}
}
@Throws(_root_ide_package_.at.torch.compose.exceptions.NostrPublishException::class, _root_ide_package_.at.torch.compose.exceptions.SignatureException::class)
@Throws(at.torch.compose.exceptions.NostrPublishException::class, at.torch.compose.exceptions.SignatureException::class)
suspend fun signPublishImportNostrEvent(
unsignedNostrEvent: at.torch.compose.database.model.UnsignedNostrEvent,
outboxRelays: List<String>,
@@ -63,7 +63,7 @@ class NostrPublisherRepository(
}
@Throws(_root_ide_package_.at.torch.compose.exceptions.NostrPublishException::class, _root_ide_package_.at.torch.compose.exceptions.SignatureException::class)
@Throws(at.torch.compose.exceptions.NostrPublishException::class, at.torch.compose.exceptions.SignatureException::class)
suspend fun publishRelayList(userId: String, relays: List<at.torch.compose.network.dto.RelayDTO>): at.torch.compose.database.model.NostrEvent {
val signedNostrEvent = nostrNotary.signRelayListMetadata(userId = userId, relays = relays).unwrapOrThrow()
relaysSocketManager.publishEvent(nostrEvent = signedNostrEvent, relays = relays.toSet())
@@ -1,4 +1,3 @@
package at.torch.compose.repository
interface PostRepository {
}
interface PostRepository
@@ -16,7 +16,7 @@ object BlurHashDecoder {
if (blurHash.length != 4 + 2 * nx * ny) return null
val maxAc = (decode83(blurHash, 1, 2) + 1) / 166f
val colors = Array(nx * ny) { i ->
Array(nx * ny) { i ->
if (i == 0) {
val color83 = decode83(blurHash, 2, 6)
decodeDc(color83)
@@ -46,7 +46,7 @@ fun ChatRoomDetailScreen(
activeUserPublicKey: HexKey,
chatRoomId: String,
relayHint: String?,
initialChatRoomDetailUIState: at.torch.compose.ui.view.state.ChatRoomDetailUIState = _root_ide_package_.at.torch.compose.ui.view.state.ChatRoomDetailUIState.Loading,
initialChatRoomDetailUIState: at.torch.compose.ui.view.state.ChatRoomDetailUIState = at.torch.compose.ui.view.state.ChatRoomDetailUIState.Loading,
nostrRepository: at.torch.compose.repository.NostrRepository,
chatRepository: at.torch.compose.repository.ChatRepository
) {
@@ -62,7 +62,7 @@ fun ChatRoomDetailScreen(
)
when (val chatRoomDetailUIState = chatRoomDetailViewModel.chatRoomDetailUIState) {
_root_ide_package_.at.torch.compose.ui.view.state.ChatRoomDetailUIState.Error -> {
at.torch.compose.ui.view.state.ChatRoomDetailUIState.Error -> {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
@@ -79,7 +79,7 @@ fun ChatRoomDetailScreen(
val textFieldState = rememberTextFieldState()
val chatRoomDetailMessageListViewModel: at.torch.compose.ui.view.model.ChatRoomDetailMessageListViewModel = viewModel(
factory = _root_ide_package_.at.torch.compose.ui.view.model.ChatRoomDetailMessageListViewModel.Companion.factory(
factory = at.torch.compose.ui.view.model.ChatRoomDetailMessageListViewModel.factory(
localChatRoom = chatRoomDetailUIState.localChatRoom,
nostrRepository = nostrRepository,
chatRepository = chatRepository
@@ -228,7 +228,7 @@ fun ChatRoomDetailScreen(
}
}
}
_root_ide_package_.at.torch.compose.ui.view.state.ChatRoomDetailUIState.Loading -> {
at.torch.compose.ui.view.state.ChatRoomDetailUIState.Loading -> {
Column(
modifier = Modifier.fillMaxWidth().padding(
20.dp
@@ -264,7 +264,7 @@ fun ChatRoomDetailScreen(
}
LaunchedEffect(true) {
if (initialChatRoomDetailUIState == _root_ide_package_.at.torch.compose.ui.view.state.ChatRoomDetailUIState.Loading) {
if (initialChatRoomDetailUIState == at.torch.compose.ui.view.state.ChatRoomDetailUIState.Loading) {
chatRoomDetailViewModel.initiateChatRoomDetail()
}
}
@@ -281,7 +281,7 @@ private fun ChatRoomDetailScreenPreview() {
activeUserPublicKey = "",
chatRoomId = "publicKey",
relayHint = null,
initialChatRoomDetailUIState = _root_ide_package_.at.torch.compose.ui.view.state.ChatRoomDetailUIState.Loaded(
initialChatRoomDetailUIState = at.torch.compose.ui.view.state.ChatRoomDetailUIState.Loaded(
localChatRoom = _root_ide_package_.at.torch.compose.database.model.intermdiate.LocalChatRoom(
chatRoom = _root_ide_package_.at.torch.compose.database.model.ChatRoom(
id = "",
@@ -292,8 +292,8 @@ private fun ChatRoomDetailScreenPreview() {
),
)
),
nostrRepository = _root_ide_package_.at.torch.compose.repository.NostrRepository.Companion.NO_OP_NOSTR_REPOSITORY,
chatRepository = _root_ide_package_.at.torch.compose.repository.ChatRepository.Companion.NO_OP_CHAT_REPOSITORY
nostrRepository = at.torch.compose.repository.NostrRepository.NO_OP_NOSTR_REPOSITORY,
chatRepository = at.torch.compose.repository.ChatRepository.NO_OP_CHAT_REPOSITORY
)
}
}
@@ -65,7 +65,7 @@ fun CreateProfileScreen(
) {
when (val createAccountUIState = createProfileViewModel.createProfileUIState.value) {
is at.torch.compose.ui.view.state.CreateProfileUIState.Declaration -> {
is CreateProfileUIState.Declaration -> {
Text(
"Create Profile",
@@ -91,7 +91,7 @@ fun CreateProfileScreen(
Button(
onClick = {
createProfileViewModel.createProfileUIState.value = _root_ide_package_.at.torch.compose.ui.view.state.CreateProfileUIState.InputPrompt
createProfileViewModel.createProfileUIState.value = CreateProfileUIState.InputPrompt
}
) {
Text(
@@ -99,7 +99,7 @@ fun CreateProfileScreen(
)
}
}
is at.torch.compose.ui.view.state.CreateProfileUIState.InputPrompt -> {
is CreateProfileUIState.InputPrompt -> {
Text(
"Create Profile",
style = MaterialTheme.typography.headlineSmall
@@ -204,7 +204,7 @@ fun CreateProfileScreen(
createProfileViewModel.validateInput().let { isInputValid ->
if (isInputValid) {
createProfileViewModel.createProfileUIState.value =
_root_ide_package_.at.torch.compose.ui.view.state.CreateProfileUIState.ConfirmInput(
CreateProfileUIState.ConfirmInput(
name = createProfileViewModel.createProfileFormState.nameField.textFieldState.text.toString(),
bio = createProfileViewModel.createProfileFormState.biographyField.textFieldState.text.toString()
)
@@ -220,7 +220,7 @@ fun CreateProfileScreen(
}
}
is at.torch.compose.ui.view.state.CreateProfileUIState.ConfirmInput -> {
is CreateProfileUIState.ConfirmInput -> {
Text(
text = "Name",
@@ -278,7 +278,7 @@ fun CreateProfileScreen(
}
}
is at.torch.compose.ui.view.state.CreateProfileUIState.Error -> {
is CreateProfileUIState.Error -> {
Spacer(
modifier = Modifier.weight(1f)
)
@@ -291,7 +291,7 @@ fun CreateProfileScreen(
modifier = Modifier.weight(1f)
)
}
is at.torch.compose.ui.view.state.CreateProfileUIState.ProfileReady -> {
is CreateProfileUIState.ProfileReady -> {
Spacer(
modifier = Modifier.weight(1f)
@@ -41,7 +41,7 @@ import kotlinx.coroutines.launch
@Composable
fun HomeScreen(
activeUserPublicKey: HexKey,
initialHomeScreenUIState: at.torch.compose.ui.view.state.HomeScreenUIState = _root_ide_package_.at.torch.compose.ui.view.state.HomeScreenUIState.Loading,
initialHomeScreenUIState: at.torch.compose.ui.view.state.HomeScreenUIState = at.torch.compose.ui.view.state.HomeScreenUIState.Loading,
onNavigateToEvent: (at.torch.compose.ui.composable.navigation.routes.Route) -> Unit,
onNavigateToDirectMessageDetail: (at.torch.compose.ui.composable.navigation.routes.Route) -> Unit,
onNavigateToChatRoomCreation: () -> Unit,
@@ -52,16 +52,16 @@ fun HomeScreen(
val scope = rememberCoroutineScope()
val homeScreenViewModel: at.torch.compose.ui.view.model.HomeViewModel = viewModel(
factory = _root_ide_package_.at.torch.compose.ui.view.model.HomeViewModel.Companion.factory(
factory = at.torch.compose.ui.view.model.HomeViewModel.factory(
activeUserPublicKey = activeUserPublicKey,
initialHomeScreenUIState = initialHomeScreenUIState,
nostrRepository = nostrRepository,
pagerState = rememberPagerState { _root_ide_package_.at.torch.compose.ui.view.model.HomeScreenType.entries.size }
pagerState = rememberPagerState { HomeScreenType.entries.size }
),
)
when(val homeScreenUIState = homeScreenViewModel.homeScreenUIState) {
_root_ide_package_.at.torch.compose.ui.view.state.HomeScreenUIState.Error -> {
at.torch.compose.ui.view.state.HomeScreenUIState.Error -> {
Scaffold { innerPadding ->
Column(
modifier = Modifier.padding(innerPadding).fillMaxSize(),
@@ -180,8 +180,8 @@ fun HomeScreen(
HomeScreenType.Messages -> {
val chatRoomListViewModel: at.torch.compose.ui.view.model.ChatRoomListViewModel = viewModel(
key = homeScreenTypeType.name,
factory = _root_ide_package_.at.torch.compose.ui.view.model.ChatRoomListViewModel.Companion.factory(
initialChatRoomListUIState = _root_ide_package_.at.torch.compose.ui.view.state.ChatRoomListUIState.Loading,
factory = at.torch.compose.ui.view.model.ChatRoomListViewModel.factory(
initialChatRoomListUIState = at.torch.compose.ui.view.state.ChatRoomListUIState.Loading,
publicKey = homeScreenUIState.profileWithFollowing.profile.publicKey,
synchronizationFilter = homeScreenViewModel.getSynchronizationFilter(
homeScreenTypeType,
@@ -208,7 +208,7 @@ fun HomeScreen(
}
}
}
_root_ide_package_.at.torch.compose.ui.view.state.HomeScreenUIState.Loading -> {
at.torch.compose.ui.view.state.HomeScreenUIState.Loading -> {
_root_ide_package_.at.torch.compose.ui.composable.widgets.LoadingDataIndicator()
}
}
@@ -227,7 +227,7 @@ private fun HomeScreenPreview() {
) {
HomeScreen(
activeUserPublicKey = "",
initialHomeScreenUIState = _root_ide_package_.at.torch.compose.ui.view.state.HomeScreenUIState.Loaded(
initialHomeScreenUIState = at.torch.compose.ui.view.state.HomeScreenUIState.Loaded(
profileWithFollowing = _root_ide_package_.at.torch.compose.database.model.intermdiate.LocalProfileWithFollowing(
nostrEvent = _root_ide_package_.at.torch.compose.database.model.NostrEvent(
id = "eventId",
@@ -253,8 +253,8 @@ It has survived not only five centuries, but also the leap into electronic types
onNavigateToChatRoomCreation = {},
onNavigateToSearch = {},
onNavigateToDirectMessageDetail = {},
nostrRepository = _root_ide_package_.at.torch.compose.repository.NostrRepository.Companion.NO_OP_NOSTR_REPOSITORY,
chatRepository = _root_ide_package_.at.torch.compose.repository.ChatRepository.Companion.NO_OP_CHAT_REPOSITORY
nostrRepository = at.torch.compose.repository.NostrRepository.NO_OP_NOSTR_REPOSITORY,
chatRepository = at.torch.compose.repository.ChatRepository.NO_OP_CHAT_REPOSITORY
)
}
}
@@ -35,7 +35,7 @@ fun NostrEventDetailScreen(
onNavigateToQuoteNostrEvent: (String) -> Unit,
) {
val nostrEventDetailViewModel: at.torch.compose.ui.view.model.NostrEventDetailViewModel = viewModel(
factory = _root_ide_package_.at.torch.compose.ui.view.model.NostrEventDetailViewModel.Companion.factory(
factory = at.torch.compose.ui.view.model.NostrEventDetailViewModel.factory(
nostrEventId = nostrEventId,
initialNostrEventDetailUIState = initialNostrEventDetailUIState,
nostrRepository = nostrRepository,
@@ -44,7 +44,7 @@ fun NostrEventDetailScreen(
)
when(val feedListUIState = nostrEventDetailViewModel.nostrEventDetailUIState) {
_root_ide_package_.at.torch.compose.ui.view.state.NostrEventDetailUIState.Error -> {
at.torch.compose.ui.view.state.NostrEventDetailUIState.Error -> {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
@@ -107,14 +107,14 @@ fun NostrEventDetailScreen(
}
}
}
_root_ide_package_.at.torch.compose.ui.view.state.NostrEventDetailUIState.Loading -> {
at.torch.compose.ui.view.state.NostrEventDetailUIState.Loading -> {
_root_ide_package_.at.torch.compose.ui.composable.widgets.LoadingDataIndicator()
LaunchedEffect(true) {
nostrEventDetailViewModel.loadNostrFeed()
}
}
_root_ide_package_.at.torch.compose.ui.view.state.NostrEventDetailUIState.NotFound -> {
at.torch.compose.ui.view.state.NostrEventDetailUIState.NotFound -> {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
@@ -134,7 +134,7 @@ private fun NostrEventDetailScreenPreview() {
modifier = Modifier.padding(20.dp)
) {
NostrEventDetailScreen(
initialNostrEventDetailUIState = _root_ide_package_.at.torch.compose.ui.view.state.NostrEventDetailUIState.Loaded(
initialNostrEventDetailUIState = at.torch.compose.ui.view.state.NostrEventDetailUIState.Loaded(
localNostrEvent = _root_ide_package_.at.torch.compose.database.model.intermdiate.LocalNostrEvent(
nostrEvent = _root_ide_package_.at.torch.compose.database.model.NostrEvent(
id = "eventId",
@@ -157,7 +157,7 @@ It has survived not only five centuries, but also the leap into electronic types
),
nostrEventId = "",
activeUserPublicKey = "",
nostrRepository = _root_ide_package_.at.torch.compose.repository.NostrRepository.Companion.NO_OP_NOSTR_REPOSITORY,
nostrRepository = at.torch.compose.repository.NostrRepository.NO_OP_NOSTR_REPOSITORY,
onNavigateBack = {},
onNavigateToEvent = {},
onNavigateToWriteAReply = {},
@@ -65,8 +65,8 @@ fun SearchResultScreen(
val scope = rememberCoroutineScope()
val searchViewModel: at.torch.compose.ui.view.model.SearchResultViewModel = viewModel(
factory = _root_ide_package_.at.torch.compose.ui.view.model.SearchResultViewModel.Companion.factory(
initialSearchResultType = _root_ide_package_.at.torch.compose.ui.view.model.SearchResultType.Profiles,
factory = at.torch.compose.ui.view.model.SearchResultViewModel.factory(
initialSearchResultType = at.torch.compose.ui.view.model.SearchResultType.Profiles,
searchQuery = searchQuery,
nostrRepository = nostrRepository,
searchRepository = searchRepository
@@ -154,14 +154,14 @@ fun SearchResultScreen(
},
windowInsets = TopAppBarDefaults.windowInsets
) {
val pagerState = rememberPagerState { _root_ide_package_.at.torch.compose.ui.view.model.SearchResultType.entries.size }
val pagerState = rememberPagerState { at.torch.compose.ui.view.model.SearchResultType.entries.size }
PrimaryScrollableTabRow(
modifier = Modifier,
edgePadding = 10.dp,
selectedTabIndex = searchViewModel.searchResultType.ordinal,
) {
_root_ide_package_.at.torch.compose.ui.view.model.SearchResultType.entries.forEach { searchResultType ->
at.torch.compose.ui.view.model.SearchResultType.entries.forEach { searchResultType ->
Tab(
selected = searchViewModel.searchResultType == searchResultType,
onClick = {
@@ -194,14 +194,14 @@ fun SearchResultScreen(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
) {
when(_root_ide_package_.at.torch.compose.ui.view.model.SearchResultType.entries[pageIndex]) {
_root_ide_package_.at.torch.compose.ui.view.model.SearchResultType.Profiles -> {
when(at.torch.compose.ui.view.model.SearchResultType.entries[pageIndex]) {
at.torch.compose.ui.view.model.SearchResultType.Profiles -> {
Text("Profiles")
}
}
when (val searchResultListUIState = searchViewModel.searchResultListUIState) {
_root_ide_package_.at.torch.compose.ui.view.state.SearchResultListUIState.Error -> {
at.torch.compose.ui.view.state.SearchResultListUIState.Error -> {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
@@ -254,7 +254,7 @@ fun SearchResultScreen(
}
}
_root_ide_package_.at.torch.compose.ui.view.state.SearchResultListUIState.Loading -> {
at.torch.compose.ui.view.state.SearchResultListUIState.Loading -> {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
@@ -296,8 +296,8 @@ private fun SearchResultScreenPreview() {
SearchResultScreen(
activeUserPublicKey = "",
searchQuery = "What happened...",
nostrRepository = _root_ide_package_.at.torch.compose.repository.NostrRepository.Companion.NO_OP_NOSTR_REPOSITORY,
searchRepository = _root_ide_package_.at.torch.compose.repository.SearchRepository.Companion.NO_OP_SEARCH_REPOSITORY,
nostrRepository = at.torch.compose.repository.NostrRepository.NO_OP_NOSTR_REPOSITORY,
searchRepository = at.torch.compose.repository.SearchRepository.NO_OP_SEARCH_REPOSITORY,
onNavigateBack = {},
onNavigateToEvent = {}
)
@@ -63,7 +63,7 @@ fun SearchScreen(
onNavigateToProfile: (at.torch.compose.ui.composable.navigation.routes.Route) -> Unit
) {
val searchViewModel: at.torch.compose.ui.view.model.SearchViewModel = viewModel(
factory = _root_ide_package_.at.torch.compose.ui.view.model.SearchViewModel.Companion.factory(
factory = at.torch.compose.ui.view.model.SearchViewModel.factory(
initialSearchUIState = initialSearchUIState,
nostrRepository = nostrRepository,
searchRepository = searchRepository
@@ -235,7 +235,7 @@ fun SearchScreen(
supportingContent = {
Text(
text = profile.staticIdentifier() ?: "",
color = _root_ide_package_.at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(profile.publicKey),
color = at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(profile.publicKey),
maxLines = 1,
)
},
@@ -307,7 +307,7 @@ fun SearchScreen(
Text(
text = profile.humanReadableNameOrPubkey(),
color = _root_ide_package_.at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(profile.publicKey),
color = at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(profile.publicKey),
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelSmall
@@ -407,9 +407,9 @@ private fun SearchScreenPreview() {
) {
SearchScreen(
activeUserPublicKey = "",
initialSearchUIState = _root_ide_package_.at.torch.compose.ui.view.state.SearchUIState.Prompt,
nostrRepository = _root_ide_package_.at.torch.compose.repository.NostrRepository.Companion.NO_OP_NOSTR_REPOSITORY,
searchRepository = _root_ide_package_.at.torch.compose.repository.SearchRepository.Companion.NO_OP_SEARCH_REPOSITORY,
initialSearchUIState = at.torch.compose.ui.view.state.SearchUIState.Prompt,
nostrRepository = at.torch.compose.repository.NostrRepository.NO_OP_NOSTR_REPOSITORY,
searchRepository = at.torch.compose.repository.SearchRepository.NO_OP_SEARCH_REPOSITORY,
onNavigateToSearchResult = {},
onNavigateToProfile = {}
)
@@ -34,11 +34,11 @@ import com.vitorpamplona.quartz.nip19Bech32.entities.NSec
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Composable
fun SignInToProfileScreen(
initialSignInToProfileUIState: at.torch.compose.ui.view.state.SignInToProfileUIState = _root_ide_package_.at.torch.compose.ui.view.state.SignInToProfileUIState.InputPrompt,
initialSignInToProfileUIState: at.torch.compose.ui.view.state.SignInToProfileUIState = at.torch.compose.ui.view.state.SignInToProfileUIState.InputPrompt,
nostrRepository: at.torch.compose.repository.NostrRepository
) {
val signInToProfileViewModel: at.torch.compose.ui.view.model.SignInToProfileViewModel = viewModel (
factory = _root_ide_package_.at.torch.compose.ui.view.model.SignInToProfileViewModel.Companion.factory(
factory = at.torch.compose.ui.view.model.SignInToProfileViewModel.factory(
initialSignInToProfileUIState,
nostrRepository
)
@@ -106,19 +106,19 @@ fun SignInToProfileScreen(
signInToProfileViewModel.signInToProfileUIState.value = signInToProfileViewModel.validateCredential().let { credentialEntity ->
when (credentialEntity) {
is NSec -> {
_root_ide_package_.at.torch.compose.ui.view.state.SignInToProfileUIState.ConfirmNsecSignIn(
at.torch.compose.ui.view.state.SignInToProfileUIState.ConfirmNsecSignIn(
nsec = signInToProfileViewModel.signInToProfileFormState.textField.textFieldState.text.toString(),
hexKey = credentialEntity.hex
)
}
is NPub -> {
_root_ide_package_.at.torch.compose.ui.view.state.SignInToProfileUIState.ConfirmNpubSignIn(
at.torch.compose.ui.view.state.SignInToProfileUIState.ConfirmNpubSignIn(
npub = signInToProfileViewModel.signInToProfileFormState.textField.textFieldState.text.toString(),
hexKey = credentialEntity.hex
)
}
else -> {
_root_ide_package_.at.torch.compose.ui.view.state.SignInToProfileUIState.Error
at.torch.compose.ui.view.state.SignInToProfileUIState.Error
}
}
}
@@ -260,7 +260,7 @@ private fun SignInToProfileScreenPreview() {
) {
SignInToProfileScreen(
initialSignInToProfileUIState =
_root_ide_package_.at.torch.compose.ui.view.state.SignInToProfileUIState.InputPrompt,
at.torch.compose.ui.view.state.SignInToProfileUIState.InputPrompt,
// SignInToProfileUIState.Error,
// SignInToProfileUIState.ConfirmNpubSignIn(
// npub = "npub1uh366qnj68a7atvwgwdy4569xd6v5jtferftapqztwjwlzh9553q47pqsx",
@@ -270,7 +270,7 @@ private fun SignInToProfileScreenPreview() {
// nsec = "nsecthingsaretobekeptsecret",
// hexKey = "e5e3ad0272d1fbeead8e439a4ad3453374ca4969c8d2be84025ba4ef8ae5a522"
// ),
nostrRepository = _root_ide_package_.at.torch.compose.repository.NostrRepository.Companion.NO_OP_NOSTR_REPOSITORY
nostrRepository = at.torch.compose.repository.NostrRepository.NO_OP_NOSTR_REPOSITORY
)
}
}
@@ -35,7 +35,7 @@ fun SovereignWalletStartupScreen(
forceWalletId: WalletId?,
) {
val sovereignWalletStartupViewModel = viewModel<at.torch.compose.ui.view.model.SovereignWalletStartupViewModel>(
factory = _root_ide_package_.at.torch.compose.ui.view.model.SovereignWalletStartupViewModel.Companion.factory(
factory = at.torch.compose.ui.view.model.SovereignWalletStartupViewModel.factory(
phoenixGlobal = sovereignWalletViewModel.phoenixGlobal,
)
)
@@ -28,7 +28,7 @@ fun UnqueuedProfileSynchronizationScreen(
nostrRepository: at.torch.compose.repository.NostrRepository
) {
val unqueuedProfileSynchronizationViewModel: at.torch.compose.ui.view.model.UnqueuedProfileSynchronizationViewModel = viewModel(
factory = _root_ide_package_.at.torch.compose.ui.view.model.UnqueuedProfileSynchronizationViewModel.Companion.factory(
factory = at.torch.compose.ui.view.model.UnqueuedProfileSynchronizationViewModel.factory(
unsignedNostrEventId = unsignedNostrEventId,
profilePublicKey = profilePublicKey,
nostrRepository = nostrRepository
@@ -89,7 +89,7 @@ private fun UnqueuedProfileSynchronizationScreenPreview() {
UnqueuedProfileSynchronizationScreen(
unsignedNostrEventId = 2,
profilePublicKey = "npub is for living.",
nostrRepository = _root_ide_package_.at.torch.compose.repository.NostrRepository.Companion.NO_OP_NOSTR_REPOSITORY
nostrRepository = at.torch.compose.repository.NostrRepository.NO_OP_NOSTR_REPOSITORY
)
}
}
@@ -48,7 +48,7 @@ import kotlin.time.Clock
@Composable
fun WriteNewNoteScreen(
activeUserPublicKey: HexKey,
initialWriteNewNoteUIState: at.torch.compose.ui.view.state.WriteNewNoteUIState = _root_ide_package_.at.torch.compose.ui.view.state.WriteNewNoteUIState.Loading,
initialWriteNewNoteUIState: at.torch.compose.ui.view.state.WriteNewNoteUIState = at.torch.compose.ui.view.state.WriteNewNoteUIState.Loading,
replyToNostrEventId: HexKey?,
quotedNostrEventId: HexKey?,
onNostrEventPublished: () -> Unit,
@@ -56,7 +56,7 @@ fun WriteNewNoteScreen(
nostrRepository: at.torch.compose.repository.NostrRepository
) {
val writeNewNoteViewModel: at.torch.compose.ui.view.model.WriteNewNoteViewModel = viewModel (
factory = _root_ide_package_.at.torch.compose.ui.view.model.WriteNewNoteViewModel.Companion.factory(
factory = at.torch.compose.ui.view.model.WriteNewNoteViewModel.factory(
activeUserPublicKey = activeUserPublicKey,
replyToNostrEventId = replyToNostrEventId,
quotedNostrEventId = quotedNostrEventId,
@@ -175,7 +175,7 @@ fun WriteNewNoteScreen(
},
outputTransformation = OutputTransformation {
val content = originalText.toString()
val nostrProfiles = _root_ide_package_.at.torch.compose.ui.composable.widgets.content.ContentParser.parse(content.trimEnd('\n', '\r'), emptyMap(), emptyMap(), trimBlankLines = true)
val nostrProfiles = at.torch.compose.ui.composable.widgets.content.ContentParser.parse(content.trimEnd('\n', '\r'), emptyMap(), emptyMap(), trimBlankLines = true)
.filterIsInstance<at.torch.compose.ui.composable.widgets.content.ContentSegment.NostrProfileSegment>()
// TODO: We might want to order these profiles by the startIndex so that we can replace the better
@@ -192,7 +192,7 @@ fun WriteNewNoteScreen(
addStyle(
SpanStyle(
color = _root_ide_package_.at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(mentionedProfile.publicKey)
color = at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(mentionedProfile.publicKey)
),
nostrProfile.startIndex,
nostrProfile.startIndex + profileMention.length
@@ -452,7 +452,7 @@ private fun WriteNewNoteScreenPreview() {
replyToNostrEventId = null,
quotedNostrEventId = null,
initialWriteNewNoteUIState =
_root_ide_package_.at.torch.compose.ui.view.state.WriteNewNoteUIState.InputPrompt(
at.torch.compose.ui.view.state.WriteNewNoteUIState.InputPrompt(
// text = "Yes, I did it. So WHAT?!",
inReplyToNostrEvent = _root_ide_package_.at.torch.compose.database.model.intermdiate.LocalNostrEvent(
nostrEvent = _root_ide_package_.at.torch.compose.database.model.NostrEvent(
@@ -497,7 +497,7 @@ It has survived not only five centuries, but also the leap into electronic types
),
onNostrEventPublished = {},
onNavigateToNostrEvent = {},
nostrRepository = _root_ide_package_.at.torch.compose.repository.NostrRepository.Companion.NO_OP_NOSTR_REPOSITORY
nostrRepository = at.torch.compose.repository.NostrRepository.NO_OP_NOSTR_REPOSITORY
)
}
}
@@ -16,6 +16,7 @@ import at.torch.compose.database.repository.DatabaseMarmotRepository
import at.torch.compose.ui.composable.ChatRoomCreationScreen
import at.torch.compose.ui.composable.ChatRoomDetailScreen
import at.torch.compose.ui.composable.HomeScreen
import at.torch.compose.ui.composable.UnsyncedProfileScreen
import at.torch.compose.ui.composable.navigation.routes.ChatRoomCreationRoute
import at.torch.compose.ui.composable.navigation.routes.WriteNewNoteRoute
import co.touchlab.kermit.Logger
@@ -69,14 +70,14 @@ fun TorchNavHost(
database = auxDatabaseManager.auxDatabase
)
val sovereignWalletViewModel: at.torch.compose.ui.view.model.SovereignWalletViewModel = viewModel(factory = _root_ide_package_.at.torch.compose.ui.view.model.SovereignWalletViewModel.Companion.factory(
val sovereignWalletViewModel: at.torch.compose.ui.view.model.SovereignWalletViewModel = viewModel(factory = at.torch.compose.ui.view.model.SovereignWalletViewModel.factory(
phoenixGlobal = phoenixGlobal
))
val navigationViewModel: at.torch.compose.ui.view.model.NavigationViewModel = viewModel (
factory = _root_ide_package_.at.torch.compose.ui.view.model.NavigationViewModel.Companion.factory(
factory = at.torch.compose.ui.view.model.NavigationViewModel.factory(
activeWallet = sovereignWalletViewModel.activeWalletInUI,
initialNavigationUIState = _root_ide_package_.at.torch.compose.ui.view.state.NavigationUIState.Loading(),
initialNavigationUIState = at.torch.compose.ui.view.state.NavigationUIState.Loading(),
nostrRepository = databaseNostrRepository,
scope = applicationIOScope
)
@@ -84,7 +85,7 @@ fun TorchNavHost(
val notaryViewModel: at.torch.compose.ui.view.model.NotaryViewModel = viewModel(
factory = _root_ide_package_.at.torch.compose.ui.view.model.NotaryViewModel.Companion.factory(
factory = at.torch.compose.ui.view.model.NotaryViewModel.Companion.factory(
activeWalletStateFlow = sovereignWalletViewModel.activeWalletInUI,
nostrRepository = databaseNostrRepository,
chatRepository = databaseChatRepository,
@@ -93,7 +94,7 @@ fun TorchNavHost(
)
// TODO: Produce a notary UI Element...
val synchronizationViewModel: at.torch.compose.ui.view.model.SynchronizationViewModel = viewModel(
factory = _root_ide_package_.at.torch.compose.ui.view.model.SynchronizationViewModel.Companion.factory(
factory = at.torch.compose.ui.view.model.SynchronizationViewModel.Companion.factory(
activeWalletStateFlow = sovereignWalletViewModel.activeWalletInUI,
nostrRepository = databaseNostrRepository,
chatRepository = databaseChatRepository,
@@ -117,7 +118,7 @@ fun TorchNavHost(
}
is at.torch.compose.ui.view.state.NavigationUIState.StartupPhoenix -> {
navController.navigate(
route = _root_ide_package_.at.torch.compose.ui.composable.navigation.routes.SovereignWalletStartupRoute
route = at.torch.compose.ui.composable.navigation.routes.SovereignWalletStartupRoute
) {
popUpTo(0)
}
@@ -133,7 +134,7 @@ fun TorchNavHost(
}
is at.torch.compose.ui.view.state.NavigationUIState.Landing -> {
navController.navigate(
route = _root_ide_package_.at.torch.compose.ui.composable.navigation.routes.LandingRoute
route = at.torch.compose.ui.composable.navigation.routes.LandingRoute
) {
popUpTo(0)
}
@@ -229,7 +230,7 @@ fun TorchNavHost(
},
onNavigateToWalletIntroPage = {
navController.navigate(
route = _root_ide_package_.at.torch.compose.ui.composable.navigation.routes.LandingRoute
route = at.torch.compose.ui.composable.navigation.routes.LandingRoute
)
},
onNavigateToWalletDashboard = {
@@ -260,7 +261,7 @@ fun TorchNavHost(
},
onNavigateToSignIn = {
navController.navigate(
route = _root_ide_package_.at.torch.compose.ui.composable.navigation.routes.SignInRoute
route = at.torch.compose.ui.composable.navigation.routes.SignInRoute
)
},
onNavigateToCreateProfile = {
@@ -274,7 +275,7 @@ fun TorchNavHost(
_root_ide_package_.at.torch.compose.ui.composable.CreateProfileScreen(
onNavigateToEndThis = {
navController.navigate(
route = _root_ide_package_.at.torch.compose.ui.composable.navigation.routes.BlankRoute
route = at.torch.compose.ui.composable.navigation.routes.BlankRoute
) {
popUpTo(0)
}
@@ -291,7 +292,7 @@ fun TorchNavHost(
sovereignWalletViewModel.listAvailableWallets {
sovereignWalletViewModel.switchToWallet(walletId)
navController.navigate(
route = _root_ide_package_.at.torch.compose.ui.composable.navigation.routes.SovereignWalletStartupRoute
route = at.torch.compose.ui.composable.navigation.routes.SovereignWalletStartupRoute
)
}
}
@@ -344,13 +345,13 @@ fun TorchNavHost(
)
}
composable<at.torch.compose.ui.composable.navigation.routes.UnsignedProfileRoute> { backStackEntry ->
val route = backStackEntry.toRoute<at.torch.compose.ui.composable.navigation.routes.UnsignedProfileRoute>()
backStackEntry.toRoute<at.torch.compose.ui.composable.navigation.routes.UnsignedProfileRoute>()
_root_ide_package_.at.torch.compose.ui.composable.UnsignedProfileScreen()
}
composable<at.torch.compose.ui.composable.navigation.routes.UnsyncedProfileRoute> { backStackEntry ->
val route = backStackEntry.toRoute<at.torch.compose.ui.composable.navigation.routes.UnsyncedProfileRoute>()
_root_ide_package_.at.torch.compose.ui.composable.UnsyncedProfileScreen(
UnsyncedProfileScreen(
unsyncedProfilePublicKey = route.publicKey
)
}
@@ -369,7 +370,7 @@ fun TorchNavHost(
_root_ide_package_.at.torch.compose.ui.composable.UnqueuedProfileScreen()
}
composable<at.torch.compose.ui.composable.navigation.routes.UnannouncedProfileRoute> { backStackEntry ->
val route = backStackEntry.toRoute<at.torch.compose.ui.composable.navigation.routes.UnannouncedProfileRoute>()
backStackEntry.toRoute<at.torch.compose.ui.composable.navigation.routes.UnannouncedProfileRoute>()
_root_ide_package_.at.torch.compose.ui.composable.UnannouncedProfileScreen()
}
@@ -455,7 +456,7 @@ fun TorchNavHost(
_root_ide_package_.at.torch.compose.ui.composable.SearchScreen(
activeUserPublicKey = route.activeUserPublicKey,
initialSearchUIState = _root_ide_package_.at.torch.compose.ui.view.state.SearchUIState.Prompt,
initialSearchUIState = at.torch.compose.ui.view.state.SearchUIState.Prompt,
nostrRepository = databaseNostrRepository,
searchRepository = searchRepository,
onNavigateToProfile = { route ->
@@ -493,7 +494,7 @@ fun TorchNavHost(
_root_ide_package_.at.torch.compose.ui.composable.NostrEventDetailScreen(
activeUserPublicKey = route.activeUserPublicKey,
initialNostrEventDetailUIState = _root_ide_package_.at.torch.compose.ui.view.state.NostrEventDetailUIState.Loading,
initialNostrEventDetailUIState = at.torch.compose.ui.view.state.NostrEventDetailUIState.Loading,
nostrEventId = route.nostrEventId,
nostrRepository = databaseNostrRepository,
onNavigateBack = {
@@ -3,5 +3,4 @@ package at.torch.compose.ui.composable.navigation.routes
import kotlinx.serialization.Serializable
@Serializable
data object AuthenticatedProfileRoute {
}
data object AuthenticatedProfileRoute
@@ -5,5 +5,4 @@ import kotlinx.serialization.Serializable
@Serializable
data class ChatRoomCreationRoute(
val activeUserPublicKey: String,
): Route() {
}
): Route()
@@ -7,5 +7,4 @@ data class ChatRoomDetailRoute(
val activeUserPublicKey: String,
val chatRoomId: String, // TODO: have this as a publicKey
val relayHint: String?
): Route() {
}
): Route()
@@ -5,5 +5,4 @@ import kotlinx.serialization.Serializable
@Serializable
data class CreateProfileRoute(
val nostrEventId: String? = null,
): Route() {
}
): Route()
@@ -5,5 +5,4 @@ import kotlinx.serialization.Serializable
@Serializable
data class ImplementationPendingRoute(
val name: String
): Route() {
}
): Route()
@@ -6,5 +6,4 @@ import kotlinx.serialization.Serializable
data class NostrEventDetailRoute(
val activeUserPublicKey: String,
val nostrEventId: String,
): Route() {
}
): Route()
@@ -5,5 +5,4 @@ import kotlinx.serialization.Serializable
@Serializable
data class UnannouncedProfileRoute(
val nostrEventId: String,
): Route() {
}
): Route()
@@ -5,6 +5,4 @@ import kotlinx.serialization.Serializable
@Serializable
data class UnindexedProfileRoute(
val nostrEventId: String,
): Route() {
}
): Route()
@@ -5,6 +5,4 @@ import kotlinx.serialization.Serializable
@Serializable
data class UnqueuedProfileRoute(
val nostrEventId: String,
): Route() {
}
): Route()
@@ -6,5 +6,4 @@ import kotlinx.serialization.Serializable
data class UnqueuedProfileSynchronizationRoute(
val publicKey: String,
val unsignedNostrEventId: Long,
): Route() {
}
): Route()
@@ -5,5 +5,4 @@ import kotlinx.serialization.Serializable
@Serializable
data class UnsignedProfileRoute(
val unsignedNostrEventId: Long,
): Route() {
}
): Route()
@@ -5,5 +5,4 @@ import kotlinx.serialization.Serializable
@Serializable
data class UnsyncedProfileRoute(
val publicKey: String,
): Route() {
}
): Route()
@@ -7,5 +7,4 @@ data class WriteNewNoteRoute(
val activeUserPublicKey: String,
val inReplyToEventId: String? = null,
val quotedEventId: String? = null,
): Route() {
}
): Route()
@@ -41,7 +41,7 @@ private fun ArticleCard(
val title = remember(event) { event.tags?.firstOrNull { it.size >= 2 && it[0] == "title" }?.get(1) }
val summary = remember(event) { event.tags?.firstOrNull { it.size >= 2 && it[0] == "summary" }?.get(1) }
val image = remember(event) { event.tags?.firstOrNull { it.size >= 2 && it[0] == "image" }?.get(1) }
remember(event) { event.tags?.firstOrNull { it.size >= 2 && it[0] == "image" }?.get(1) }
val publishedAt = remember(event) { event.tags?.firstOrNull { it.size >= 2 && it[0] == "published_at" }?.get(1)?.toLongOrNull() }
Surface(
@@ -146,7 +146,7 @@ private fun ArticleCard(
if (publishedAt != null) {
Text(
text = " \u00b7 ${
_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Helpers.formatQuotedTimestamp(
Helpers.formatQuotedTimestamp(
publishedAt
)
}",
@@ -31,7 +31,7 @@ internal object ContentParser {
val url = "https://$bareDomainCapture"
val meta = imetaMap[url]
val imetaMime = meta?.mime?.let {
_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Helpers.classifyByMime(
Helpers.classifyByMime(
it
)
}
@@ -40,13 +40,13 @@ internal object ContentParser {
imetaMime == "image" -> segments.add(ContentSegment.ImageSegment(meta!!))
imetaMime == "video" -> segments.add(ContentSegment.VideoSegment(meta!!))
imetaMime == "audio" -> segments.add(ContentSegment.AudioSegment(meta!!))
ext in _root_ide_package_.at.torch.compose.ui.composable.widgets.content.Constants.imageExtensions -> segments.add(ContentSegment.ImageSegment(meta ?: MediaMeta(url)))
ext in _root_ide_package_.at.torch.compose.ui.composable.widgets.content.Constants.videoExtensions -> segments.add(ContentSegment.VideoSegment(meta ?: MediaMeta(url)))
ext in _root_ide_package_.at.torch.compose.ui.composable.widgets.content.Constants.audioExtensions -> segments.add(ContentSegment.AudioSegment(meta ?: MediaMeta(url)))
_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Helpers.isBlossomUrl(
ext in Constants.imageExtensions -> segments.add(ContentSegment.ImageSegment(meta ?: MediaMeta(url)))
ext in Constants.videoExtensions -> segments.add(ContentSegment.VideoSegment(meta ?: MediaMeta(url)))
ext in Constants.audioExtensions -> segments.add(ContentSegment.AudioSegment(meta ?: MediaMeta(url)))
Helpers.isBlossomUrl(
url
) -> segments.add(ContentSegment.UnknownMediaSegment(meta ?: MediaMeta(url)))
_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Helpers.isStandaloneUrl(
Helpers.isStandaloneUrl(
content,
match.range
) -> segments.add(ContentSegment.LinkSegment(url))
@@ -97,7 +97,7 @@ internal object ContentParser {
val isWebSocket = url.startsWith("wss://") || url.startsWith("ws://")
val meta = imetaMap[url]
val imetaMime = meta?.mime?.let {
_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Helpers.classifyByMime(
Helpers.classifyByMime(
it
)
}
@@ -106,9 +106,9 @@ internal object ContentParser {
imetaMime == "image" -> segments.add(ContentSegment.ImageSegment(meta!!))
imetaMime == "video" -> segments.add(ContentSegment.VideoSegment(meta!!))
imetaMime == "audio" -> segments.add(ContentSegment.AudioSegment(meta!!))
ext in _root_ide_package_.at.torch.compose.ui.composable.widgets.content.Constants.imageExtensions -> segments.add(ContentSegment.ImageSegment(meta ?: MediaMeta(url)))
ext in _root_ide_package_.at.torch.compose.ui.composable.widgets.content.Constants.videoExtensions -> segments.add(ContentSegment.VideoSegment(meta ?: MediaMeta(url)))
ext in _root_ide_package_.at.torch.compose.ui.composable.widgets.content.Constants.audioExtensions -> segments.add(ContentSegment.AudioSegment(meta ?: MediaMeta(url)))
ext in Constants.imageExtensions -> segments.add(ContentSegment.ImageSegment(meta ?: MediaMeta(url)))
ext in Constants.videoExtensions -> segments.add(ContentSegment.VideoSegment(meta ?: MediaMeta(url)))
ext in Constants.audioExtensions -> segments.add(ContentSegment.AudioSegment(meta ?: MediaMeta(url)))
// TODO: Support websockets
// isWebSocket && '\'' in url -> {
// val parsed = Nip29.parseGroupIdentifier(url)
@@ -116,10 +116,10 @@ internal object ContentParser {
// else segments.add(ContentSegment.InlineLinkSegment(url))
// }
isWebSocket -> segments.add(ContentSegment.InlineLinkSegment(url))
_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Helpers.isBlossomUrl(
Helpers.isBlossomUrl(
url
) -> segments.add(ContentSegment.UnknownMediaSegment(meta ?: MediaMeta(url)))
_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Helpers.isStandaloneUrl(
Helpers.isStandaloneUrl(
content,
match.range
) -> segments.add(ContentSegment.LinkSegment(url))
@@ -141,7 +141,7 @@ internal object ContentParser {
for (segment in segments) {
if (segment is ContentSegment.TextSegment) {
result.addAll(
_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Helpers.splitTextForEmojis(
Helpers.splitTextForEmojis(
segment.text,
emojiMap
)
@@ -158,7 +158,7 @@ internal object ContentParser {
for (segment in afterEmoji) {
if (segment is ContentSegment.TextSegment) {
finalResult.addAll(
_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Helpers.splitTextForInvoices(
Helpers.splitTextForInvoices(
segment.text
)
)
@@ -56,7 +56,7 @@ fun FullScreenImageViewer(
}
val clipboardManager = LocalClipboardManager.current
val scope = rememberCoroutineScope()
rememberCoroutineScope()
Box(
modifier = Modifier
@@ -16,7 +16,7 @@ internal object Helpers {
return try {
val uri = Url(url)
val path = uri.fullPath ?: return false
_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Constants.blossomPathRegex.matches(path)
Constants.blossomPathRegex.matches(path)
} catch (_: Exception) {
false
}
@@ -33,23 +33,21 @@ internal object Helpers {
val after = content.substring(matchRange.last + 1)
val lineEnd = after.indexOf('\n')
val suffix = if (lineEnd == -1) after else after.substring(0, lineEnd)
if (suffix.isNotBlank()) return false
return true
return suffix.isBlank()
}
fun classifyByMime(mime: String): String? = when {
_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Constants.imageMimeTypes.any { mime.startsWith(it) } -> "image"
_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Constants.videoMimeTypes.any { mime.startsWith(it) } -> "video"
_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Constants.audioMimeTypes.any { mime.startsWith(it) } -> "audio"
Constants.imageMimeTypes.any { mime.startsWith(it) } -> "image"
Constants.videoMimeTypes.any { mime.startsWith(it) } -> "video"
Constants.audioMimeTypes.any { mime.startsWith(it) } -> "audio"
else -> null
}
fun splitTextForEmojis(text: String, emojiMap: Map<String, String>): List<ContentSegment> {
val result = mutableListOf<ContentSegment>()
var lastEnd = 0
for (match in _root_ide_package_.at.torch.compose.ui.composable.widgets.content.Constants.emojiShortcodeRegex.findAll(text)) {
for (match in Constants.emojiShortcodeRegex.findAll(text)) {
val shortcode = match.groupValues[1]
val url = emojiMap[shortcode] ?: continue
if (match.range.first > lastEnd) {
@@ -67,7 +65,7 @@ internal object Helpers {
}
fun splitTextForInvoices(text: String): List<ContentSegment> {
val matches = _root_ide_package_.at.torch.compose.ui.composable.widgets.content.Constants.bolt11Regex.findAll(text).toList()
val matches = Constants.bolt11Regex.findAll(text).toList()
if (matches.isEmpty()) return listOf(ContentSegment.TextSegment(text))
val result = mutableListOf<ContentSegment>()
var lastEnd = 0
@@ -111,7 +109,7 @@ internal object Helpers {
}
suspend fun fetchOgData(url: String): OgData? = withContext(Dispatchers.IO) {
_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Constants.ogCache.get(url)?.let { return@withContext it }
Constants.ogCache.get(url)?.let { return@withContext it }
null
// TODO: YouTube blocks bot User-Agents; use their oEmbed API instead
@@ -32,7 +32,7 @@ import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.dp
@kotlin.OptIn(ExperimentalFoundationApi::class)
@OptIn(ExperimentalFoundationApi::class)
@Composable
internal fun ImageWithContextMenu(meta: MediaMeta, onFullScreen: () -> Unit) {
val url = meta.url
@@ -27,13 +27,13 @@ import io.ktor.http.Url
@Composable
internal fun LinkPreview(url: String) {
var ogData by remember(url) { mutableStateOf(_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Constants.ogCache.get(url)) }
var ogData by remember(url) { mutableStateOf(Constants.ogCache.get(url)) }
val uriHandler = LocalUriHandler.current
LaunchedEffect(url) {
if (ogData == null) {
ogData =
_root_ide_package_.at.torch.compose.ui.composable.widgets.content.Helpers.fetchOgData(
Helpers.fetchOgData(
url
)
}
@@ -170,7 +170,7 @@ fun RichContent(
}
is ContentSegment.CustomEmojiSegment -> {
pushStringAnnotation(
tag = _root_ide_package_.at.torch.compose.ui.composable.widgets.content.Constants.INLINE_CONTENT_TAG,
tag = Constants.INLINE_CONTENT_TAG,
annotation = seg.shortcode
)
append(":${seg.shortcode}:")
@@ -197,7 +197,7 @@ fun RichContent(
onProfileClick?.invoke(pubkey)
}
) {
withStyle(SpanStyle(color = _root_ide_package_.at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(seg.pubkey), textDecoration = linkDecoration)) {
withStyle(SpanStyle(color = at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(seg.pubkey), textDecoration = linkDecoration)) {
append("@${displayName.trimEnd()}")
}
}
@@ -244,8 +244,7 @@ fun RichContent(
Text(text = annotated, style = style, inlineContent = emojiInlineContent)
} else {
val segment = group as ContentSegment
when (segment) {
when (val segment = group as ContentSegment) {
is ContentSegment.ImageSegment -> {
ImageWithContextMenu(
meta = segment.meta,
@@ -63,11 +63,11 @@ fun MetadataEventDetail(
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(rememberTopAppBarState())
val metadataEventDetailViewModel: at.torch.compose.ui.view.model.MetadataEventDetailViewModel = viewModel(
factory = _root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailViewModel.Companion.factory(
factory = at.torch.compose.ui.view.model.MetadataEventDetailViewModel.factory(
activeUserPublicKey = activeUserPublicKey,
publicKey = localNostrEvent.nostrEvent.pubKey,
nostrRepository = nostrRepository,
pagerState = rememberPagerState { _root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailType.entries.size }
pagerState = rememberPagerState { at.torch.compose.ui.view.model.MetadataEventDetailType.entries.size }
),
)
@@ -150,7 +150,7 @@ fun MetadataEventDetail(
)
when(val metadataEventDetailUIState = metadataEventDetailViewModel.metadataEventDetailUIState) {
_root_ide_package_.at.torch.compose.ui.view.state.MetadataEventDetailUIState.Error -> {
at.torch.compose.ui.view.state.MetadataEventDetailUIState.Error -> {
Icon(
Icons.Default.Error,
contentDescription = "Something went wrong"
@@ -203,7 +203,7 @@ fun MetadataEventDetail(
}
_root_ide_package_.at.torch.compose.ui.view.state.MetadataEventDetailUIState.Loading -> {
at.torch.compose.ui.view.state.MetadataEventDetailUIState.Loading -> {
LoadingIndicator()
}
}
@@ -246,7 +246,7 @@ fun MetadataEventDetail(
edgePadding = 10.dp,
selectedTabIndex = metadataEventDetailViewModel.pagerState.currentPage,
) {
_root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailType.entries.forEachIndexed { index, destination ->
at.torch.compose.ui.view.model.MetadataEventDetailType.entries.forEachIndexed { index, destination ->
Tab(
selected = metadataEventDetailViewModel.pagerState.currentPage == index,
onClick = {
@@ -273,17 +273,17 @@ fun MetadataEventDetail(
HorizontalPager(
state = metadataEventDetailViewModel.pagerState,
) { pageIndex ->
val metadataEventDetailType = _root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailType.entries[pageIndex]
val metadataEventDetailType = at.torch.compose.ui.view.model.MetadataEventDetailType.entries[pageIndex]
when (metadataEventDetailType) {
_root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailType.Posts, _root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailType.Replies,
_root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailType.Articles, _root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailType.Zaps,
_root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailType.Photos, _root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailType.Shorts, _root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailType.Videos,
_root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailType.Bookmarks, _root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailType.Reports, _root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailType.Relays -> {
at.torch.compose.ui.view.model.MetadataEventDetailType.Posts, at.torch.compose.ui.view.model.MetadataEventDetailType.Replies,
at.torch.compose.ui.view.model.MetadataEventDetailType.Articles, at.torch.compose.ui.view.model.MetadataEventDetailType.Zaps,
at.torch.compose.ui.view.model.MetadataEventDetailType.Photos, at.torch.compose.ui.view.model.MetadataEventDetailType.Shorts, at.torch.compose.ui.view.model.MetadataEventDetailType.Videos,
at.torch.compose.ui.view.model.MetadataEventDetailType.Bookmarks, at.torch.compose.ui.view.model.MetadataEventDetailType.Reports, at.torch.compose.ui.view.model.MetadataEventDetailType.Relays -> {
val feedListViewModel: at.torch.compose.ui.view.model.FeedListViewModel = viewModel(
key = metadataEventDetailType.name,
factory = _root_ide_package_.at.torch.compose.ui.view.model.FeedListViewModel.Companion.factory(
initialFeedListUIState = _root_ide_package_.at.torch.compose.ui.view.state.FeedListUIState.Loading,
factory = at.torch.compose.ui.view.model.FeedListViewModel.factory(
initialFeedListUIState = at.torch.compose.ui.view.state.FeedListUIState.Loading,
synchronizationFilter = metadataEventDetailViewModel.getSynchronizationFilter(metadataEventDetailType),
nostrRepository = nostrRepository
),
@@ -301,11 +301,11 @@ fun MetadataEventDetail(
}
}
// TODO: Support gallery feeds...
_root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailType.Following -> {
at.torch.compose.ui.view.model.MetadataEventDetailType.Following -> {
val followingListViewModel: at.torch.compose.ui.view.model.FollowingListViewModel = viewModel(
key = metadataEventDetailType.name,
factory = _root_ide_package_.at.torch.compose.ui.view.model.FollowingListViewModel.Companion.factory(
initialFeedListUIState = _root_ide_package_.at.torch.compose.ui.view.state.FollowingListUIState.Loading,
factory = at.torch.compose.ui.view.model.FollowingListViewModel.factory(
initialFeedListUIState = at.torch.compose.ui.view.state.FollowingListUIState.Loading,
publicKey = localNostrEvent.nostrEvent.pubKey,
synchronizationFilter = metadataEventDetailViewModel.getSynchronizationFilter(metadataEventDetailType),
nostrRepository = nostrRepository
@@ -324,11 +324,11 @@ fun MetadataEventDetail(
followingListViewModel.initiate()
}
}
_root_ide_package_.at.torch.compose.ui.view.model.MetadataEventDetailType.Followers -> {
at.torch.compose.ui.view.model.MetadataEventDetailType.Followers -> {
val followersListViewModel: at.torch.compose.ui.view.model.FollowersListViewModel = viewModel(
key = metadataEventDetailType.name,
factory = _root_ide_package_.at.torch.compose.ui.view.model.FollowersListViewModel.Companion.factory(
initialFeedListUIState = _root_ide_package_.at.torch.compose.ui.view.state.FollowersListUIState.Loading,
factory = at.torch.compose.ui.view.model.FollowersListViewModel.factory(
initialFeedListUIState = at.torch.compose.ui.view.state.FollowersListUIState.Loading,
publicKey = localNostrEvent.nostrEvent.pubKey,
synchronizationFilter = metadataEventDetailViewModel.getSynchronizationFilter(metadataEventDetailType),
nostrRepository = nostrRepository
@@ -391,7 +391,7 @@ private fun MetadataEventEventDetailPreview() {
onNavigateToEvent = {},
onNavigateToEditProfile = {},
onNavigateToChatRoom = {},
nostrRepository = _root_ide_package_.at.torch.compose.repository.NostrRepository.Companion.NO_OP_NOSTR_REPOSITORY
nostrRepository = at.torch.compose.repository.NostrRepository.NO_OP_NOSTR_REPOSITORY
)
}
}
@@ -61,10 +61,10 @@ fun TextNoteEventDetail(
val inReplyToNostrEventFeedListViewModel: at.torch.compose.ui.view.model.InReplyToViewModel = viewModel(
key = "replies-${localNostrEvent.nostrEvent.id}",
factory = _root_ide_package_.at.torch.compose.ui.view.model.InReplyToViewModel.Companion.factory(
factory = at.torch.compose.ui.view.model.InReplyToViewModel.factory(
nostrEvent = localNostrEvent.nostrEvent,
profile = localNostrEvent.profile,
initialFeedListUIState = _root_ide_package_.at.torch.compose.ui.view.state.FeedListUIState.Loading,
initialFeedListUIState = at.torch.compose.ui.view.state.FeedListUIState.Loading,
nostrRepository = nostrRepository,
createdAt = localNostrEvent.nostrEvent.createdAt
),
@@ -118,7 +118,7 @@ fun TextNoteEventDetail(
Icon(
Icons.Default.Person,
contentDescription = "User profile",
tint = _root_ide_package_.at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey("profile")
tint = at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey("profile")
)
// ProfileAvatar(
// profile = localProfile.profile,
@@ -219,7 +219,7 @@ fun TextNoteEventDetail(
Text(
text = staticIdentifier,
style = MaterialTheme.typography.labelMedium,
color = _root_ide_package_.at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromProfile(
color = at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromProfile(
profile
)
)
@@ -354,14 +354,14 @@ fun TextNoteEventDetail(
}
}
}
_root_ide_package_.at.torch.compose.ui.view.state.FeedListUIState.Error -> {
at.torch.compose.ui.view.state.FeedListUIState.Error -> {
item {
Text(
text = "Something went wrong"
)
}
}
_root_ide_package_.at.torch.compose.ui.view.state.FeedListUIState.Loading -> {
at.torch.compose.ui.view.state.FeedListUIState.Loading -> {
item {
LoadingIndicator()
}
@@ -408,7 +408,7 @@ It has survived not only five centuries, but also the leap into electronic types
onNavigateBack = {},
onNavigateToWriteAReply = {},
onNavigateToNostrEvent = {},
nostrRepository = _root_ide_package_.at.torch.compose.repository.NostrRepository.Companion.NO_OP_NOSTR_REPOSITORY
nostrRepository = at.torch.compose.repository.NostrRepository.NO_OP_NOSTR_REPOSITORY
)
}
}
@@ -60,7 +60,7 @@ fun at.torch.compose.database.model.intermdiate.LocalNostrEvent.ListView(
Text(
text = profile?.humanReadableNameOrPubkey() ?: nostrEvent.pubKey,
style = MaterialTheme.typography.labelSmall,
color = _root_ide_package_.at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(profile?.publicKey ?: nostrEvent.pubKey)
color = at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(profile?.publicKey ?: nostrEvent.pubKey)
)
Text(
text = "reposted",
@@ -59,7 +59,7 @@ internal fun TextNoteFeedItem(
}
),
style = MaterialTheme.typography.labelLargeEmphasized,
color = _root_ide_package_.at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(localInReplyToNostrEvent.nostrEvent.pubKey),
color = at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(localInReplyToNostrEvent.nostrEvent.pubKey),
text = localInReplyToNostrEvent.profile?.humanReadableNameOrPubkey() ?: "loading information..."
)
}
@@ -105,7 +105,7 @@ internal fun TextNoteFeedItem(
Text(
text = staticIdentifier,
style = MaterialTheme.typography.bodySmall,
color = _root_ide_package_.at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromProfile(profile)
color = at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromProfile(profile)
)
}
}
@@ -76,7 +76,7 @@ class ChatRoomDetailMessageListViewModel(
localChatRoom.chatRoom.id
).distinctUntilChanged().collect { chatMessages ->
logger.d("getChatMessageListByChatRoomId: $chatMessages")
chatRoomDetailMessageListUIState = _root_ide_package_.at.torch.compose.ui.view.state.ChatRoomDetailMessageListUIState.Loaded(
chatRoomDetailMessageListUIState = at.torch.compose.ui.view.state.ChatRoomDetailMessageListUIState.Loaded(
chatMessageList = chatMessages
)
}
@@ -112,7 +112,7 @@ class ChatRoomDetailMessageListViewModel(
isReceiverChatMessageRelayListMissing.value = true
// TODO: compute the timestamp for when list we sent messages and use that as since...
Pair(
_root_ide_package_.at.torch.compose.nostr.Relays.negentropicRelaySet,
at.torch.compose.nostr.Relays.negentropicRelaySet,
_root_ide_package_.at.torch.compose.database.model.types.SynchronizationFilter(
kinds = arrayOf(
ChatMessageRelayListEvent.KIND,
@@ -129,7 +129,7 @@ class ChatRoomDetailMessageListViewModel(
val negentropySynchronizeRequests = relayAndSynchronizationFilter.first.map { normalizedRelayUrl ->
_root_ide_package_.at.torch.compose.database.model.NegentropySynchronizeRequest(
id = _root_ide_package_.at.torch.compose.database.model.NegentropySynchronizeRequest.Companion.computeId(
id = at.torch.compose.database.model.NegentropySynchronizeRequest.computeId(
relayURL = normalizedRelayUrl.url,
synchronizationFilter = relayAndSynchronizationFilter.second
),
@@ -161,7 +161,7 @@ class ChatRoomDetailMessageListViewModel(
horizontalAlignment = Alignment.CenterHorizontally
) {
when (val chatRoomDetailMessageListUIState = this@ChatRoomDetailMessageListViewModel.chatRoomDetailMessageListUIState) {
_root_ide_package_.at.torch.compose.ui.view.state.ChatRoomDetailMessageListUIState.Error -> {
at.torch.compose.ui.view.state.ChatRoomDetailMessageListUIState.Error -> {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
@@ -286,7 +286,7 @@ class ChatRoomDetailMessageListViewModel(
text = localChatMessage.profile?.humanReadableNameOrPubkey() ?: localChatMessage.chatMessage.senderPublicKey,
maxLines = 1,
overflow = TextOverflow.MiddleEllipsis,
color = _root_ide_package_.at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(localChatMessage.chatMessage.senderPublicKey),
color = at.torch.compose.ui.composable.widgets.profile.ProfileColor.fromPublicKey(localChatMessage.chatMessage.senderPublicKey),
style = MaterialTheme.typography.labelSmall
)
}
@@ -342,7 +342,7 @@ class ChatRoomDetailMessageListViewModel(
}
}
}
_root_ide_package_.at.torch.compose.ui.view.state.ChatRoomDetailMessageListUIState.Loading -> {
at.torch.compose.ui.view.state.ChatRoomDetailMessageListUIState.Loading -> {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
@@ -384,7 +384,7 @@ class ChatRoomDetailMessageListViewModel(
const val TAG = "ChatRoomDetailMessageListViewModel"
fun factory(
initialChatRoomDetailMessageListUIState: at.torch.compose.ui.view.state.ChatRoomDetailMessageListUIState = _root_ide_package_.at.torch.compose.ui.view.state.ChatRoomDetailMessageListUIState.Loading,
initialChatRoomDetailMessageListUIState: at.torch.compose.ui.view.state.ChatRoomDetailMessageListUIState = at.torch.compose.ui.view.state.ChatRoomDetailMessageListUIState.Loading,
localChatRoom: at.torch.compose.database.model.intermdiate.LocalChatRoom,
nostrRepository: at.torch.compose.repository.NostrRepository,
chatRepository: at.torch.compose.repository.ChatRepository
@@ -54,7 +54,7 @@ class ChatRoomListViewModel(
publicKey
).collect { chatRooms ->
logger.d("ChatRoomList: $chatRooms")
chatRoomListUIState = _root_ide_package_.at.torch.compose.ui.view.state.ChatRoomListUIState.Loaded(
chatRoomListUIState = at.torch.compose.ui.view.state.ChatRoomListUIState.Loaded(
chatRoomList = chatRooms
)
}
@@ -66,9 +66,9 @@ class ChatRoomListViewModel(
viewModelScope.launch(Dispatchers.IO) {
// Sync Notifications... might want to also run this in the background
nostrRepository.queueNegentropySynchronizeRequest(
_root_ide_package_.at.torch.compose.nostr.Relays.DefaultDMRelayList.shuffled().map { normalizedRelayUrl ->
at.torch.compose.nostr.Relays.DefaultDMRelayList.shuffled().map { normalizedRelayUrl ->
_root_ide_package_.at.torch.compose.database.model.NegentropySynchronizeRequest(
id = _root_ide_package_.at.torch.compose.database.model.NegentropySynchronizeRequest.Companion.computeId(
id = at.torch.compose.database.model.NegentropySynchronizeRequest.computeId(
relayURL = normalizedRelayUrl.url,
synchronizationFilter = synchronizationFilter
),
@@ -92,7 +92,7 @@ class ChatRoomListViewModel(
horizontalAlignment = Alignment.CenterHorizontally
) {
when (val chatRoomListUIState = chatRoomListUIState) {
_root_ide_package_.at.torch.compose.ui.view.state.ChatRoomListUIState.Error -> {
at.torch.compose.ui.view.state.ChatRoomListUIState.Error -> {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
@@ -149,7 +149,7 @@ class ChatRoomListViewModel(
}
}
}
_root_ide_package_.at.torch.compose.ui.view.state.ChatRoomListUIState.Loading -> {
at.torch.compose.ui.view.state.ChatRoomListUIState.Loading -> {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
@@ -176,7 +176,7 @@ class ChatRoomListViewModel(
const val TAG = "ChatRoomListViewModel"
fun factory(
initialChatRoomListUIState: at.torch.compose.ui.view.state.ChatRoomListUIState = _root_ide_package_.at.torch.compose.ui.view.state.ChatRoomListUIState.Loading,
initialChatRoomListUIState: at.torch.compose.ui.view.state.ChatRoomListUIState = at.torch.compose.ui.view.state.ChatRoomListUIState.Loading,
publicKey: String,
synchronizationFilter: at.torch.compose.database.model.types.SynchronizationFilter,
nostrRepository: at.torch.compose.repository.NostrRepository,
@@ -77,7 +77,7 @@ class CreateProfileViewModel(
}
public fun createAccount(
fun createAccount(
writeSeed: (List<String>) -> Unit
// onNavigateToUnsignedProfile: (UnsignedProfileRoute) -> Unit,
// onNavigateToUnannouncedProfile: (UnannouncedProfileRoute) -> Unit
@@ -43,9 +43,9 @@ class FeedListViewModel(
val isSynchronizationPending: MutableState<Boolean> = mutableStateOf(false)
val negentropySynchronizeRequests = _root_ide_package_.at.torch.compose.nostr.Relays.negentropicRelaySet.shuffled().map { normalizedRelayUrl ->
val negentropySynchronizeRequests = at.torch.compose.nostr.Relays.negentropicRelaySet.shuffled().map { normalizedRelayUrl ->
_root_ide_package_.at.torch.compose.database.model.NegentropySynchronizeRequest(
id = _root_ide_package_.at.torch.compose.database.model.NegentropySynchronizeRequest.Companion.computeId(
id = at.torch.compose.database.model.NegentropySynchronizeRequest.computeId(
normalizedRelayUrl.url,
synchronizationFilter = synchronizationFilter
),
@@ -70,7 +70,7 @@ class FeedListViewModel(
nostrRepository.observeNostrFeed(
synchronizationFilter
).distinctUntilChanged().first().let { localNostrEvents ->
feedListUIState = _root_ide_package_.at.torch.compose.ui.view.state.FeedListUIState.Loaded(
feedListUIState = at.torch.compose.ui.view.state.FeedListUIState.Loaded(
localNostrEvents = localNostrEvents
)
}
@@ -108,7 +108,7 @@ class FeedListViewModel(
horizontalAlignment = Alignment.CenterHorizontally
) {
when (val feedListUIState = feedListUIState) {
_root_ide_package_.at.torch.compose.ui.view.state.FeedListUIState.Error -> {
at.torch.compose.ui.view.state.FeedListUIState.Error -> {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
@@ -159,7 +159,7 @@ class FeedListViewModel(
}
}
_root_ide_package_.at.torch.compose.ui.view.state.FeedListUIState.Loading -> {
at.torch.compose.ui.view.state.FeedListUIState.Loading -> {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
@@ -186,7 +186,7 @@ class FeedListViewModel(
const val TAG = "FeedListViewModel"
fun factory(
initialFeedListUIState: at.torch.compose.ui.view.state.FeedListUIState = _root_ide_package_.at.torch.compose.ui.view.state.FeedListUIState.Loading,
initialFeedListUIState: at.torch.compose.ui.view.state.FeedListUIState = at.torch.compose.ui.view.state.FeedListUIState.Loading,
synchronizationFilter: at.torch.compose.database.model.types.SynchronizationFilter,
nostrRepository: at.torch.compose.repository.NostrRepository,
): ViewModelProvider.Factory = viewModelFactory {
@@ -55,7 +55,7 @@ class FollowersListViewModel(
nostrRepository.observeProfileWithFollowers(
publicKey
).collect { localFollowers ->
followersListUIState = _root_ide_package_.at.torch.compose.ui.view.state.FollowersListUIState.Loaded(
followersListUIState = at.torch.compose.ui.view.state.FollowersListUIState.Loaded(
followers = localFollowers?.followers ?: emptyList()
)
}
@@ -67,9 +67,9 @@ class FollowersListViewModel(
viewModelScope.launch(Dispatchers.IO) {
// Sync Notifications... might want to also run this in the background
nostrRepository.queueNegentropySynchronizeRequest(
_root_ide_package_.at.torch.compose.nostr.Relays.negentropicRelaySet.shuffled().map { normalizedRelayUrl ->
at.torch.compose.nostr.Relays.negentropicRelaySet.shuffled().map { normalizedRelayUrl ->
_root_ide_package_.at.torch.compose.database.model.NegentropySynchronizeRequest(
id = _root_ide_package_.at.torch.compose.database.model.NegentropySynchronizeRequest.Companion.computeId(
id = at.torch.compose.database.model.NegentropySynchronizeRequest.computeId(
relayURL = normalizedRelayUrl.url,
synchronizationFilter = synchronizationFilter
),
@@ -104,7 +104,7 @@ class FollowersListViewModel(
horizontalAlignment = Alignment.CenterHorizontally
) {
when (val followersListUIState = followersListUIState) {
_root_ide_package_.at.torch.compose.ui.view.state.FollowersListUIState.Error -> {
at.torch.compose.ui.view.state.FollowersListUIState.Error -> {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
@@ -149,7 +149,7 @@ class FollowersListViewModel(
}
}
_root_ide_package_.at.torch.compose.ui.view.state.FollowersListUIState.Loading -> {
at.torch.compose.ui.view.state.FollowersListUIState.Loading -> {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
@@ -176,7 +176,7 @@ class FollowersListViewModel(
const val TAG = "FollowersListViewModel"
fun factory(
initialFeedListUIState: at.torch.compose.ui.view.state.FollowersListUIState = _root_ide_package_.at.torch.compose.ui.view.state.FollowersListUIState.Loading,
initialFeedListUIState: at.torch.compose.ui.view.state.FollowersListUIState = at.torch.compose.ui.view.state.FollowersListUIState.Loading,
publicKey: String,
synchronizationFilter: at.torch.compose.database.model.types.SynchronizationFilter,
nostrRepository: at.torch.compose.repository.NostrRepository,
@@ -54,7 +54,7 @@ class FollowingListViewModel(
nostrRepository.observeProfileWithFollowing(
publicKey
).collect { localFollowing ->
followingListUIState = _root_ide_package_.at.torch.compose.ui.view.state.FollowingListUIState.Loaded(
followingListUIState = at.torch.compose.ui.view.state.FollowingListUIState.Loaded(
following = localFollowing?.following ?: emptyList()
)
}
@@ -66,9 +66,9 @@ class FollowingListViewModel(
viewModelScope.launch(Dispatchers.IO) {
// Sync Notifications... might want to also run this in the background
nostrRepository.queueNegentropySynchronizeRequest(
_root_ide_package_.at.torch.compose.nostr.Relays.negentropicRelaySet.shuffled().map { normalizedRelayUrl ->
at.torch.compose.nostr.Relays.negentropicRelaySet.shuffled().map { normalizedRelayUrl ->
_root_ide_package_.at.torch.compose.database.model.NegentropySynchronizeRequest(
id = _root_ide_package_.at.torch.compose.database.model.NegentropySynchronizeRequest.Companion.computeId(
id = at.torch.compose.database.model.NegentropySynchronizeRequest.computeId(
relayURL = normalizedRelayUrl.url,
synchronizationFilter = synchronizationFilter
),
@@ -103,7 +103,7 @@ class FollowingListViewModel(
horizontalAlignment = Alignment.CenterHorizontally
) {
when (val feedListUIState = followingListUIState) {
_root_ide_package_.at.torch.compose.ui.view.state.FollowingListUIState.Error -> {
at.torch.compose.ui.view.state.FollowingListUIState.Error -> {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
@@ -148,7 +148,7 @@ class FollowingListViewModel(
}
}
_root_ide_package_.at.torch.compose.ui.view.state.FollowingListUIState.Loading -> {
at.torch.compose.ui.view.state.FollowingListUIState.Loading -> {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
@@ -175,7 +175,7 @@ class FollowingListViewModel(
const val TAG = "FollowingListViewModel"
fun factory(
initialFeedListUIState: at.torch.compose.ui.view.state.FollowingListUIState = _root_ide_package_.at.torch.compose.ui.view.state.FollowingListUIState.Loading,
initialFeedListUIState: at.torch.compose.ui.view.state.FollowingListUIState = at.torch.compose.ui.view.state.FollowingListUIState.Loading,
publicKey: String,
synchronizationFilter: at.torch.compose.database.model.types.SynchronizationFilter,
nostrRepository: at.torch.compose.repository.NostrRepository,
@@ -46,11 +46,11 @@ class HomeViewModel(
activeUserPublicKey
).collect { profileWithFollowing ->
homeScreenUIState = if (profileWithFollowing != null) {
_root_ide_package_.at.torch.compose.ui.view.state.HomeScreenUIState.Loaded(
at.torch.compose.ui.view.state.HomeScreenUIState.Loaded(
profileWithFollowing = profileWithFollowing
)
} else {
_root_ide_package_.at.torch.compose.ui.view.state.HomeScreenUIState.Error
at.torch.compose.ui.view.state.HomeScreenUIState.Error
}
}
}
@@ -61,8 +61,8 @@ class HomeViewModel(
profileWithFollowing: at.torch.compose.database.model.intermdiate.LocalProfileWithFollowing,
): at.torch.compose.database.model.types.SynchronizationFilter {
val twelveHoursAgo = Clock.System.now().minus(12.hours)
val now = Clock.System.now()
Clock.System.now().minus(12.hours)
Clock.System.now()
return when (homeScreenType) {
HomeScreenType.Messages -> {
@@ -61,7 +61,7 @@ class InReplyToViewModel(
nostrRepository.observeNostrFeed(
synchronizationFilter
).distinctUntilChanged().collect { localNostrEvents ->
inReplyToFeedListUIState = _root_ide_package_.at.torch.compose.ui.view.state.FeedListUIState.Loaded(
inReplyToFeedListUIState = at.torch.compose.ui.view.state.FeedListUIState.Loaded(
localNostrEvents = localNostrEvents
)
}
@@ -74,12 +74,12 @@ class InReplyToViewModel(
// Sync Notifications... might want to also run this in the background
val publicRelays = profile?.profilePublicRelays(
nostrRepository
) ?: _root_ide_package_.at.torch.compose.nostr.Relays.negentropicRelaySet
) ?: at.torch.compose.nostr.Relays.negentropicRelaySet
nostrRepository.queueNegentropySynchronizeRequest(
publicRelays.take(3).map { normalizedRelayUrl ->
_root_ide_package_.at.torch.compose.database.model.NegentropySynchronizeRequest(
id = _root_ide_package_.at.torch.compose.database.model.NegentropySynchronizeRequest.Companion.computeId(
id = at.torch.compose.database.model.NegentropySynchronizeRequest.computeId(
relayURL = normalizedRelayUrl.url,
synchronizationFilter = synchronizationFilter
),
@@ -114,7 +114,7 @@ class InReplyToViewModel(
horizontalAlignment = Alignment.CenterHorizontally
) {
when (val feedListUIState = inReplyToFeedListUIState) {
_root_ide_package_.at.torch.compose.ui.view.state.FeedListUIState.Error -> {
at.torch.compose.ui.view.state.FeedListUIState.Error -> {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
@@ -165,7 +165,7 @@ class InReplyToViewModel(
}
}
_root_ide_package_.at.torch.compose.ui.view.state.FeedListUIState.Loading -> {
at.torch.compose.ui.view.state.FeedListUIState.Loading -> {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
@@ -195,7 +195,7 @@ class InReplyToViewModel(
nostrEvent: at.torch.compose.database.model.NostrEvent,
profile: at.torch.compose.database.model.Profile?,
createdAt: Instant,
initialFeedListUIState: at.torch.compose.ui.view.state.FeedListUIState = _root_ide_package_.at.torch.compose.ui.view.state.FeedListUIState.Loading,
initialFeedListUIState: at.torch.compose.ui.view.state.FeedListUIState = at.torch.compose.ui.view.state.FeedListUIState.Loading,
synchronizationFilter: at.torch.compose.database.model.types.SynchronizationFilter = _root_ide_package_.at.torch.compose.database.model.types.SynchronizationFilter(
kinds = arrayOf(
TextNoteEvent.KIND,
@@ -38,7 +38,7 @@ enum class MetadataEventDetailType {
}
class MetadataEventDetailViewModel(
initialMetadataEventDetailUIState: at.torch.compose.ui.view.state.MetadataEventDetailUIState = _root_ide_package_.at.torch.compose.ui.view.state.MetadataEventDetailUIState.Loading,
initialMetadataEventDetailUIState: at.torch.compose.ui.view.state.MetadataEventDetailUIState = at.torch.compose.ui.view.state.MetadataEventDetailUIState.Loading,
val activeUserPublicKey: HexKey,
val eventPublicKey: HexKey,
val nostrRepository: at.torch.compose.repository.NostrRepository,
@@ -66,7 +66,7 @@ class MetadataEventDetailViewModel(
).collect { relations ->
logger.d("We found relations: $relations")
metadataEventDetailUIState = _root_ide_package_.at.torch.compose.ui.view.state.MetadataEventDetailUIState.Loaded(
metadataEventDetailUIState = at.torch.compose.ui.view.state.MetadataEventDetailUIState.Loaded(
isActiveUser = isActiveUser(activeUserPublicKey),
followingActiveUserConnection = relations.find { connection -> connection.sourcePublicKey == eventPublicKey && connection.destinationPublicKey == activeUserPublicKey },
followedByActiveUserConnection = relations.find { connection -> connection.sourcePublicKey == activeUserPublicKey && connection.destinationPublicKey == eventPublicKey }
@@ -66,19 +66,19 @@ class NavigationViewModel(
logger.d("Active Wallet: $activeWallet")
if (activeWallet == null) {
_navigationUIState.getAndUpdate {
_root_ide_package_.at.torch.compose.ui.view.state.NavigationUIState.StartupPhoenix
at.torch.compose.ui.view.state.NavigationUIState.StartupPhoenix
}
} else {
if (activeWallet.business == null) {
_navigationUIState.getAndUpdate {
_root_ide_package_.at.torch.compose.ui.view.state.NavigationUIState.StartupPhoenix
at.torch.compose.ui.view.state.NavigationUIState.StartupPhoenix
}
} else {
val activeUserPublicKey = activeWallet.business.walletManager.keyManager.value?.nostrPublicKey()
if (activeUserPublicKey == null) {
_navigationUIState.getAndUpdate {
_root_ide_package_.at.torch.compose.ui.view.state.NavigationUIState.Loading(text = "Couldn't get the nostrKey")
at.torch.compose.ui.view.state.NavigationUIState.Loading(text = "Couldn't get the nostrKey")
}
} else {
@@ -91,48 +91,48 @@ class NavigationViewModel(
_navigationUIState.getAndUpdate {
if (localProfile == null) {
logger.i("We need to be on the landing screen so user creates account")
_root_ide_package_.at.torch.compose.ui.view.state.NavigationUIState.Landing
at.torch.compose.ui.view.state.NavigationUIState.Landing
} else if (localProfile.unsignedNostrEvent == null) {
logger.i("We need to be on the landing screen so user creates account")
_root_ide_package_.at.torch.compose.ui.view.state.NavigationUIState.Landing
at.torch.compose.ui.view.state.NavigationUIState.Landing
} else if (localProfile.broadcastNostrEventReceipt != null) {
logger.i("We have a broadcast receipt: ${localProfile.profile}")
_root_ide_package_.at.torch.compose.ui.view.state.NavigationUIState.ProfileLoaded(
at.torch.compose.ui.view.state.NavigationUIState.ProfileLoaded(
publicKey = localProfile.unsignedNostrEvent.pubKey
)
} else if (localProfile.unsignedNostrEvent.signedAt != null && localProfile.profile != null) {
logger.i("We have successfully synced a profile: ${localProfile.profile}")
_root_ide_package_.at.torch.compose.ui.view.state.NavigationUIState.ProfileLoaded(
at.torch.compose.ui.view.state.NavigationUIState.ProfileLoaded(
publicKey = localProfile.unsignedNostrEvent.pubKey
)
} else if (localProfile.broadcastNostrEventRequest != null) {
logger.i("We have a broadcast request: ${localProfile.broadcastNostrEventRequest}")
_root_ide_package_.at.torch.compose.ui.view.state.NavigationUIState.UnannouncedProfile(
at.torch.compose.ui.view.state.NavigationUIState.UnannouncedProfile(
broadcastNostrEventRequest = localProfile.broadcastNostrEventRequest
)
} else if (localProfile.profile != null) {
logger.i("We have a profile that needs to queued for broadcast: ${localProfile.profile}")
_root_ide_package_.at.torch.compose.ui.view.state.NavigationUIState.UnqueuedProfile(
at.torch.compose.ui.view.state.NavigationUIState.UnqueuedProfile(
profile = localProfile.profile
)
} else if (localProfile.nostrEvent != null) {
logger.i("Nostr event with the profile needs to be indexed: ${localProfile.nostrEvent}")
_root_ide_package_.at.torch.compose.ui.view.state.NavigationUIState.UnindexedProfile(
at.torch.compose.ui.view.state.NavigationUIState.UnindexedProfile(
nostrEvent = localProfile.nostrEvent
)
} else if (localProfile.unsignedNostrEvent.signedAt != null && localProfile.synchronizeNostrEventRequests.isEmpty()) {
logger.i("We should request to sync profile: ${localProfile.unsignedNostrEvent}")
_root_ide_package_.at.torch.compose.ui.view.state.NavigationUIState.UnqueuedProfileSynchronization(
at.torch.compose.ui.view.state.NavigationUIState.UnqueuedProfileSynchronization(
unsignedNostrEvent = localProfile.unsignedNostrEvent
)
} else if (localProfile.unsignedNostrEvent.signedAt != null && localProfile.synchronizeNostrEventRequests.isEmpty()) {
logger.i("We should be syncing the profile: ${localProfile.unsignedNostrEvent}")
_root_ide_package_.at.torch.compose.ui.view.state.NavigationUIState.UnsyncedProfile(
at.torch.compose.ui.view.state.NavigationUIState.UnsyncedProfile(
unsignedNostrEvent = localProfile.unsignedNostrEvent
)
} else {
logger.i("We have an unsigned profile: ${localProfile.unsignedNostrEvent}")
_root_ide_package_.at.torch.compose.ui.view.state.NavigationUIState.UnsignedProfile(
at.torch.compose.ui.view.state.NavigationUIState.UnsignedProfile(
unsignedNostrEvent = localProfile.unsignedNostrEvent
)
}
@@ -28,7 +28,7 @@ class NostrEventDetailViewModel(
private set
fun retryLoad() {
nostrEventDetailUIState = _root_ide_package_.at.torch.compose.ui.view.state.NostrEventDetailUIState.Loading
nostrEventDetailUIState = at.torch.compose.ui.view.state.NostrEventDetailUIState.Loading
loadNostrFeed()
}
@@ -36,7 +36,7 @@ class NostrEventDetailViewModel(
viewModelScope.launch(Dispatchers.IO) {
// Sync Notifications... might want to also run this in the background
nostrRepository.queueSynchronizeNostrEvent(
_root_ide_package_.at.torch.compose.nostr.Relays.eventPublishRelaySet.take(1).map { normalizedRelay -> // TODO: Sync from all relays instead of 1
at.torch.compose.nostr.Relays.eventPublishRelaySet.take(1).map { normalizedRelay -> // TODO: Sync from all relays instead of 1
_root_ide_package_.at.torch.compose.database.model.SynchronizeNostrEventRequest(
purpose = "detail",
synchronizationFilters = arrayOf(
@@ -69,11 +69,11 @@ class NostrEventDetailViewModel(
nostrEventId
).collectLatest { localNostrEvent ->
nostrEventDetailUIState = if (localNostrEvent != null) {
_root_ide_package_.at.torch.compose.ui.view.state.NostrEventDetailUIState.Loaded(
at.torch.compose.ui.view.state.NostrEventDetailUIState.Loaded(
localNostrEvent = localNostrEvent
)
} else {
_root_ide_package_.at.torch.compose.ui.view.state.NostrEventDetailUIState.Error
at.torch.compose.ui.view.state.NostrEventDetailUIState.Error
}
}
}
@@ -85,7 +85,7 @@ class NostrEventDetailViewModel(
fun factory(
nostrEventId: HexKey,
activeUserPublicKey: HexKey,
initialNostrEventDetailUIState: at.torch.compose.ui.view.state.NostrEventDetailUIState = _root_ide_package_.at.torch.compose.ui.view.state.NostrEventDetailUIState.Loading,
initialNostrEventDetailUIState: at.torch.compose.ui.view.state.NostrEventDetailUIState = at.torch.compose.ui.view.state.NostrEventDetailUIState.Loading,
nostrRepository: at.torch.compose.repository.NostrRepository,
): ViewModelProvider.Factory = viewModelFactory {
initializer {
@@ -103,7 +103,7 @@ class NotaryViewModel(
sig = event.sig,
unsignedNostrEventId = unsignedNostrEvent.id
),
relayURLs = _root_ide_package_.at.torch.compose.nostr.Relays.eventPublishRelaySet.map { normalizedRelayUrl -> normalizedRelayUrl.url },
relayURLs = at.torch.compose.nostr.Relays.eventPublishRelaySet.map { normalizedRelayUrl -> normalizedRelayUrl.url },
activeKeyPair = keyPair
)
}
@@ -31,11 +31,11 @@ class SearchResultViewModel(
private set
var searchResultListUIState: at.torch.compose.ui.view.state.SearchResultListUIState by mutableStateOf(
_root_ide_package_.at.torch.compose.ui.view.state.SearchResultListUIState.Loading)
at.torch.compose.ui.view.state.SearchResultListUIState.Loading)
private set
fun updateSearchResultType (searchResultType: SearchResultType) {
searchResultListUIState = _root_ide_package_.at.torch.compose.ui.view.state.SearchResultListUIState.Loading
searchResultListUIState = at.torch.compose.ui.view.state.SearchResultListUIState.Loading
this.searchResultType = searchResultType
@@ -78,7 +78,7 @@ class SearchResultViewModel(
viewModelScope.launch(Dispatchers.IO) {
// Sync Notifications... might want to also run this in the background
searchRepository.submitSearch(
_root_ide_package_.at.torch.compose.nostr.Relays.eventFinderRelaySet.take(1).map { normalizedRelay -> // TODO: Search all relays instead of the first
at.torch.compose.nostr.Relays.eventFinderRelaySet.take(1).map { normalizedRelay -> // TODO: Search all relays instead of the first
_root_ide_package_.at.torch.compose.database.model.SynchronizeNostrEventRequest(
purpose = "search",
synchronizationFilters = arrayOf(
@@ -97,7 +97,7 @@ class SearchResultViewModel(
viewModelScope.launch(Dispatchers.IO) {
// This is something not taking into consideration the results we are actually looking for...
nostrRepository.observeNostrFeed(synchronizationFilter).distinctUntilChanged().collect { localNostrEvents ->
searchResultListUIState = _root_ide_package_.at.torch.compose.ui.view.state.SearchResultListUIState.Loaded(
searchResultListUIState = at.torch.compose.ui.view.state.SearchResultListUIState.Loaded(
localNostrEvents = localNostrEvents
)
}
@@ -76,7 +76,7 @@ class SearchViewModel(
const val TAG = "SearchViewModel"
fun factory(
initialSearchUIState: at.torch.compose.ui.view.state.SearchUIState = _root_ide_package_.at.torch.compose.ui.view.state.SearchUIState.Prompt,
initialSearchUIState: at.torch.compose.ui.view.state.SearchUIState = at.torch.compose.ui.view.state.SearchUIState.Prompt,
nostrRepository: at.torch.compose.repository.NostrRepository,
searchRepository: at.torch.compose.repository.SearchRepository,
): ViewModelProvider.Factory = viewModelFactory {
@@ -78,7 +78,7 @@ class SignInToProfileViewModel(
}
else -> {
// TODO: Might want to give reasons for the error.
signInToProfileUIState.value = _root_ide_package_.at.torch.compose.ui.view.state.SignInToProfileUIState.Error
signInToProfileUIState.value = at.torch.compose.ui.view.state.SignInToProfileUIState.Error
}
}
@@ -82,16 +82,16 @@ class SovereignWalletViewModel(
.stateIn(viewModelScope, started = SharingStarted.Lazily, initialValue = emptyList())
var walletUIState: at.torch.compose.ui.view.state.SovereignWalletUIState by mutableStateOf(
_root_ide_package_.at.torch.compose.ui.view.state.SovereignWalletUIState.Loading)
at.torch.compose.ui.view.state.SovereignWalletUIState.Loading)
private set
fun retryLoad() {
walletUIState = _root_ide_package_.at.torch.compose.ui.view.state.SovereignWalletUIState.Loading
walletUIState = at.torch.compose.ui.view.state.SovereignWalletUIState.Loading
}
fun loadSovereignData(walletId: WalletId) {
walletUIState = _root_ide_package_.at.torch.compose.ui.view.state.SovereignWalletUIState.Success(
walletUIState = at.torch.compose.ui.view.state.SovereignWalletUIState.Success(
publicKey = walletId.nodeIdHash,
balanceInSatoshis = 0 // TODO: Get balance...
)
@@ -154,7 +154,7 @@ class SovereignWalletViewModel(
phoenixGlobal = phoenixGlobal,
walletId = walletId,
name = null,
avatar = _root_ide_package_.at.torch.compose.ui.composable.widgets.wallet.WalletAvatars.list.random(),
avatar = at.torch.compose.ui.composable.widgets.wallet.WalletAvatars.list.random(),
isHidden = false
)
}
@@ -40,8 +40,8 @@ class SynchronizationViewModel(
val relaysSocketManager = _root_ide_package_.at.torch.compose.network.relays.RelaysSocketManager(
activeWalletStateFlow = activeWalletStateFlow,
nostrSocketClientFactory = _root_ide_package_.at.torch.compose.network.sockets.NostrSocketClientFactory,
cachingImportRepository = _root_ide_package_.at.torch.compose.repository.CachingImportRepository.Companion.NO_OP_CACHING_IMPORT_REPOSITORY,
nostrSocketClientFactory = at.torch.compose.network.sockets.NostrSocketClientFactory,
cachingImportRepository = at.torch.compose.repository.CachingImportRepository.NO_OP_CACHING_IMPORT_REPOSITORY,
relayRepository = relayRepository,
)
@@ -382,7 +382,7 @@ class SynchronizationViewModel(
scope.launch(Dispatchers.IO) {
relaysSocketManager.publishEvent(
localBroadcastNostrEventRequest.nostrEvent
).timeout(_root_ide_package_.at.torch.compose.network.relays.RelayPool.Companion.PUBLISH_TIMEOUT.milliseconds).catch {
).timeout(at.torch.compose.network.relays.RelayPool.PUBLISH_TIMEOUT.milliseconds).catch {
// Timeout...
}.collect { nostrPublishResult ->
if (nostrPublishResult.error != null) {
@@ -409,7 +409,7 @@ class SynchronizationViewModel(
setOf(
localBroadcastNostrEventRequest.broadcastNostrEventRequest.relayURL.toRelayDTO()
)
).timeout(_root_ide_package_.at.torch.compose.network.relays.RelayPool.Companion.PUBLISH_TIMEOUT.milliseconds).catch {
).timeout(at.torch.compose.network.relays.RelayPool.PUBLISH_TIMEOUT.milliseconds).catch {
// Timeout...
}.collect { nostrPublishResult ->
if (nostrPublishResult.error != null) {
@@ -55,7 +55,7 @@ class UnqueuedProfileSynchronizationViewModel(
delay(2_000)
nostrRepository.queueSynchronizeNostrEvent(
_root_ide_package_.at.torch.compose.nostr.Relays.eventPublishRelaySet.map { normalizedRelayUrl ->
at.torch.compose.nostr.Relays.eventPublishRelaySet.map { normalizedRelayUrl ->
_root_ide_package_.at.torch.compose.database.model.SynchronizeNostrEventRequest(
purpose = "sign-in",
synchronizationFilters = arrayOf(
@@ -121,13 +121,13 @@ class WriteNewNoteViewModel(
activePublicKey
).collect { profileWithFollowing ->
writeNewNoteUIState = if (profileWithFollowing != null) {
_root_ide_package_.at.torch.compose.ui.view.state.WriteNewNoteUIState.InputPrompt(
at.torch.compose.ui.view.state.WriteNewNoteUIState.InputPrompt(
localProfile = profileWithFollowing,
inReplyToNostrEvent = nostrEventBeingRepliedTo,
quotedNostrEvent = nostrEventBeingQuoted
)
} else {
_root_ide_package_.at.torch.compose.ui.view.state.WriteNewNoteUIState.Error
at.torch.compose.ui.view.state.WriteNewNoteUIState.Error
}
}
}
@@ -141,7 +141,7 @@ class WriteNewNoteViewModel(
validateInput().let { isInputValid ->
if (isInputValid) {
writeNewNoteUIState =
_root_ide_package_.at.torch.compose.ui.view.state.WriteNewNoteUIState.ConfirmNote(
at.torch.compose.ui.view.state.WriteNewNoteUIState.ConfirmNote(
localProfile = localProfile,
inReplyToNostrEvent = inReplyToNostrEvent,
quotedNostrEvent = quotedNostrEvent,
@@ -172,7 +172,7 @@ class WriteNewNoteViewModel(
isActionPending.value = true
viewModelScope.launch(Dispatchers.IO) {
val mentionedPublicKeys = _root_ide_package_.at.torch.compose.ui.composable.widgets.content.ContentParser.parse(
val mentionedPublicKeys = at.torch.compose.ui.composable.widgets.content.ContentParser.parse(
writeNewNoteFormState.textField.textFieldState.text.toString(),
).filterIsInstance<at.torch.compose.ui.composable.widgets.content.ContentSegment.NostrProfileSegment>().map { it.pubkey }
@@ -183,7 +183,7 @@ class WriteNewNoteViewModel(
inReplyToNostrEvent = inReplyToNostrEvent,
quotedNostrEvent = quotedNostrEvent,
onError = {
writeNewNoteUIState = _root_ide_package_.at.torch.compose.ui.view.state.WriteNewNoteUIState.Error
writeNewNoteUIState = at.torch.compose.ui.view.state.WriteNewNoteUIState.Error
},
onSuccess = onNostrEventPublished
)
@@ -28,8 +28,7 @@ object RestoreWallet {
if (this === other) return true
if (other == null || this::class != other::class) return false
other as ValidMnemonics
if (!seed.contentEquals(other.seed)) return false
return true
return seed.contentEquals(other.seed)
}
override fun hashCode(): Int {
@@ -203,12 +203,12 @@ enum class FiatCurrency(override val displayCode: String, val flag: String = "
suspend fun getLabel(): Pair<String, String> {
val fullName = when {
// use the free market rates as default. Name for official rates gets a special tag, as those rates are usually inaccurate.
this == FiatCurrency.ARS -> getString(Res.string.currency_ars_official)
this == FiatCurrency.ARS_BM -> getString(Res.string.currency_ars_bm)
this == FiatCurrency.CUP -> getString(Res.string.currency_cup_official)
this == FiatCurrency.CUP_FM -> getString(Res.string.currency_cup_fm)
this == FiatCurrency.LBP -> getString(Res.string.currency_lbp_official)
this == FiatCurrency.LBP_BM -> getString(Res.string.currency_lbp_bm)
this == ARS -> getString(Res.string.currency_ars_official)
this == ARS_BM -> getString(Res.string.currency_ars_bm)
this == CUP -> getString(Res.string.currency_cup_official)
this == CUP_FM -> getString(Res.string.currency_cup_fm)
this == LBP -> getString(Res.string.currency_lbp_official)
this == LBP_BM -> getString(Res.string.currency_lbp_bm)
// use the JVM API otherwise to get the name
this.displayCode.length == 3 -> try {
this.name
@@ -115,7 +115,7 @@ sealed interface Lnurl {
Tag.Auth -> {
val k1 = url.parameters["k1"]
if (k1.isNullOrBlank()) {
throw LnurlError.Auth.MissingK1
throw LnurlError.Auth.MissingK1()
} else {
LnurlAuth(url, k1)
}
@@ -129,7 +129,7 @@ sealed interface Lnurl {
val (_, data) = Bech32.decode(source)
val payload = Bech32.five2eight(data, 0).decodeToString()
val url = URLBuilder(payload).build()
if (!url.protocol.isSecure()) throw LnurlError.UnsafeResource
if (!url.protocol.isSecure()) throw LnurlError.UnsafeResource()
return url
}
@@ -141,7 +141,7 @@ sealed interface Lnurl {
// this url contains a lnurl fallback which takes priority - and must be bech32 encoded
parseBech32Url(lightningParam)
} else {
if (!urlBuilder.protocol.isSecure()) throw LnurlError.UnsafeResource
if (!urlBuilder.protocol.isSecure()) throw LnurlError.UnsafeResource()
urlBuilder.build()
}
}
@@ -217,12 +217,12 @@ sealed interface Lnurl {
/** Converts a lnurl JSON response to a [Lnurl] object. */
fun parseLnurlJson(url: Url, json: JsonObject): Lnurl {
val callback = URLBuilder(json["callback"]?.jsonPrimitive?.content ?: throw LnurlError.MissingCallback).build()
if (!callback.protocol.isSecure()) throw LnurlError.UnsafeResource
val tag = json["tag"]?.jsonPrimitive?.content?.takeIf { it.isNotBlank() } ?: throw LnurlError.NoTag
val callback = URLBuilder(json["callback"]?.jsonPrimitive?.content ?: throw LnurlError.MissingCallback()).build()
if (!callback.protocol.isSecure()) throw LnurlError.UnsafeResource()
val tag = json["tag"]?.jsonPrimitive?.content?.takeIf { it.isNotBlank() } ?: throw LnurlError.NoTag()
return when (tag) {
Tag.Withdraw.label -> {
val k1 = json["k1"]?.jsonPrimitive?.content?.takeIf { it.isNotBlank() } ?: throw LnurlError.Withdraw.MissingK1
val k1 = json["k1"]?.jsonPrimitive?.content?.takeIf { it.isNotBlank() } ?: throw LnurlError.Withdraw.MissingK1()
val minWithdrawable = json["minWithdrawable"]?.jsonPrimitive?.doubleOrNull?.takeIf { it > 0f }?.toLong()?.msat
?: json["minWithdrawable"]?.jsonPrimitive?.long?.takeIf { it > 0 }?.msat
?: 0.msat
@@ -242,11 +242,11 @@ sealed interface Lnurl {
Tag.Pay.label -> {
val minSendable = json["minSendable"]?.jsonPrimitive?.doubleOrNull?.takeIf { it > 0f }?.toLong()?.msat
?: json["minSendable"]?.jsonPrimitive?.longOrNull?.takeIf { it > 0 }?.msat
?: throw LnurlError.Pay.Intent.InvalidMin
?: throw LnurlError.Pay.Intent.InvalidMin()
val maxSendable = json["maxSendable"]?.jsonPrimitive?.doubleOrNull?.takeIf { it > 0f }?.toLong()?.msat
?: json["maxSendable"]?.jsonPrimitive?.longOrNull?.coerceAtLeast(minSendable.msat)?.msat
?: throw LnurlError.Pay.Intent.MissingMax
val metadata = LnurlPay.parseMetadata(json["metadata"]?.jsonPrimitive?.content ?: throw LnurlError.Pay.Intent.MissingMetadata)
?: throw LnurlError.Pay.Intent.MissingMax()
val metadata = LnurlPay.parseMetadata(json["metadata"]?.jsonPrimitive?.content ?: throw LnurlError.Pay.Intent.MissingMetadata())
val maxCommentLength = json["commentAllowed"]?.jsonPrimitive?.longOrNull?.takeIf { it > 0 }
LnurlPay.Intent(
initialUrl = url,
@@ -166,7 +166,7 @@ data class LnurlAuth(
/** Get the legacy domain for the given [Url] if eligible, or the full domain name otherwise (i.e. specs compliant). */
fun filterDomain(url: Url): String {
return entries.firstOrNull() { it.host == url.host }?.legacyCompatDomain ?: url.host
return entries.firstOrNull { it.host == url.host }?.legacyCompatDomain ?: url.host
}
}
}
@@ -22,18 +22,18 @@ sealed class LnurlError(override val message: String? = null) : RuntimeException
val details: String by lazy { "Lnurl error=${message ?: this::class.simpleName ?: "N/A"} in url=" }
sealed class Auth(override val message: String?) : LnurlError(message) {
object MissingK1 : Auth("missing k1 parameter")
class MissingK1 : Auth("missing k1 parameter")
}
sealed class Withdraw(override val message: String?) : LnurlError(message) {
object MissingK1 : Withdraw("missing k1 parameter in auth metadata")
class MissingK1 : Withdraw("missing k1 parameter in auth metadata")
}
sealed class Pay : LnurlError() {
sealed class Intent(override val message: String?) : LnurlError(message) {
object InvalidMin : Intent("invalid minimum amount")
object MissingMax : Intent("missing maximum amount parameter")
object MissingMetadata : Intent("missing metadata parameter")
class InvalidMin : Intent("invalid minimum amount")
class MissingMax : Intent("missing maximum amount parameter")
class MissingMetadata : Intent("missing metadata parameter")
data class InvalidMetadata(val meta: String) : Intent("invalid meta=$meta")
}
@@ -50,10 +50,10 @@ sealed class LnurlError(override val message: String? = null) : RuntimeException
}
data class Invalid(override val cause: Throwable?) : LnurlError("cannot be parsed as a bech32 or as a human readable lnurl")
object NoTag : LnurlError("no tag field found")
class NoTag : LnurlError("no tag field found")
data class UnhandledTag(val tag: String) : LnurlError("unhandled tag=$tag")
object UnsafeResource : LnurlError("resource should be https")
object MissingCallback : LnurlError("missing callback in metadata response")
class UnsafeResource : LnurlError("resource should be https")
class MissingCallback : LnurlError("missing callback in metadata response")
sealed class RemoteFailure(override val message: String) : LnurlError(message) {
abstract val origin: String
Loaded 100 of 115 files, more files were not shown because too many files have changed in this diff. Show more