diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index 26a6b8f2a..b65547ca6 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -11,6 +11,6 @@
-
+
\ No newline at end of file
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt
index 79a9fe3c6..f4f8f743b 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt
@@ -898,59 +898,101 @@ object LocalCache : ILocalCache, ICacheProvider {
@Suppress("DEPRECATION")
fun computeReplyTo(event: Event): List =
when (event) {
- is PollNoteEvent -> event.tagsWithoutCitations().mapNotNull { checkGetOrCreateNote(it) }
- is LongTextNoteEvent -> event.tagsWithoutCitations().mapNotNull { checkGetOrCreateNote(it) }
- is GitReplyEvent -> event.tagsWithoutCitations().filter { it != event.repository()?.toTag() }.mapNotNull { checkGetOrCreateNote(it) }
- is TextNoteEvent -> event.tagsWithoutCitations().mapNotNull { checkGetOrCreateNote(it) }
- is CommentEvent -> event.tagsWithoutCitations().mapNotNull { checkGetOrCreateNote(it) }
+ is PollNoteEvent -> {
+ event.tagsWithoutCitations().mapNotNull { checkGetOrCreateNote(it) }
+ }
- is VoiceReplyEvent -> event.markedReplyTos().mapNotNull { checkGetOrCreateNote(it) }
+ is LongTextNoteEvent -> {
+ event.tagsWithoutCitations().mapNotNull { checkGetOrCreateNote(it) }
+ }
- is ChatMessageEvent -> event.taggedEvents().mapNotNull { checkGetOrCreateNote(it) }
- is ChatMessageEncryptedFileHeaderEvent -> event.taggedEvents().mapNotNull { checkGetOrCreateNote(it) }
+ is GitReplyEvent -> {
+ event.tagsWithoutCitations().filter { it != event.repository()?.toTag() }.mapNotNull { checkGetOrCreateNote(it) }
+ }
- is LnZapEvent ->
+ is TextNoteEvent -> {
+ event.tagsWithoutCitations().mapNotNull { checkGetOrCreateNote(it) }
+ }
+
+ is CommentEvent -> {
+ event.tagsWithoutCitations().mapNotNull { checkGetOrCreateNote(it) }
+ }
+
+ is VoiceReplyEvent -> {
+ event.markedReplyTos().mapNotNull { checkGetOrCreateNote(it) }
+ }
+
+ is ChatMessageEvent -> {
+ event.taggedEvents().mapNotNull { checkGetOrCreateNote(it) }
+ }
+
+ is ChatMessageEncryptedFileHeaderEvent -> {
+ event.taggedEvents().mapNotNull { checkGetOrCreateNote(it) }
+ }
+
+ is LnZapEvent -> {
event.zappedPost().mapNotNull { checkGetOrCreateNote(it) } +
event.taggedAddresses().map { getOrCreateAddressableNote(it) } +
(event.zapRequest?.taggedAddresses()?.map { getOrCreateAddressableNote(it) } ?: emptyList())
- is LnZapRequestEvent ->
+ }
+
+ is LnZapRequestEvent -> {
event.zappedPost().mapNotNull { checkGetOrCreateNote(it) } +
event.taggedAddresses().map { getOrCreateAddressableNote(it) }
- is BadgeProfilesEvent ->
+ }
+
+ is BadgeProfilesEvent -> {
event.badgeAwardEvents().mapNotNull { checkGetOrCreateNote(it) } +
event.badgeAwardDefinitions().map { getOrCreateAddressableNote(it) }
- is BadgeAwardEvent -> event.awardDefinition().map { getOrCreateAddressableNote(it) }
- is PrivateDmEvent -> event.taggedEvents().mapNotNull { checkGetOrCreateNote(it) }
- is RepostEvent ->
+ }
+
+ is BadgeAwardEvent -> {
+ event.awardDefinition().map { getOrCreateAddressableNote(it) }
+ }
+
+ is PrivateDmEvent -> {
+ event.taggedEvents().mapNotNull { checkGetOrCreateNote(it) }
+ }
+
+ is RepostEvent -> {
listOfNotNull(
event.boostedEventId()?.let { checkGetOrCreateNote(it) },
event.boostedAddress()?.let { getOrCreateAddressableNote(it) },
)
- is GenericRepostEvent ->
+ }
+
+ is GenericRepostEvent -> {
listOfNotNull(
event.boostedEventId()?.let { checkGetOrCreateNote(it) },
event.boostedAddress()?.let { getOrCreateAddressableNote(it) },
)
- is CommunityPostApprovalEvent ->
+ }
+
+ is CommunityPostApprovalEvent -> {
event.approvedEvents().mapNotNull { checkGetOrCreateNote(it) } +
event.approvedAddresses().map { getOrCreateAddressableNote(it) }
- is ReactionEvent ->
+ }
+
+ is ReactionEvent -> {
event.originalPost().mapNotNull { checkGetOrCreateNote(it) } +
event.taggedAddresses().map { getOrCreateAddressableNote(it) }
- is ChannelMessageEvent ->
- event
- .tagsWithoutCitations()
- .filter { it != event.channelId() }
- .mapNotNull { checkGetOrCreateNote(it) }
- is LiveActivitiesChatMessageEvent ->
- event
- .tagsWithoutCitations()
- .filter { it != event.activity()?.toTag() }
- .mapNotNull { checkGetOrCreateNote(it) }
- is TorrentCommentEvent ->
- event.tagsWithoutCitations().mapNotNull { checkGetOrCreateNote(it) }
+ }
- else -> emptyList()
+ is ChannelMessageEvent -> {
+ event.tagsWithoutCitations().filter { it != event.channelId() }.mapNotNull { checkGetOrCreateNote(it) }
+ }
+
+ is LiveActivitiesChatMessageEvent -> {
+ event.tagsWithoutCitations().filter { it != event.activity()?.toTag() }.mapNotNull { checkGetOrCreateNote(it) }
+ }
+
+ is TorrentCommentEvent -> {
+ event.tagsWithoutCitations().mapNotNull { checkGetOrCreateNote(it) }
+ }
+
+ else -> {
+ emptyList()
+ }
}
fun consume(
@@ -2691,27 +2733,38 @@ object LocalCache : ILocalCache, ICacheProvider {
fun consume(nip19: Entity) {
when (nip19) {
- is NSec -> getOrCreateUser(nip19.toPubKeyHex())
- is NPub -> getOrCreateUser(nip19.hex)
+ is NSec -> {
+ getOrCreateUser(nip19.toPubKeyHex())
+ }
+
+ is NPub -> {
+ getOrCreateUser(nip19.hex)
+ }
+
is NProfile -> {
nip19.relay.forEach { relayHint ->
relayHints.addKey(nip19.hex, relayHint)
}
getOrCreateUser(nip19.hex)
}
+
is NNote -> {
getOrCreateNote(nip19.hex)
}
+
is NEvent -> {
nip19.relay.forEach { relayHint ->
relayHints.addEvent(nip19.hex, relayHint)
}
getOrCreateNote(nip19.hex)
}
+
is NEmbed -> {
justConsume(nip19.event, null, false)
}
+
is NRelay -> {}
+
is NAddress -> {
val aTag = nip19.aTag()
nip19.relay.forEach { relayHint ->
@@ -2719,6 +2772,7 @@ object LocalCache : ILocalCache, ICacheProvider {
}
getOrCreateAddressableNote(nip19.address())
}
+
else -> { }
}
}
@@ -2966,10 +3020,7 @@ object LocalCache : ILocalCache, ICacheProvider {
is VoiceReplyEvent -> consume(event, relay, wasVerified)
is WikiNoteEvent -> consume(event, relay, wasVerified)
is PaymentTargetsEvent -> consume(event, relay, wasVerified)
- else -> {
- Log.w("Event Not Supported", "From ${relay?.url}: ${event.toJson()}")
- false
- }
+ else -> Log.w("Event Not Supported", "From ${relay?.url}: ${event.toJson()}").let { false }
}
} catch (e: Exception) {
if (e is CancellationException) throw e
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/MiniFhir.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/MiniFhir.kt
index 5c6f7b2b5..e5c035f6f 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/MiniFhir.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/MiniFhir.kt
@@ -168,6 +168,7 @@ fun parseResourceBundleOrNull(json: String): FhirElementDatabase? {
is Bundle -> {
resource.entry.associateBy { it.id }.toImmutableMap()
}
+
else -> {
persistentMapOf(resource.id to resource)
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/UiSettings.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/UiSettings.kt
index 30c763162..b0e6aae20 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/UiSettings.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/UiSettings.kt
@@ -54,9 +54,7 @@ fun parseThemeType(code: Int?): ThemeType =
ThemeType.SYSTEM.screenCode -> ThemeType.SYSTEM
ThemeType.LIGHT.screenCode -> ThemeType.LIGHT
ThemeType.DARK.screenCode -> ThemeType.DARK
- else -> {
- ThemeType.SYSTEM
- }
+ else -> ThemeType.SYSTEM
}
enum class ConnectivityType(
@@ -91,9 +89,7 @@ fun parseConnectivityType(code: Boolean?): ConnectivityType =
ConnectivityType.ALWAYS.prefCode -> ConnectivityType.ALWAYS
ConnectivityType.WIFI_ONLY.prefCode -> ConnectivityType.WIFI_ONLY
ConnectivityType.NEVER.prefCode -> ConnectivityType.NEVER
- else -> {
- ConnectivityType.ALWAYS
- }
+ else -> ConnectivityType.ALWAYS
}
fun parseConnectivityType(screenCode: Int): ConnectivityType =
@@ -101,9 +97,7 @@ fun parseConnectivityType(screenCode: Int): ConnectivityType =
ConnectivityType.ALWAYS.screenCode -> ConnectivityType.ALWAYS
ConnectivityType.WIFI_ONLY.screenCode -> ConnectivityType.WIFI_ONLY
ConnectivityType.NEVER.screenCode -> ConnectivityType.NEVER
- else -> {
- ConnectivityType.ALWAYS
- }
+ else -> ConnectivityType.ALWAYS
}
fun parseFeatureSetType(screenCode: Int): FeatureSetType =
@@ -111,18 +105,14 @@ fun parseFeatureSetType(screenCode: Int): FeatureSetType =
FeatureSetType.COMPLETE.screenCode -> FeatureSetType.COMPLETE
FeatureSetType.SIMPLIFIED.screenCode -> FeatureSetType.SIMPLIFIED
FeatureSetType.PERFORMANCE.screenCode -> FeatureSetType.PERFORMANCE
- else -> {
- FeatureSetType.COMPLETE
- }
+ else -> FeatureSetType.COMPLETE
}
fun parseGalleryType(screenCode: Int): ProfileGalleryType =
when (screenCode) {
ProfileGalleryType.CLASSIC.screenCode -> ProfileGalleryType.CLASSIC
ProfileGalleryType.MODERN.screenCode -> ProfileGalleryType.MODERN
- else -> {
- ProfileGalleryType.CLASSIC
- }
+ else -> ProfileGalleryType.CLASSIC
}
enum class BooleanType(
@@ -138,18 +128,14 @@ fun parseBooleanType(code: Boolean?): BooleanType =
when (code) {
BooleanType.ALWAYS.prefCode -> BooleanType.ALWAYS
BooleanType.NEVER.prefCode -> BooleanType.NEVER
- else -> {
- BooleanType.ALWAYS
- }
+ else -> BooleanType.ALWAYS
}
fun parseBooleanType(screenCode: Int): BooleanType =
when (screenCode) {
BooleanType.ALWAYS.screenCode -> BooleanType.ALWAYS
BooleanType.NEVER.screenCode -> BooleanType.NEVER
- else -> {
- BooleanType.ALWAYS
- }
+ else -> BooleanType.ALWAYS
}
enum class WarningType(
@@ -167,9 +153,7 @@ fun parseWarningType(screenCode: Int): WarningType =
WarningType.WARN.screenCode -> WarningType.WARN
WarningType.SHOW.screenCode -> WarningType.SHOW
WarningType.HIDE.screenCode -> WarningType.HIDE
- else -> {
- WarningType.WARN
- }
+ else -> WarningType.WARN
}
fun parseWarningType(code: Boolean?): WarningType =
@@ -177,7 +161,5 @@ fun parseWarningType(code: Boolean?): WarningType =
WarningType.WARN.prefCode -> WarningType.WARN
WarningType.HIDE.prefCode -> WarningType.HIDE
WarningType.SHOW.prefCode -> WarningType.SHOW
- else -> {
- WarningType.WARN
- }
+ else -> WarningType.WARN
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt
index 3c6be3068..754d801de 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt
@@ -68,13 +68,17 @@ class AccountCacheState(
NostrSignerInternal(accountSettings.keyPair)
} else {
when (val packageName = accountSettings.externalSignerPackageName) {
- null -> NostrSignerInternal(accountSettings.keyPair)
- else ->
+ null -> {
+ NostrSignerInternal(accountSettings.keyPair)
+ }
+
+ else -> {
NostrSignerExternal(
pubKey = accountSettings.keyPair.pubKey.toHexKey(),
packageName = packageName,
contentResolver = contentResolverFn(),
)
+ }
}
},
accountSettings = accountSettings,
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/Nip11CachedRetriever.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/Nip11CachedRetriever.kt
index a73f17579..2a9b56068 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/Nip11CachedRetriever.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/Nip11CachedRetriever.kt
@@ -74,7 +74,10 @@ class Nip11CachedRetriever(
val doc = relayInformationDocumentCache.get(relay)
if (doc != null) {
when (doc) {
- is RetrieveResult.Success -> onInfo(doc.data)
+ is RetrieveResult.Success -> {
+ onInfo(doc.data)
+ }
+
is RetrieveResult.Loading -> {
if (doc.isValid()) {
// just wait.
@@ -82,6 +85,7 @@ class Nip11CachedRetriever(
retrieve(relay, onInfo, onError)
}
}
+
is RetrieveResult.Error -> {
if (doc.isValid()) {
onError(relay, doc.error, null)
@@ -89,7 +93,10 @@ class Nip11CachedRetriever(
retrieve(relay, onInfo, onError)
}
}
- is RetrieveResult.Empty -> retrieve(relay, onInfo, onError)
+
+ is RetrieveResult.Empty -> {
+ retrieve(relay, onInfo, onError)
+ }
}
} else {
retrieve(relay, onInfo, onError)
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt
index 66758a65f..746776ac9 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt
@@ -64,11 +64,26 @@ class FeedTopNavFilterState(
) {
fun loadFlowsFor(listName: String): IFeedFlowsType =
when (listName) {
- GLOBAL_FOLLOWS -> GlobalFeedFlow(followsRelays, proxyRelays)
- ALL_FOLLOWS -> AllFollowsFeedFlow(allFollows, followsRelays, blockedRelays, proxyRelays)
- ALL_USER_FOLLOWS -> AllUserFollowsFeedFlow(allFollows, followsRelays, blockedRelays, proxyRelays)
- KIND3_FOLLOWS -> Kind3UserFollowsFeedFlow(kind3Follows, followsRelays, blockedRelays, proxyRelays)
- AROUND_ME -> AroundMeFeedFlow(locationFlow, followsRelays, proxyRelays)
+ GLOBAL_FOLLOWS -> {
+ GlobalFeedFlow(followsRelays, proxyRelays)
+ }
+
+ ALL_FOLLOWS -> {
+ AllFollowsFeedFlow(allFollows, followsRelays, blockedRelays, proxyRelays)
+ }
+
+ ALL_USER_FOLLOWS -> {
+ AllUserFollowsFeedFlow(allFollows, followsRelays, blockedRelays, proxyRelays)
+ }
+
+ KIND3_FOLLOWS -> {
+ Kind3UserFollowsFeedFlow(kind3Follows, followsRelays, blockedRelays, proxyRelays)
+ }
+
+ AROUND_ME -> {
+ AroundMeFeedFlow(locationFlow, followsRelays, proxyRelays)
+ }
+
else -> {
val note = LocalCache.checkGetOrCreateAddressableNote(listName)
if (note != null) {
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/NoteFeedFlow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/NoteFeedFlow.kt
index e6bc764df..a32aabae3 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/NoteFeedFlow.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/NoteFeedFlow.kt
@@ -68,21 +68,27 @@ class NoteFeedFlow(
AuthorsByOutboxTopNavFilter(caches.peopleListCache.cachedUserIdSet(noteEvent), blockedRelays)
}
}
+
is MuteListEvent -> {
MutedAuthorsByOutboxTopNavFilter(caches.muteListCache.cachedUserIdSet(noteEvent), blockedRelays)
}
+
is FollowListEvent -> {
AuthorsByOutboxTopNavFilter(noteEvent.followIdSet(), blockedRelays)
}
+
is CommunityListEvent -> {
AllCommunitiesTopNavFilter(caches.communityListCache.cachedCommunityIdSet(noteEvent), blockedRelays)
}
+
is HashtagListEvent -> {
HashtagTopNavFilter(caches.hashtagCache.cachedHashtags(noteEvent), outboxRelays)
}
+
is GeohashListEvent -> {
LocationTopNavFilter(caches.geohashCache.cachedGeohashes(noteEvent), outboxRelays)
}
+
is CommunityDefinitionEvent -> {
SingleCommunityTopNavFilter(
community = noteEvent.addressTag(),
@@ -91,7 +97,10 @@ class NoteFeedFlow(
blockedRelays = blockedRelays,
)
}
- else -> AuthorsByOutboxTopNavFilter(emptySet(), blockedRelays)
+
+ else -> {
+ AuthorsByOutboxTopNavFilter(emptySet(), blockedRelays)
+ }
}
suspend fun FlowCollector.processByOutbox(
@@ -106,21 +115,27 @@ class NoteFeedFlow(
emit(AuthorsByOutboxTopNavFilter(caches.peopleListCache.userIdSet(noteEvent), blockedRelays))
}
}
+
is MuteListEvent -> {
emit(MutedAuthorsByOutboxTopNavFilter(caches.muteListCache.mutedUserIdSet(noteEvent), blockedRelays))
}
+
is FollowListEvent -> {
emit(AuthorsByOutboxTopNavFilter(noteEvent.followIdSet(), blockedRelays))
}
+
is CommunityListEvent -> {
emit(AllCommunitiesTopNavFilter(caches.communityListCache.communityIdSet(noteEvent), blockedRelays))
}
+
is HashtagListEvent -> {
emit(HashtagTopNavFilter(caches.hashtagCache.hashtags(noteEvent), outboxRelays))
}
+
is GeohashListEvent -> {
emit(LocationTopNavFilter(caches.geohashCache.geohashes(noteEvent), outboxRelays))
}
+
is CommunityDefinitionEvent -> {
emit(
SingleCommunityTopNavFilter(
@@ -131,10 +146,12 @@ class NoteFeedFlow(
),
)
}
- else ->
+
+ else -> {
emit(
AuthorsByOutboxTopNavFilter(emptySet(), blockedRelays),
)
+ }
}
}
@@ -150,21 +167,27 @@ class NoteFeedFlow(
AuthorsByProxyTopNavFilter(caches.peopleListCache.cachedUserIdSet(noteEvent), proxyRelays)
}
}
+
is MuteListEvent -> {
MutedAuthorsByProxyTopNavFilter(caches.muteListCache.cachedUserIdSet(noteEvent), proxyRelays)
}
+
is FollowListEvent -> {
AuthorsByProxyTopNavFilter(noteEvent.followIdSet(), proxyRelays)
}
+
is CommunityListEvent -> {
AllCommunitiesTopNavFilter(caches.communityListCache.cachedCommunityIdSet(noteEvent), blockedRelays)
}
+
is HashtagListEvent -> {
HashtagTopNavFilter(caches.hashtagCache.cachedHashtags(noteEvent), proxyRelays)
}
+
is GeohashListEvent -> {
LocationTopNavFilter(caches.geohashCache.cachedGeohashes(noteEvent), proxyRelays)
}
+
is CommunityDefinitionEvent -> {
SingleCommunityTopNavFilter(
community = noteEvent.addressTag(),
@@ -173,7 +196,10 @@ class NoteFeedFlow(
blockedRelays = blockedRelays,
)
}
- else -> AuthorsByProxyTopNavFilter(emptySet(), proxyRelays)
+
+ else -> {
+ AuthorsByProxyTopNavFilter(emptySet(), proxyRelays)
+ }
}
suspend fun FlowCollector.processByProxy(
@@ -188,21 +214,27 @@ class NoteFeedFlow(
emit(AuthorsByProxyTopNavFilter(caches.peopleListCache.userIdSet(noteEvent), proxyRelays))
}
}
+
is MuteListEvent -> {
emit(MutedAuthorsByProxyTopNavFilter(caches.muteListCache.mutedUserIdSet(noteEvent), proxyRelays))
}
+
is FollowListEvent -> {
emit(AuthorsByProxyTopNavFilter(noteEvent.followIdSet(), proxyRelays))
}
+
is CommunityListEvent -> {
emit(AllCommunitiesTopNavFilter(caches.communityListCache.communityIdSet(noteEvent), blockedRelays))
}
+
is HashtagListEvent -> {
emit(HashtagTopNavFilter(caches.hashtagCache.hashtags(noteEvent), proxyRelays))
}
+
is GeohashListEvent -> {
emit(LocationTopNavFilter(caches.geohashCache.geohashes(noteEvent), proxyRelays))
}
+
is CommunityDefinitionEvent -> {
emit(
SingleCommunityTopNavFilter(
@@ -213,10 +245,12 @@ class NoteFeedFlow(
),
)
}
- else ->
+
+ else -> {
emit(
AuthorsByProxyTopNavFilter(emptySet(), proxyRelays),
)
+ }
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/EmojiUtils.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/EmojiUtils.kt
index d799190e4..010b382ad 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/EmojiUtils.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/EmojiUtils.kt
@@ -25,14 +25,16 @@ import com.vitorpamplona.amethyst.commons.model.ImmutableListOfLists
fun String.isUTF16Char(pos: Int): Boolean = Character.charCount(this.codePointAt(pos)) == 2
-fun String.firstFullCharOld(): String {
- return when (this.length) {
- 0,
- 1,
- -> return this
- 2,
- 3,
- -> return if (isUTF16Char(0)) this.take(2) else this.take(1)
+fun String.firstFullCharOld(): String =
+ when (this.length) {
+ 0, 1 -> {
+ this
+ }
+
+ 2, 3 -> {
+ if (isUTF16Char(0)) this.take(2) else this.take(1)
+ }
+
else -> {
val first = isUTF16Char(0)
val second = isUTF16Char(2)
@@ -45,7 +47,6 @@ fun String.firstFullCharOld(): String {
}
}
}
-}
fun String.firstFullChar(): String {
var isInJoin = false
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/HttpStatusMessages.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/HttpStatusMessages.kt
index 12331c0cf..76b1c4f48 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/HttpStatusMessages.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/HttpStatusMessages.kt
@@ -45,7 +45,6 @@ class HttpStatusMessages {
416 -> R.string.http_status_416
417 -> R.string.http_status_417
426 -> R.string.http_status_426
-
500 -> R.string.http_status_500
501 -> R.string.http_status_501
502 -> R.string.http_status_502
@@ -56,7 +55,6 @@ class HttpStatusMessages {
507 -> R.string.http_status_507
508 -> R.string.http_status_508
511 -> R.string.http_status_511
-
else -> null
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/ZapPaymentHandler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/ZapPaymentHandler.kt
index 98ed68b76..ae28e98d8 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/ZapPaymentHandler.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/ZapPaymentHandler.kt
@@ -97,6 +97,7 @@ class ZapPaymentHandler(
weight = setup.weight,
)
}
+
is ZapSplitSetup -> {
val user = LocalCache.checkGetOrCreateUser(setup.pubKeyHex)
UnverifiedZapSplitSetup(
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/broadcast/BroadcastTracker.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/broadcast/BroadcastTracker.kt
index 57f3d9d67..78d47aae3 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/broadcast/BroadcastTracker.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/broadcast/BroadcastTracker.kt
@@ -366,13 +366,21 @@ class BroadcastTracker {
// Recalculate status
val newStatus =
when {
- currentBroadcast.results.values.any { it is RelayResult.Pending || it is RelayResult.Retrying } ->
+ currentBroadcast.results.values.any { it is RelayResult.Pending || it is RelayResult.Retrying } -> {
BroadcastStatus.IN_PROGRESS
- currentBroadcast.results.all { it.value is RelayResult.Success } ->
+ }
+
+ currentBroadcast.results.all { it.value is RelayResult.Success } -> {
BroadcastStatus.SUCCESS
- currentBroadcast.results.none { it.value is RelayResult.Success } ->
+ }
+
+ currentBroadcast.results.none { it.value is RelayResult.Success } -> {
BroadcastStatus.FAILED
- else -> BroadcastStatus.PARTIAL
+ }
+
+ else -> {
+ BroadcastStatus.PARTIAL
+ }
}
currentBroadcast.copy(status = newStatus)
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt
index 92388afe7..c3160d01e 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt
@@ -157,6 +157,7 @@ class EventNotificationConsumer(
null
}
}
+
is SealedRumorEvent -> {
if (LocalCache.justConsume(event, null, false)) {
// new event
@@ -174,6 +175,7 @@ class EventNotificationConsumer(
null
}
}
+
else -> {
LocalCache.justConsume(event, null, false)
event
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/playback/composable/PlayerSurface.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/playback/composable/PlayerSurface.kt
deleted file mode 100644
index ecd357ef0..000000000
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/playback/composable/PlayerSurface.kt
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2025 Vitor Pamplona
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
- * Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-package com.vitorpamplona.amethyst.service.playback.composable
-
-import android.view.Surface
-import android.view.SurfaceView
-import android.view.TextureView
-import androidx.annotation.IntDef
-import androidx.compose.foundation.AndroidEmbeddedExternalSurface
-import androidx.compose.foundation.AndroidExternalSurface
-import androidx.compose.foundation.AndroidExternalSurfaceScope
-import androidx.compose.runtime.Composable
-import androidx.compose.ui.Modifier
-import androidx.media3.common.Player
-
-/**
- * Provides a dedicated drawing [Surface] for media playbacks using a [Player].
- *
- * The player's video output is displayed with either a [SurfaceView]/[AndroidExternalSurface] or a
- * [TextureView]/[AndroidEmbeddedExternalSurface].
- *
- * [Player] takes care of attaching the rendered output to the [Surface] and clearing it, when it is
- * destroyed.
- *
- * See
- * [Choosing a surface type](https://developer.android.com/media/media3/ui/playerview#surfacetype)
- * for more information.
- */
-@Composable
-fun PlayerSurface(
- player: Player,
- surfaceType: @SurfaceType Int = SURFACE_TYPE_SURFACE_VIEW,
- modifier: Modifier = Modifier,
-) {
- val onSurfaceCreated: (Surface) -> Unit = { surface -> player.setVideoSurface(surface) }
- val onSurfaceDestroyed: () -> Unit = { player.setVideoSurface(null) }
- val onSurfaceInitialized: AndroidExternalSurfaceScope.() -> Unit = {
- onSurface { surface, _, _ ->
- onSurfaceCreated(surface)
- surface.onDestroyed { onSurfaceDestroyed() }
- }
- }
-
- when (surfaceType) {
- SURFACE_TYPE_SURFACE_VIEW ->
- AndroidExternalSurface(modifier = modifier, onInit = onSurfaceInitialized)
- SURFACE_TYPE_TEXTURE_VIEW ->
- AndroidEmbeddedExternalSurface(modifier = modifier, onInit = onSurfaceInitialized)
- else -> throw IllegalArgumentException("Unrecognized surface type: $surfaceType")
- }
-}
-
-/**
- * The type of surface view used for media playbacks. One of [SURFACE_TYPE_SURFACE_VIEW] or
- * [SURFACE_TYPE_TEXTURE_VIEW].
- */
-@MustBeDocumented
-@Retention(AnnotationRetention.SOURCE)
-@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER)
-@IntDef(SURFACE_TYPE_SURFACE_VIEW, SURFACE_TYPE_TEXTURE_VIEW)
-annotation class SurfaceType
-
-/** Surface type equivalent to [SurfaceView] . */
-const val SURFACE_TYPE_SURFACE_VIEW = 1
-
-/** Surface type equivalent to [TextureView]. */
-const val SURFACE_TYPE_TEXTURE_VIEW = 2
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/BlurhashMetadataCalculator.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/BlurhashMetadataCalculator.kt
index 5071a8877..ef3b0aea1 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/BlurhashMetadataCalculator.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/BlurhashMetadataCalculator.kt
@@ -60,6 +60,7 @@ object BlurhashMetadataCalculator {
val bitmap = BitmapFactory.decodeByteArray(data, 0, data.size, createBitmapOptions())
processImage(bitmap, dimPrecomputed)
}
+
isVideo(mimeType) -> {
val retriever = MediaMetadataRetriever()
try {
@@ -69,7 +70,10 @@ object BlurhashMetadataCalculator {
retriever.release()
}
}
- else -> null to dimPrecomputed
+
+ else -> {
+ null to dimPrecomputed
+ }
}
fun computeFromUri(
@@ -82,11 +86,12 @@ object BlurhashMetadataCalculator {
return try {
when {
- isImage(mimeType) ->
+ isImage(mimeType) -> {
context.contentResolver.openInputStream(uri)?.use { stream ->
val bitmap = BitmapFactory.decodeStream(stream, null, createBitmapOptions())
processImage(bitmap, dimPrecomputed)
} ?: (null to dimPrecomputed)
+ }
isVideo(mimeType) -> {
val retriever = MediaMetadataRetriever()
@@ -98,7 +103,9 @@ object BlurhashMetadataCalculator {
}
}
- else -> null
+ else -> {
+ null
+ }
}
} catch (e: Exception) {
Log.w("BlurhashMetadataCalc", "Failed to compute metadata from uri", e)
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/MediaCompressor.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/MediaCompressor.kt
index cee89bdbe..f984e7288 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/MediaCompressor.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/MediaCompressor.kt
@@ -60,11 +60,16 @@ class MediaCompressor {
contentType?.startsWith("video", ignoreCase = true) == true -> {
VideoCompressionHelper.compressVideo(uri, contentType, applicationContext, mediaQuality, useH265)
}
+
contentType?.startsWith("image", ignoreCase = true) == true &&
!contentType.contains("gif") &&
- !contentType.contains("svg") ->
+ !contentType.contains("svg") -> {
compressImage(uri, contentType, applicationContext, mediaQuality)
- else -> MediaCompressorResult(uri, contentType, null)
+ }
+
+ else -> {
+ MediaCompressorResult(uri, contentType, null)
+ }
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt
index 54f28d5f2..4ac789e64 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt
@@ -150,9 +150,18 @@ fun uriToRoute(
val route =
when (nip19) {
- is NPub -> Route.Profile(nip19.hex)
- is NProfile -> Route.Profile(nip19.hex)
- is NNote -> Route.Note(nip19.hex)
+ is NPub -> {
+ Route.Profile(nip19.hex)
+ }
+
+ is NProfile -> {
+ Route.Profile(nip19.hex)
+ }
+
+ is NNote -> {
+ Route.Note(nip19.hex)
+ }
+
is NEvent -> {
routeFor(
note = LocalCache.getOrCreateNote(nip19.hex),
@@ -182,7 +191,9 @@ fun uriToRoute(
}
}
- else -> null
+ else -> {
+ null
+ }
}
if (route != null) {
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt
index 00ed13d6e..0e419e04c 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt
@@ -57,8 +57,11 @@ object MediaSaverToDisk {
onError: (Throwable) -> Any?,
) = withContext(Dispatchers.IO) {
when {
- videoUri.isNullOrBlank() -> return@withContext
- videoUri.startsWith("file") ->
+ videoUri.isNullOrBlank() -> {
+ return@withContext
+ }
+
+ videoUri.startsWith("file") -> {
save(
localFile = videoUri.toUri().toFile(),
mimeType = mimeType,
@@ -66,7 +69,9 @@ object MediaSaverToDisk {
onSuccess = onSuccess,
onError = onError,
)
- else ->
+ }
+
+ else -> {
downloadAndSave(
url = videoUri,
mimeType = mimeType,
@@ -75,6 +80,7 @@ object MediaSaverToDisk {
onSuccess = onSuccess,
onError = onError,
)
+ }
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMessageTagger.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMessageTagger.kt
index 1073b6562..b770c5473 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMessageTagger.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMessageTagger.kt
@@ -71,12 +71,25 @@ class NewMessageTagger(
val results = parseDirtyWordForKey(word)
when (val entity = results?.key?.entity) {
- is NPub -> addUserToMentions(dao.getOrCreateUser(entity.hex))
- is NProfile -> addUserToMentions(dao.getOrCreateUser(entity.hex))
+ is NPub -> {
+ addUserToMentions(dao.getOrCreateUser(entity.hex))
+ }
- is com.vitorpamplona.quartz.nip19Bech32.entities.NNote -> addNoteToReplyTos(dao.getOrCreateNote(entity.hex))
- is NEvent -> addNoteToReplyTos(dao.getOrCreateNote(entity.hex))
- is NEmbed -> addNoteToReplyTos(dao.getOrCreateNote(entity.event.id))
+ is NProfile -> {
+ addUserToMentions(dao.getOrCreateUser(entity.hex))
+ }
+
+ is com.vitorpamplona.quartz.nip19Bech32.entities.NNote -> {
+ addNoteToReplyTos(dao.getOrCreateNote(entity.hex))
+ }
+
+ is NEvent -> {
+ addNoteToReplyTos(dao.getOrCreateNote(entity.hex))
+ }
+
+ is NEmbed -> {
+ addNoteToReplyTos(dao.getOrCreateNote(entity.event.id))
+ }
is NAddress -> {
val note = dao.getOrCreateAddressableNote(entity.address())
@@ -86,6 +99,7 @@ class NewMessageTagger(
}
is NSec -> {}
+
is NRelay -> {}
}
}
@@ -104,6 +118,7 @@ class NewMessageTagger(
is NPub -> {
getNostrAddress(dao.getOrCreateUser(entity.hex).toNProfile(), results.restOfWord)
}
+
is NProfile -> {
getNostrAddress(dao.getOrCreateUser(entity.hex).toNProfile(), results.restOfWord)
}
@@ -111,6 +126,7 @@ class NewMessageTagger(
is com.vitorpamplona.quartz.nip19Bech32.entities.NNote -> {
getNostrAddress(dao.getOrCreateNote(entity.hex).toNEvent(), results.restOfWord)
}
+
is NEvent -> {
getNostrAddress(dao.getOrCreateNote(entity.hex).toNEvent(), results.restOfWord)
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/uploads/VoiceAnonymizer.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/uploads/VoiceAnonymizer.kt
index d9aaf8e6f..a8e6ff782 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/uploads/VoiceAnonymizer.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/uploads/VoiceAnonymizer.kt
@@ -306,7 +306,10 @@ class VoiceAnonymizer {
val randomShift = 0.9 + (Math.random() * 0.2)
baseFactor * randomShift
}
- else -> baseFactor
+
+ else -> {
+ baseFactor
+ }
}
val totalSamples = pcmData.size
val processedSamples = ArrayList(totalSamples)
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/broadcast/BroadcastDetailsSheet.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/broadcast/BroadcastDetailsSheet.kt
index 501de7c2b..d57c88079 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/broadcast/BroadcastDetailsSheet.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/broadcast/BroadcastDetailsSheet.kt
@@ -476,6 +476,7 @@ private fun RelayResultRow(
overflow = TextOverflow.Ellipsis,
)
}
+
is RelayResult.Timeout -> {
Text(
text = "Timeout",
@@ -483,6 +484,7 @@ private fun RelayResultRow(
color = warningColor,
)
}
+
is RelayResult.Retrying -> {
Text(
text = "Retrying...",
@@ -490,6 +492,7 @@ private fun RelayResultRow(
color = MaterialTheme.colorScheme.primary,
)
}
+
else -> {}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/broadcast/BroadcastSnackbar.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/broadcast/BroadcastSnackbar.kt
index 259e5910d..88aaf44be 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/broadcast/BroadcastSnackbar.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/broadcast/BroadcastSnackbar.kt
@@ -84,6 +84,7 @@ fun BroadcastSnackbarHost(
onViewDetails(broadcast)
}
}
+
SnackbarResult.Dismissed -> { /* No action */ }
}
}
@@ -104,8 +105,12 @@ private fun BroadcastSnackbarContent(snackbarData: SnackbarData) {
val containerColor =
when (broadcastVisuals?.broadcast?.status) {
- BroadcastStatus.FAILED -> Color(0xFF7F1D1D) // Dark red
- BroadcastStatus.PARTIAL -> Color(0xFF78350F) // Dark amber
+ BroadcastStatus.FAILED -> Color(0xFF7F1D1D)
+
+ // Dark red
+ BroadcastStatus.PARTIAL -> Color(0xFF78350F)
+
+ // Dark amber
else -> Color(0xFF1E3A5F) // Dark blue (default)
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt
index 8806bb469..ed5ac081a 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt
@@ -93,12 +93,17 @@ fun CashuPreview(
CrossfadeIfEnabled(targetState = cashuData, label = "CashuPreview", accountViewModel = accountViewModel) {
when (it) {
- is GenericLoadable.Loaded> -> CashuPreview(it.loaded, accountViewModel)
- is GenericLoadable.Error> ->
+ is GenericLoadable.Loaded> -> {
+ CashuPreview(it.loaded, accountViewModel)
+ }
+
+ is GenericLoadable.Error> -> {
Text(
text = "$cashutoken ",
style = LocalTextStyle.current.copy(textDirection = TextDirection.Content),
)
+ }
+
else -> {}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/LoadUrlPreview.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/LoadUrlPreview.kt
index 04a2e4983..d620de76a 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/LoadUrlPreview.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/LoadUrlPreview.kt
@@ -73,11 +73,13 @@ fun LoadUrlPreviewDirect(
is UrlPreviewState.Loaded -> {
RenderLoaded(state, url, callbackUri, accountViewModel)
}
+
is UrlPreviewState.Loading -> {
WaitAndDisplay {
DisplayUrlWithLoadingSymbol(url)
}
}
+
else -> {
ClickableUrl(urlText, url)
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/MyAsyncImage.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/MyAsyncImage.kt
index d21f3b731..9c29244c4 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/MyAsyncImage.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/MyAsyncImage.kt
@@ -87,6 +87,7 @@ fun MyAsyncImage(
}
}
}
+
is AsyncImagePainter.State.Error -> {
if (onError != null) {
if (ratio != null) {
@@ -102,6 +103,7 @@ fun MyAsyncImage(
ClickableUrl(urlText = imageUrl, url = imageUrl)
}
}
+
is AsyncImagePainter.State.Success -> {
SubcomposeAsyncImageContent(loadedImageModifier)
@@ -110,6 +112,7 @@ fun MyAsyncImage(
MediaAspectRatioCache.add(imageUrl, drawable.width, drawable.height)
}
}
+
else -> {}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt
index 2928fdb9d..73aa212b6 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt
@@ -160,7 +160,9 @@ fun RenderStrangeNamePreview() {
)
}
- is RegularTextSegment -> Text(word.segmentText)
+ is RegularTextSegment -> {
+ Text(word.segmentText)
+ }
}
}
}
@@ -180,12 +182,21 @@ fun RenderRegularPreview() {
when (word) {
// is ImageSegment -> ZoomableContentView(word.segmentText, state, accountViewModel)
// is LinkSegment -> LoadUrlPreview(word.segmentText, word.segmentText, accountViewModel)
- is EmojiSegment -> RenderCustomEmoji(word.segmentText, state)
+ is EmojiSegment -> {
+ RenderCustomEmoji(word.segmentText, state)
+ }
+
// is InvoiceSegment -> MayBeInvoicePreview(word.segmentText)
// is WithdrawSegment -> MayBeWithdrawal(word.segmentText)
// is CashuSegment -> CashuPreview(word.segmentText, accountViewModel)
- is EmailSegment -> ClickableEmail(word.segmentText)
- is PhoneSegment -> ClickablePhone(word.segmentText)
+ is EmailSegment -> {
+ ClickableEmail(word.segmentText)
+ }
+
+ is PhoneSegment -> {
+ ClickablePhone(word.segmentText)
+ }
+
is BechSegment -> {
CreateClickableText(
word.segmentText.substring(0, 10),
@@ -196,11 +207,19 @@ fun RenderRegularPreview() {
)
}
- is HashTagSegment -> HashTag(word, EmptyNav())
+ is HashTagSegment -> {
+ HashTag(word, EmptyNav())
+ }
+
// is HashIndexUserSegment -> TagLink(word, accountViewModel, nav)
// is HashIndexEventSegment -> TagLink(word, true, backgroundColorState, accountViewModel, nav)
- is SchemelessUrlSegment -> NoProtocolUrlRenderer(word)
- is RegularTextSegment -> Text(word.segmentText)
+ is SchemelessUrlSegment -> {
+ NoProtocolUrlRenderer(word)
+ }
+
+ is RegularTextSegment -> {
+ Text(word.segmentText)
+ }
}
}
}
@@ -219,16 +238,21 @@ fun RenderRegularPreview2() {
// is ImageSegment -> ZoomableContentView(word.segmentText, state, accountViewModel)
// is LinkSegment -> LoadUrlPreview(word.segmentText, word.segmentText, accountViewModel)
is EmojiSegment -> RenderCustomEmoji(word.segmentText, state)
+
// is InvoiceSegment -> MayBeInvoicePreview(word.segmentText)
// is WithdrawSegment -> MayBeWithdrawal(word.segmentText)
// is CashuSegment -> CashuPreview(word.segmentText, accountViewModel)
is EmailSegment -> ClickableEmail(word.segmentText)
+
is PhoneSegment -> ClickablePhone(word.segmentText)
+
// is BechSegment -> BechLink(word.segmentText, true, backgroundColor, accountViewModel, nav)
is HashTagSegment -> HashTag(word, EmptyNav())
+
// is HashIndexUserSegment -> TagLink(word, accountViewModel, nav)
// is HashIndexEventSegment -> TagLink(word, true, backgroundColorState, accountViewModel, nav)
is SchemelessUrlSegment -> NoProtocolUrlRenderer(word)
+
is RegularTextSegment -> Text(word.segmentText)
}
}
@@ -260,17 +284,23 @@ fun RenderRegularPreview3() {
when (word) {
// is ImageSegment -> ZoomableContentView(word.segmentText, state, accountViewModel)
is LinkSegment -> LoadUrlPreview(word.segmentText, word.segmentText, null, accountViewModel)
+
is EmojiSegment -> RenderCustomEmoji(word.segmentText, state)
+
// is InvoiceSegment -> MayBeInvoicePreview(word.segmentText)
// is WithdrawSegment -> MayBeWithdrawal(word.segmentText)
// is CashuSegment -> CashuPreview(word.segmentText, accountViewModel)
is EmailSegment -> ClickableEmail(word.segmentText)
+
is PhoneSegment -> ClickablePhone(word.segmentText)
+
// is BechSegment -> BechLink(word.segmentText, true, backgroundColor, accountViewModel, nav)
is HashTagSegment -> HashTag(word, EmptyNav())
+
// is HashIndexUserSegment -> TagLink(word, accountViewModel, nav)
// is HashIndexEventSegment -> TagLink(word, true, backgroundColorState, accountViewModel, nav)
is SchemelessUrlSegment -> NoProtocolUrlRenderer(word)
+
is RegularTextSegment -> Text(word.segmentText)
}
}
@@ -415,23 +445,38 @@ private fun RenderWordWithoutPreview(
when (word) {
// Don't preview Images
is ImageSegment -> ClickableUrl(word.segmentText, word.segmentText)
+
// Don't preview Videos
is VideoSegment -> ClickableUrl(word.segmentText, word.segmentText)
+
is LinkSegment -> ClickableUrl(word.segmentText, word.segmentText)
+
is EmojiSegment -> RenderCustomEmoji(word.segmentText, state)
+
// Don't offer to pay invoices
is InvoiceSegment -> Text(word.segmentText)
+
// Don't offer to withdraw
is WithdrawSegment -> Text(word.segmentText)
+
is CashuSegment -> Text(word.segmentText)
+
is EmailSegment -> ClickableEmail(word.segmentText)
+
is SecretEmoji -> Text(word.segmentText)
+
is PhoneSegment -> ClickablePhone(word.segmentText)
+
is BechSegment -> BechLink(word.segmentText, false, 0, backgroundColor, accountViewModel, nav)
+
is HashTagSegment -> HashTag(word, nav)
+
is HashIndexUserSegment -> TagLink(word, accountViewModel, nav)
+
is HashIndexEventSegment -> TagLink(word, false, 0, backgroundColor, accountViewModel, nav)
+
is SchemelessUrlSegment -> NoProtocolUrlRenderer(word)
+
is RegularTextSegment -> Text(word.segmentText)
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/SwipeToDelete.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/SwipeToDelete.kt
index fb6143160..9f28df570 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/SwipeToDelete.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/SwipeToDelete.kt
@@ -65,8 +65,14 @@ fun SwipeToDeleteContainer(
StartToEnd -> {
onStartToEnd()
}
- EndToStart -> return@rememberSwipeToDismissBoxState false
- Settled -> return@rememberSwipeToDismissBoxState false
+
+ EndToStart -> {
+ return@rememberSwipeToDismissBoxState false
+ }
+
+ Settled -> {
+ return@rememberSwipeToDismissBoxState false
+ }
}
return@rememberSwipeToDismissBoxState true
},
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt
index 15dad866a..751a98db3 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt
@@ -139,7 +139,7 @@ fun ZoomableContentView(
var dialogOpen by remember(content) { mutableStateOf(false) }
when (content) {
- is MediaUrlImage ->
+ is MediaUrlImage -> {
SensitivityWarning(content.contentWarning != null, accountViewModel) {
TwoSecondController(content) { controllerVisible ->
val mainImageModifier =
@@ -150,7 +150,9 @@ fun ZoomableContentView(
UrlImageView(content, contentScale, mainImageModifier, loadedImageModifier, controllerVisible, accountViewModel = accountViewModel)
}
}
- is MediaUrlVideo ->
+ }
+
+ is MediaUrlVideo -> {
SensitivityWarning(content.contentWarning != null, accountViewModel) {
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
VideoView(
@@ -171,7 +173,9 @@ fun ZoomableContentView(
)
}
}
- is MediaLocalImage ->
+ }
+
+ is MediaLocalImage -> {
TwoSecondController(content) { controllerVisible ->
val mainImageModifier =
Modifier
@@ -181,7 +185,9 @@ fun ZoomableContentView(
LocalImageView(content, contentScale, mainImageModifier, loadedImageModifier, controllerVisible, accountViewModel = accountViewModel)
}
- is MediaLocalVideo ->
+ }
+
+ is MediaLocalVideo -> {
content.localFile?.let {
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
VideoView(
@@ -198,6 +204,7 @@ fun ZoomableContentView(
)
}
}
+ }
}
if (dialogOpen) {
@@ -286,9 +293,11 @@ fun LocalImageView(
}
}
}
+
is AsyncImagePainter.State.Error -> {
BlankNote(loadedImageModifier)
}
+
is AsyncImagePainter.State.Success -> {
SubcomposeAsyncImageContent(loadedImageModifier)
@@ -310,6 +319,7 @@ fun LocalImageView(
}
}
}
+
else -> {}
}
}
@@ -405,9 +415,11 @@ fun UrlImageView(
}
}
}
+
is AsyncImagePainter.State.Error -> {
ClickableUrl(urlText = "${content.url} ", url = content.url)
}
+
is AsyncImagePainter.State.Success -> {
SubcomposeAsyncImageContent(loadedImageModifier)
@@ -418,6 +430,7 @@ fun UrlImageView(
MediaAspectRatioCache.add(content.url, drawable.width, drawable.height)
}
}
+
else -> {}
}
}
@@ -794,6 +807,7 @@ fun ShareMediaAction(
}
}
}
+
is MediaUrlVideo -> {
videoUri?.let {
if (videoUri.isNotEmpty()) {
@@ -832,6 +846,7 @@ fun ShareMediaAction(
}
}
}
+
is MediaLocalVideo -> {
content.localFile?.let { localFile ->
DropdownMenuItem(
@@ -843,6 +858,7 @@ fun ShareMediaAction(
)
}
}
+
else -> { /* No share option for other types */ }
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/DisplayErrorMessages.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/DisplayErrorMessages.kt
index 7ba88d8d8..936d50d7f 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/DisplayErrorMessages.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/DisplayErrorMessages.kt
@@ -39,7 +39,7 @@ fun DisplayErrorMessages(
openDialogMsg.value?.let { obj ->
when (obj) {
- is ResourceToastMsg ->
+ is ResourceToastMsg -> {
if (obj.params != null) {
InformationDialog(
stringRes(obj.titleResId),
@@ -55,16 +55,18 @@ fun DisplayErrorMessages(
toastManager.clearToasts()
}
}
+ }
- is StringToastMsg ->
+ is StringToastMsg -> {
InformationDialog(
obj.title,
obj.msg,
) {
toastManager.clearToasts()
}
+ }
- is ActionableStringToastMsg ->
+ is ActionableStringToastMsg -> {
InformationDialog(
obj.title,
obj.msg,
@@ -72,8 +74,9 @@ fun DisplayErrorMessages(
obj.action()
toastManager.clearToasts()
}
+ }
- is ThrowableToastMsg ->
+ is ThrowableToastMsg -> {
InformationDialog(
stringRes(obj.titleResId),
obj.msg,
@@ -81,8 +84,11 @@ fun DisplayErrorMessages(
) {
toastManager.clearToasts()
}
+ }
- is MultiErrorToastMsg -> MultiUserErrorMessageDialog(obj, accountViewModel, nav)
+ is MultiErrorToastMsg -> {
+ MultiUserErrorMessageDialog(obj, accountViewModel, nav)
+ }
}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt
index a8e578936..b85ba7c87 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt
@@ -87,24 +87,29 @@ fun routeForInner(
is AppDefinitionEvent -> {
Route.ContentDiscovery(noteEvent.id)
}
+
is IsInPublicChatChannel -> {
noteEvent.channelId()?.let {
Route.PublicChatChannel(it)
}
}
+
is ChannelCreateEvent -> {
Route.PublicChatChannel(noteEvent.id)
}
+
is LiveActivitiesEvent -> {
noteEvent.address().let {
Route.LiveActivityChannel(it.kind, it.pubKeyHex, it.dTag)
}
}
+
is LiveActivitiesChatMessageEvent -> {
noteEvent.activityAddress()?.let {
Route.LiveActivityChannel(it.kind, it.pubKeyHex, it.dTag)
}
}
+
is EphemeralChatEvent -> {
noteEvent.roomId()?.let {
Route.EphemeralChat(it.id, it.relayUrl.url)
@@ -124,16 +129,19 @@ fun routeForInner(
is CommunityDefinitionEvent -> {
Route.Community(noteEvent.kind, noteEvent.pubKey, noteEvent.dTag())
}
+
is GiftWrapEvent -> {
noteEvent.innerEventId?.let {
routeFor(LocalCache.getOrCreateNote(it), loggedIn)
}
}
+
is SealedRumorEvent -> {
noteEvent.innerEventId?.let {
routeFor(LocalCache.getOrCreateNote(it), loggedIn)
}
}
+
is AddressableEvent -> {
Route.Note(noteEvent.aTag().toTag())
}
@@ -232,23 +240,31 @@ fun routeReplyTo(
Route.PublicChatChannel(channelId, replyTo = note.idHex)
}
}
+
is LiveActivitiesChatMessageEvent -> {
noteEvent.activityAddress()?.let {
Route.LiveActivityChannel(it.kind, it.pubKeyHex, it.dTag, replyTo = note.idHex)
}
}
+
is EphemeralChatEvent -> {
noteEvent.roomId()?.let {
Route.EphemeralChat(it.id, it.relayUrl.url, replyTo = note.idHex)
}
}
- is PublicMessageEvent ->
+
+ is PublicMessageEvent -> {
Route.NewPublicMessage(
users = noteEvent.groupKeySet() - account.userProfile().pubkeyHex,
parentId = noteEvent.id,
)
- is TextNoteEvent -> Route.NewShortNote(baseReplyTo = note.idHex)
- is PrivateDmEvent ->
+ }
+
+ is TextNoteEvent -> {
+ Route.NewShortNote(baseReplyTo = note.idHex)
+ }
+
+ is PrivateDmEvent -> {
routeToMessage(
room = noteEvent.chatroomKey(account.userProfile().pubkeyHex),
draftMessage = null,
@@ -256,7 +272,9 @@ fun routeReplyTo(
draftId = null,
account = account,
)
- is ChatroomKeyable ->
+ }
+
+ is ChatroomKeyable -> {
routeToMessage(
room = noteEvent.chatroomKey(account.userProfile().pubkeyHex),
draftMessage = null,
@@ -264,6 +282,8 @@ fun routeReplyTo(
draftId = null,
account = account,
)
+ }
+
is CommentEvent -> {
if (noteEvent.isGeohashedScoped()) {
Route.GeoPost(replyTo = note.idHex)
@@ -274,7 +294,9 @@ fun routeReplyTo(
}
}
- else -> Route.GenericCommentPost(replyTo = note.idHex)
+ else -> {
+ Route.GenericCommentPost(replyTo = note.idHex)
+ }
}
}
@@ -286,10 +308,14 @@ suspend fun routeEditDraftTo(
val draft = account.draftsDecryptionCache.cachedDraft(noteEvent)
return when (draft) {
- is ChannelMessageEvent -> draft.channelId()?.let { Route.PublicChatChannel(it, draftId = note.idHex) }
+ is ChannelMessageEvent -> {
+ draft.channelId()?.let { Route.PublicChatChannel(it, draftId = note.idHex) }
+ }
+
is LiveActivitiesChatMessageEvent -> {
draft.activityAddress()?.let { Route.LiveActivityChannel(it.kind, it.pubKeyHex, it.dTag, draftId = note.idHex) }
}
+
is EphemeralChatEvent -> {
draft.roomId()?.let { Route.EphemeralChat(it.id, it.relayUrl.url, draftId = note.idHex) }
}
@@ -300,15 +326,21 @@ suspend fun routeEditDraftTo(
return Route.Room(room, draftId = note.idHex)
}
- is TextNoteEvent -> Route.NewShortNote(draft = note.idHex)
- is ClassifiedsEvent -> Route.NewProduct(draft = note.idHex)
+ is TextNoteEvent -> {
+ Route.NewShortNote(draft = note.idHex)
+ }
- is PublicMessageEvent ->
+ is ClassifiedsEvent -> {
+ Route.NewProduct(draft = note.idHex)
+ }
+
+ is PublicMessageEvent -> {
Route.NewPublicMessage(
users = draft.groupKeySet() - account.userProfile().pubkeyHex,
parentId = noteEvent.id,
draftId = note.idHex,
)
+ }
is CommentEvent -> {
if (draft.isGeohashedScoped()) {
@@ -320,6 +352,8 @@ suspend fun routeEditDraftTo(
}
}
- else -> null
+ else -> {
+ null
+ }
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt
index 8a22a6ee2..6cffc431e 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt
@@ -312,7 +312,6 @@ fun getRouteWithArguments(navController: NavHostController): Route? {
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
-
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
@@ -321,16 +320,13 @@ fun getRouteWithArguments(navController: NavHostController): Route? {
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
-
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
-
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
-
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
@@ -349,7 +345,6 @@ fun getRouteWithArguments(navController: NavHostController): Route? {
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
-
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
@@ -359,10 +354,7 @@ fun getRouteWithArguments(navController: NavHostController): Route? {
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
dest.hasRoute() -> entry.toRoute()
-
- else -> {
- null
- }
+ else -> null
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/topbars/FeedFilterSpinner.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/topbars/FeedFilterSpinner.kt
index 0a09013ba..a0ba5ef34 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/topbars/FeedFilterSpinner.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/topbars/FeedFilterSpinner.kt
@@ -179,6 +179,7 @@ fun FeedFilterSpinner(
lineHeight = 12.sp,
)
}
+
LocationState.LocationResult.Loading -> {
Text(
text = stringRes(R.string.loading_location),
@@ -252,6 +253,7 @@ fun RenderOption(
}
}
}
+
is HashtagName -> {
Row(
horizontalArrangement = Arrangement.Center,
@@ -260,6 +262,7 @@ fun RenderOption(
Text(text = option.name(), color = MaterialTheme.colorScheme.onSurface)
}
}
+
is ResourceName -> {
Row(
horizontalArrangement = Arrangement.Center,
@@ -271,6 +274,7 @@ fun RenderOption(
)
}
}
+
is PeopleListName -> {
Row(
horizontalArrangement = Arrangement.Center,
@@ -297,6 +301,7 @@ fun RenderOption(
Text(text = name, color = MaterialTheme.colorScheme.onSurface)
}
}
+
is CommunityName -> {
Row(
horizontalArrangement = Arrangement.Center,
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt
index 7e90f895a..dee03ea65 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt
@@ -221,8 +221,14 @@ fun RenderLikeGallery(
)
} else {
when (val shortReaction = reactionType) {
- "+" -> LikedIcon(modifier.size(Size19dp))
- "-" -> Text(text = "\uD83D\uDC4E", modifier = modifier)
+ "+" -> {
+ LikedIcon(modifier.size(Size19dp))
+ }
+
+ "-" -> {
+ Text(text = "\uD83D\uDC4E", modifier = modifier)
+ }
+
else -> {
if (EmojiCoder.isCoded(shortReaction)) {
DisplaySecretEmojiAsReaction(
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NIP05VerificationDisplay.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NIP05VerificationDisplay.kt
index d7bd8db7e..281f797ae 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NIP05VerificationDisplay.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NIP05VerificationDisplay.kt
@@ -243,13 +243,15 @@ fun DisplayStatusInner(
nav: INav,
) {
when (type) {
- "music" ->
+ "music" -> {
Icon(
imageVector = CustomHashTagIcons.Tunestr,
null,
modifier = Size15Modifier.padding(end = Size5dp),
tint = MaterialTheme.colorScheme.placeholderText,
)
+ }
+
else -> {}
}
@@ -408,41 +410,50 @@ fun RenderNIP05VerifiedSymbol(
) {
CrossfadeIfEnabled(targetState = state, accountViewModel = accountViewModel) {
when (it) {
- is Nip05VerifState.Verifying ->
+ is Nip05VerifState.Verifying -> {
Icon(
imageVector = Icons.Default.Downloading,
contentDescription = stringRes(id = R.string.nip05_checking),
modifier = modifier,
tint = Color.Yellow,
)
- is Nip05VerifState.NotStarted ->
+ }
+
+ is Nip05VerifState.NotStarted -> {
Icon(
imageVector = Icons.Default.Downloading,
contentDescription = stringRes(id = R.string.nip05_checking),
modifier = modifier,
tint = Color.Yellow,
)
- is Nip05VerifState.Verified ->
+ }
+
+ is Nip05VerifState.Verified -> {
Icon(
painter = painterRes(R.drawable.nip_05, compositionSizeReference),
contentDescription = stringRes(id = R.string.nip05_verified),
modifier = modifier,
tint = Color.Unspecified,
)
- is Nip05VerifState.Failed ->
+ }
+
+ is Nip05VerifState.Failed -> {
Icon(
imageVector = Icons.Default.Report,
contentDescription = stringRes(id = R.string.nip05_failed),
modifier = modifier,
tint = Color.Red,
)
- is Nip05VerifState.Error ->
+ }
+
+ is Nip05VerifState.Error -> {
Icon(
imageVector = Icons.Default.Report,
contentDescription = stringRes(id = R.string.nip05_failed),
modifier = modifier,
tint = Color.Red,
)
+ }
}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt
index f83dfe721..4ff83b259 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt
@@ -297,14 +297,16 @@ fun AcceptableNote(
if (isQuotedNote || isBoostedNote) {
val noteEvent = baseNote.event
when (noteEvent) {
- is ChannelCreateEvent ->
+ is ChannelCreateEvent -> {
RenderPublicChatChannelHeader(
channelId = noteEvent.id,
sendToChannel = true,
accountViewModel = accountViewModel,
nav = nav,
)
- is ChannelMetadataEvent ->
+ }
+
+ is ChannelMetadataEvent -> {
noteEvent.channelId()?.let {
RenderPublicChatChannelHeader(
channelId = it,
@@ -313,7 +315,9 @@ fun AcceptableNote(
nav = nav,
)
}
- is CommunityDefinitionEvent ->
+ }
+
+ is CommunityDefinitionEvent -> {
(baseNote as? AddressableNote)?.let {
RenderCommunity(
baseNote = it,
@@ -321,8 +325,13 @@ fun AcceptableNote(
nav = nav,
)
}
- is BadgeDefinitionEvent -> BadgeDisplay(baseNote = baseNote, accountViewModel)
- else ->
+ }
+
+ is BadgeDefinitionEvent -> {
+ BadgeDisplay(baseNote = baseNote, accountViewModel)
+ }
+
+ else -> {
LongPressToQuickAction(baseNote = baseNote, accountViewModel = accountViewModel, nav) { showPopup ->
CheckNewAndRenderNote(
baseNote = baseNote,
@@ -341,17 +350,20 @@ fun AcceptableNote(
moreOptions = moreOptions,
)
}
+ }
}
} else {
when (val noteEvent = baseNote.event) {
- is ChannelCreateEvent ->
+ is ChannelCreateEvent -> {
RenderPublicChatChannelHeader(
channelId = noteEvent.id,
sendToChannel = true,
accountViewModel = accountViewModel,
nav = nav,
)
- is ChannelMetadataEvent ->
+ }
+
+ is ChannelMetadataEvent -> {
noteEvent.channelId()?.let {
RenderPublicChatChannelHeader(
channelId = it,
@@ -360,7 +372,9 @@ fun AcceptableNote(
nav = nav,
)
}
- is CommunityDefinitionEvent ->
+ }
+
+ is CommunityDefinitionEvent -> {
(baseNote as? AddressableNote)?.let {
RenderCommunity(
baseNote = it,
@@ -368,8 +382,13 @@ fun AcceptableNote(
nav = nav,
)
}
- is BadgeDefinitionEvent -> BadgeDisplay(baseNote, accountViewModel)
- else ->
+ }
+
+ is BadgeDefinitionEvent -> {
+ BadgeDisplay(baseNote, accountViewModel)
+ }
+
+ else -> {
LongPressToQuickAction(baseNote, accountViewModel, nav) { showPopup ->
CheckNewAndRenderNote(
baseNote = baseNote,
@@ -388,6 +407,7 @@ fun AcceptableNote(
moreOptions = moreOptions,
)
}
+ }
}
}
}
@@ -717,34 +737,118 @@ private fun RenderNoteRow(
nav: INav,
) {
when (val noteEvent = baseNote.event) {
- is AppDefinitionEvent -> RenderAppDefinition(baseNote, accountViewModel, nav)
- is AudioTrackEvent -> RenderAudioTrack(baseNote, ContentScale.FillWidth, accountViewModel, nav)
- is AudioHeaderEvent -> RenderAudioHeader(baseNote, ContentScale.FillWidth, accountViewModel, nav)
- is DraftWrapEvent -> RenderDraft(baseNote, quotesLeft, unPackReply, backgroundColor, accountViewModel, nav)
- is ReactionEvent -> RenderReaction(baseNote, quotesLeft, backgroundColor, accountViewModel, nav)
- is RepostEvent -> RenderRepost(baseNote, quotesLeft, backgroundColor, accountViewModel, nav)
- is GenericRepostEvent -> RenderRepost(baseNote, quotesLeft, backgroundColor, accountViewModel, nav)
- is ReportEvent -> RenderReport(baseNote, quotesLeft, backgroundColor, accountViewModel, nav)
- is LongTextNoteEvent -> RenderLongFormContent(baseNote, accountViewModel, nav)
- is WikiNoteEvent -> RenderWikiContent(baseNote, accountViewModel, nav)
- is NipTextEvent -> RenderNipContent(baseNote, accountViewModel, nav)
- is BadgeAwardEvent -> RenderBadgeAward(baseNote, backgroundColor, accountViewModel, nav)
- is FhirResourceEvent -> RenderFhirResource(baseNote, accountViewModel, nav)
- is PeopleListEvent -> DisplayPeopleList(baseNote, backgroundColor, accountViewModel, nav)
- is FollowListEvent -> DisplayFollowList(baseNote, true, accountViewModel, nav)
- is RelaySetEvent -> DisplayRelaySet(baseNote, backgroundColor, accountViewModel, nav)
- is ChatMessageRelayListEvent -> DisplayDMRelayList(baseNote, backgroundColor, accountViewModel, nav)
- is AdvertisedRelayListEvent -> DisplayNIP65RelayList(baseNote, backgroundColor, accountViewModel, nav)
- is SearchRelayListEvent -> DisplaySearchRelayList(baseNote, backgroundColor, accountViewModel, nav)
- is BlockedRelayListEvent -> DisplayBlockedRelayList(baseNote, backgroundColor, accountViewModel, nav)
- is TrustedRelayListEvent -> DisplayTrustedRelayList(baseNote, backgroundColor, accountViewModel, nav)
- is IndexerRelayListEvent -> DisplayIndexerRelayList(baseNote, backgroundColor, accountViewModel, nav)
- is ProxyRelayListEvent -> DisplayProxyRelayList(baseNote, backgroundColor, accountViewModel, nav)
- is BroadcastRelayListEvent -> DisplayBroadcastRelayList(baseNote, backgroundColor, accountViewModel, nav)
- is PinListEvent -> RenderPinListEvent(baseNote, backgroundColor, accountViewModel, nav)
- is EmojiPackEvent -> RenderEmojiPack(baseNote, true, backgroundColor, accountViewModel)
- is LiveActivitiesEvent -> RenderLiveActivityEvent(baseNote, accountViewModel, nav)
- is GitRepositoryEvent -> RenderGitRepositoryEvent(baseNote, accountViewModel, nav)
+ is AppDefinitionEvent -> {
+ RenderAppDefinition(baseNote, accountViewModel, nav)
+ }
+
+ is AudioTrackEvent -> {
+ RenderAudioTrack(baseNote, ContentScale.FillWidth, accountViewModel, nav)
+ }
+
+ is AudioHeaderEvent -> {
+ RenderAudioHeader(baseNote, ContentScale.FillWidth, accountViewModel, nav)
+ }
+
+ is DraftWrapEvent -> {
+ RenderDraft(baseNote, quotesLeft, unPackReply, backgroundColor, accountViewModel, nav)
+ }
+
+ is ReactionEvent -> {
+ RenderReaction(baseNote, quotesLeft, backgroundColor, accountViewModel, nav)
+ }
+
+ is RepostEvent -> {
+ RenderRepost(baseNote, quotesLeft, backgroundColor, accountViewModel, nav)
+ }
+
+ is GenericRepostEvent -> {
+ RenderRepost(baseNote, quotesLeft, backgroundColor, accountViewModel, nav)
+ }
+
+ is ReportEvent -> {
+ RenderReport(baseNote, quotesLeft, backgroundColor, accountViewModel, nav)
+ }
+
+ is LongTextNoteEvent -> {
+ RenderLongFormContent(baseNote, accountViewModel, nav)
+ }
+
+ is WikiNoteEvent -> {
+ RenderWikiContent(baseNote, accountViewModel, nav)
+ }
+
+ is NipTextEvent -> {
+ RenderNipContent(baseNote, accountViewModel, nav)
+ }
+
+ is BadgeAwardEvent -> {
+ RenderBadgeAward(baseNote, backgroundColor, accountViewModel, nav)
+ }
+
+ is FhirResourceEvent -> {
+ RenderFhirResource(baseNote, accountViewModel, nav)
+ }
+
+ is PeopleListEvent -> {
+ DisplayPeopleList(baseNote, backgroundColor, accountViewModel, nav)
+ }
+
+ is FollowListEvent -> {
+ DisplayFollowList(baseNote, true, accountViewModel, nav)
+ }
+
+ is RelaySetEvent -> {
+ DisplayRelaySet(baseNote, backgroundColor, accountViewModel, nav)
+ }
+
+ is ChatMessageRelayListEvent -> {
+ DisplayDMRelayList(baseNote, backgroundColor, accountViewModel, nav)
+ }
+
+ is AdvertisedRelayListEvent -> {
+ DisplayNIP65RelayList(baseNote, backgroundColor, accountViewModel, nav)
+ }
+
+ is SearchRelayListEvent -> {
+ DisplaySearchRelayList(baseNote, backgroundColor, accountViewModel, nav)
+ }
+
+ is BlockedRelayListEvent -> {
+ DisplayBlockedRelayList(baseNote, backgroundColor, accountViewModel, nav)
+ }
+
+ is TrustedRelayListEvent -> {
+ DisplayTrustedRelayList(baseNote, backgroundColor, accountViewModel, nav)
+ }
+
+ is IndexerRelayListEvent -> {
+ DisplayIndexerRelayList(baseNote, backgroundColor, accountViewModel, nav)
+ }
+
+ is ProxyRelayListEvent -> {
+ DisplayProxyRelayList(baseNote, backgroundColor, accountViewModel, nav)
+ }
+
+ is BroadcastRelayListEvent -> {
+ DisplayBroadcastRelayList(baseNote, backgroundColor, accountViewModel, nav)
+ }
+
+ is PinListEvent -> {
+ RenderPinListEvent(baseNote, backgroundColor, accountViewModel, nav)
+ }
+
+ is EmojiPackEvent -> {
+ RenderEmojiPack(baseNote, true, backgroundColor, accountViewModel)
+ }
+
+ is LiveActivitiesEvent -> {
+ RenderLiveActivityEvent(baseNote, accountViewModel, nav)
+ }
+
+ is GitRepositoryEvent -> {
+ RenderGitRepositoryEvent(baseNote, accountViewModel, nav)
+ }
+
is GitPatchEvent -> {
RenderGitPatchEvent(
baseNote,
@@ -756,6 +860,7 @@ private fun RenderNoteRow(
nav,
)
}
+
is GitIssueEvent -> {
RenderGitIssueEvent(
baseNote,
@@ -767,6 +872,7 @@ private fun RenderNoteRow(
nav,
)
}
+
is PrivateDmEvent -> {
RenderPrivateMessage(
baseNote,
@@ -778,6 +884,7 @@ private fun RenderNoteRow(
nav,
)
}
+
is ChatMessageEvent -> {
RenderChatMessage(
baseNote,
@@ -790,6 +897,7 @@ private fun RenderNoteRow(
nav,
)
}
+
is ChatMessageEncryptedFileHeaderEvent -> {
RenderChatMessageEncryptedFile(
baseNote,
@@ -802,6 +910,7 @@ private fun RenderNoteRow(
nav,
)
}
+
is ClassifiedsEvent -> {
RenderClassifieds(
noteEvent,
@@ -810,6 +919,7 @@ private fun RenderNoteRow(
nav,
)
}
+
is HighlightEvent -> {
RenderHighlight(
baseNote,
@@ -821,6 +931,7 @@ private fun RenderNoteRow(
nav,
)
}
+
is CommentEvent -> {
RenderTextEvent(
baseNote,
@@ -834,7 +945,8 @@ private fun RenderNoteRow(
nav,
)
}
- is NIP90ContentDiscoveryResponseEvent ->
+
+ is NIP90ContentDiscoveryResponseEvent -> {
RenderNIP90ContentDiscoveryResponse(
baseNote,
makeItShort,
@@ -844,13 +956,15 @@ private fun RenderNoteRow(
accountViewModel,
nav,
)
+ }
- is NIP90StatusEvent ->
+ is NIP90StatusEvent -> {
RenderNIP90Status(
baseNote,
accountViewModel,
nav,
)
+ }
is PollNoteEvent -> {
RenderPoll(
@@ -864,14 +978,39 @@ private fun RenderNoteRow(
nav,
)
}
- is FileHeaderEvent -> FileHeaderDisplay(baseNote, true, ContentScale.FillWidth, accountViewModel)
- is VideoHorizontalEvent -> VideoDisplay(baseNote, makeItShort, canPreview, backgroundColor, ContentScale.FillWidth, accountViewModel, nav)
- is VideoVerticalEvent -> VideoDisplay(baseNote, makeItShort, canPreview, backgroundColor, ContentScale.FillWidth, accountViewModel, nav)
- is VideoNormalEvent -> VideoDisplay(baseNote, makeItShort, canPreview, backgroundColor, ContentScale.FillWidth, accountViewModel, nav)
- is VideoShortEvent -> VideoDisplay(baseNote, makeItShort, canPreview, backgroundColor, ContentScale.FillWidth, accountViewModel, nav)
- is PictureEvent -> PictureDisplay(baseNote, true, ContentScale.FillWidth, PaddingValues(vertical = 5.dp), backgroundColor, accountViewModel, nav)
- is BaseVoiceEvent -> RenderVoiceTrack(baseNote, accountViewModel, nav)
- is FileStorageHeaderEvent -> FileStorageHeaderDisplay(baseNote, true, ContentScale.FillWidth, accountViewModel)
+
+ is FileHeaderEvent -> {
+ FileHeaderDisplay(baseNote, true, ContentScale.FillWidth, accountViewModel)
+ }
+
+ is VideoHorizontalEvent -> {
+ VideoDisplay(baseNote, makeItShort, canPreview, backgroundColor, ContentScale.FillWidth, accountViewModel, nav)
+ }
+
+ is VideoVerticalEvent -> {
+ VideoDisplay(baseNote, makeItShort, canPreview, backgroundColor, ContentScale.FillWidth, accountViewModel, nav)
+ }
+
+ is VideoNormalEvent -> {
+ VideoDisplay(baseNote, makeItShort, canPreview, backgroundColor, ContentScale.FillWidth, accountViewModel, nav)
+ }
+
+ is VideoShortEvent -> {
+ VideoDisplay(baseNote, makeItShort, canPreview, backgroundColor, ContentScale.FillWidth, accountViewModel, nav)
+ }
+
+ is PictureEvent -> {
+ PictureDisplay(baseNote, true, ContentScale.FillWidth, PaddingValues(vertical = 5.dp), backgroundColor, accountViewModel, nav)
+ }
+
+ is BaseVoiceEvent -> {
+ RenderVoiceTrack(baseNote, accountViewModel, nav)
+ }
+
+ is FileStorageHeaderEvent -> {
+ FileStorageHeaderDisplay(baseNote, true, ContentScale.FillWidth, accountViewModel)
+ }
+
is CommunityPostApprovalEvent -> {
RenderPostApproval(
baseNote,
@@ -881,6 +1020,7 @@ private fun RenderNoteRow(
nav,
)
}
+
is TextNoteModificationEvent -> {
RenderTextModificationEvent(
baseNote,
@@ -892,7 +1032,8 @@ private fun RenderNoteRow(
nav,
)
}
- is ChannelMessageEvent ->
+
+ is ChannelMessageEvent -> {
RenderChannelMessage(
baseNote,
makeItShort,
@@ -903,7 +1044,9 @@ private fun RenderNoteRow(
accountViewModel,
nav,
)
- is LiveActivitiesChatMessageEvent ->
+ }
+
+ is LiveActivitiesChatMessageEvent -> {
RenderLiveActivityChatMessage(
baseNote,
makeItShort,
@@ -914,15 +1057,18 @@ private fun RenderNoteRow(
accountViewModel,
nav,
)
- is TorrentEvent ->
+ }
+
+ is TorrentEvent -> {
RenderTorrent(
baseNote,
backgroundColor,
accountViewModel,
nav,
)
+ }
- is TorrentCommentEvent ->
+ is TorrentCommentEvent -> {
RenderTorrentComment(
baseNote,
makeItShort,
@@ -934,8 +1080,9 @@ private fun RenderNoteRow(
accountViewModel,
nav,
)
+ }
- is InteractiveStoryBaseEvent ->
+ is InteractiveStoryBaseEvent -> {
RenderInteractiveStory(
baseNote,
makeItShort,
@@ -945,7 +1092,9 @@ private fun RenderNoteRow(
accountViewModel,
nav,
)
- is PublicMessageEvent ->
+ }
+
+ is PublicMessageEvent -> {
RenderPublicMessage(
baseNote,
makeItShort,
@@ -955,6 +1104,8 @@ private fun RenderNoteRow(
accountViewModel,
nav,
)
+ }
+
else -> {
RenderTextEvent(
baseNote,
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt
index f3582fb9a..128af382f 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt
@@ -962,8 +962,14 @@ private fun RenderReactionType(
)
} else {
when (reactionType) {
- "+" -> LikedIcon(iconSizeModifier)
- "-" -> Text(text = "\uD83D\uDC4E", maxLines = 1, fontSize = iconFontSize)
+ "+" -> {
+ LikedIcon(iconSizeModifier)
+ }
+
+ "-" -> {
+ Text(text = "\uD83D\uDC4E", maxLines = 1, fontSize = iconFontSize)
+ }
+
else -> {
if (EmojiCoder.isCoded(reactionType)) {
AnimatedBorderTextCornerRadius(
@@ -1611,6 +1617,7 @@ fun RenderReaction(reactionType: String) {
fontSize = 22.sp,
)
}
+
else -> {
if (EmojiCoder.isCoded(reactionType)) {
AnimatedBorderTextCornerRadius(
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt
index b446617d8..95116950f 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt
@@ -326,12 +326,15 @@ private fun RenderReactionOption(
)
}
}
- "-" ->
+
+ "-" -> {
Text(
text = "\uD83D\uDC4E ✖",
color = MaterialTheme.colorScheme.onBackground,
textAlign = TextAlign.Center,
)
+ }
+
else -> {
if (EmojiCoder.isCoded(reactionType)) {
Row(verticalAlignment = Alignment.CenterVertically) {
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt
index da65c0eb8..527758391 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt
@@ -584,9 +584,15 @@ fun authenticate(
super.onAuthenticationError(errorCode, errString)
when (errorCode) {
- BiometricPrompt.ERROR_NEGATIVE_BUTTON -> keyguardPrompt()
- BiometricPrompt.ERROR_LOCKOUT -> keyguardPrompt()
- else ->
+ BiometricPrompt.ERROR_NEGATIVE_BUTTON -> {
+ keyguardPrompt()
+ }
+
+ BiometricPrompt.ERROR_LOCKOUT -> {
+ keyguardPrompt()
+ }
+
+ else -> {
onError(
stringRes(context, R.string.biometric_authentication_failed),
stringRes(
@@ -595,6 +601,7 @@ fun authenticate(
errString.toString(),
),
)
+ }
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt
index 0c38a637e..979b796ac 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt
@@ -235,10 +235,13 @@ fun NonClickableUserPictures(
Box(Modifier.size(size), contentAlignment = Alignment.TopEnd) {
when (room.users.size) {
0 -> {}
- 1 ->
+
+ 1 -> {
LoadUser(baseUserHex = room.users.first(), accountViewModel) {
it?.let { BaseUserPicture(it, size, accountViewModel, outerModifier = Modifier) }
}
+ }
+
2 -> {
val userList = room.users.toList()
@@ -263,6 +266,7 @@ fun NonClickableUserPictures(
}
}
}
+
3 -> {
val userList = room.users.toList()
@@ -297,6 +301,7 @@ fun NonClickableUserPictures(
}
}
}
+
else -> {
val userList = room.users.toList()
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt
index 75f522771..2d9d789ae 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt
@@ -238,9 +238,11 @@ fun ZapCustomDialog(
LnZapEvent.ZapType.PUBLIC, LnZapEvent.ZapType.ANONYMOUS -> {
Text(text = stringRes(id = R.string.custom_zaps_add_a_message))
}
+
LnZapEvent.ZapType.PRIVATE -> {
Text(text = stringRes(id = R.string.custom_zaps_add_a_message_private))
}
+
LnZapEvent.ZapType.NONZAP -> {
Text(text = stringRes(id = R.string.custom_zaps_add_a_message_nonzap))
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/location/DisplayLocationObserver.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/location/DisplayLocationObserver.kt
index 2433084f2..4b2317218 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/location/DisplayLocationObserver.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/location/DisplayLocationObserver.kt
@@ -52,6 +52,7 @@ fun DisplayLocationObserver(viewModel: ILocationGrabber) {
lineHeight = 12.sp,
)
}
+
LocationState.LocationResult.Loading -> {
Text(
text = stringRes(R.string.loading_location),
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/previews/PreviewUrl.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/previews/PreviewUrl.kt
index 852cc5de2..f3a1c3956 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/previews/PreviewUrl.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/previews/PreviewUrl.kt
@@ -235,6 +235,7 @@ private fun MyLoadUrlPreviewDirect(
}
}
}
+
else -> {
Box(contentAlignment = Alignment.BottomCenter, modifier = Modifier.aspectRatio(1f)) {
ClickableUrl(urlText, url)
@@ -288,11 +289,13 @@ private fun MyLoadUrlPreviewDirectFillWidth(
UrlPreviewCard(url, previewInfo = state.previewInfo)
}
}
+
is UrlPreviewState.Loading -> {
WaitAndDisplay {
DisplayUrlWithLoadingSymbol(url)
}
}
+
else -> {
ClickableUrl(urlText, url)
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/zapsplits/DisplayZapSplits.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/zapsplits/DisplayZapSplits.kt
index 9e21cecee..9ef050b0e 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/zapsplits/DisplayZapSplits.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/zapsplits/DisplayZapSplits.kt
@@ -72,15 +72,18 @@ fun DisplayZapSplits(
FlowRow {
list.forEach {
when (it) {
- is ZapSplitSetupLnAddress ->
+ is ZapSplitSetupLnAddress -> {
ClickableTextPrimary(it.lnAddress) { }
- is ZapSplitSetup ->
+ }
+
+ is ZapSplitSetup -> {
UserPicture(
userHex = it.pubKeyHex,
size = Size25dp,
accountViewModel = accountViewModel,
nav = nav,
)
+ }
}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/DisplayExternalId.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/DisplayExternalId.kt
index fdc96d67e..8e72db0c1 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/DisplayExternalId.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/DisplayExternalId.kt
@@ -34,8 +34,14 @@ fun DisplayExternalId(
nav: INav,
) {
when (externalId) {
- is GeohashId -> DisplayGeohashExternalId(externalId, accountViewModel, nav)
- is HashtagId -> DisplayHashtagExternalId(externalId, accountViewModel, nav)
+ is GeohashId -> {
+ DisplayGeohashExternalId(externalId, accountViewModel, nav)
+ }
+
+ is HashtagId -> {
+ DisplayHashtagExternalId(externalId, accountViewModel, nav)
+ }
+
else -> {}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/LiveActivity.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/LiveActivity.kt
index b25cd4328..423726a97 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/LiveActivity.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/LiveActivity.kt
@@ -176,6 +176,7 @@ fun RenderLiveActivityEventInner(
}
StatusTag.STATUS.ENDED -> {}
+
null -> {}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/MedicalData.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/MedicalData.kt
index 65c6e5fe6..f26bbd40d 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/MedicalData.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/MedicalData.kt
@@ -201,9 +201,11 @@ fun RenderFhirResource(event: FhirResourceEvent) {
RenderEyeGlassesPrescription(it, state.localDb)
}
}
+
is VisionPrescription -> {
RenderEyeGlassesPrescription(resource, state.localDb)
}
+
else -> {
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt
index 259742e67..1fb1fa797 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt
@@ -119,12 +119,7 @@ class AccountStateViewModel : ViewModel() {
is NEmbed -> null
is NRelay -> null
is NAddress -> null
- else ->
- try {
- if (loginWithExternalSigner) Hex.decode(key) else null
- } catch (e: Exception) {
- null
- }
+ else -> runCatching { if (loginWithExternalSigner) Hex.decode(key) else null }
}
if (loginWithExternalSigner && pubKeyParsed == null) {
@@ -350,11 +345,15 @@ class AccountStateViewModel : ViewModel() {
fun currentAccountNPub() =
when (val state = _accountContent.value) {
- is AccountState.LoggedIn ->
+ is AccountState.LoggedIn -> {
state.account.signer.pubKey
.hexToByteArray()
.toNpub()
- else -> null
+ }
+
+ else -> {
+ null
+ }
}
fun logOff(accountInfo: AccountInfo) {
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedView.kt
index 17d57cedb..652c44eb6 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedView.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedView.kt
@@ -64,12 +64,15 @@ fun UserFeedView(
is UserFeedState.Empty -> {
FeedEmpty { viewModel.invalidateData() }
}
+
is UserFeedState.FeedError -> {
FeedError(state.errorMessage) { viewModel.invalidateData() }
}
+
is UserFeedState.Loaded -> {
FeedLoaded(state, accountViewModel, nav)
}
+
is UserFeedState.Loading -> {
LoadingFeed()
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt
index 0db89c7b5..319f7c810 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt
@@ -1637,19 +1637,24 @@ class AccountViewModel(
when (val parsed = it.entity) {
is NSec -> {}
+
is NPub -> {}
+
is NProfile -> {}
+
is NNote -> {
LocalCache.checkGetOrCreateNote(parsed.hex)?.let { note ->
returningNote = note
}
}
+
is NEvent -> {
LocalCache.checkGetOrCreateNote(parsed.hex)?.let { note ->
returningNote = note
}
}
- is NEmbed ->
+
+ is NEmbed -> {
withContext(Dispatchers.IO) {
val baseNote = LocalCache.getOrCreateNote(parsed.event)
if (baseNote.event == null) {
@@ -1660,13 +1665,16 @@ class AccountViewModel(
returningNote = baseNote
}
+ }
is NRelay -> {}
+
is NAddress -> {
LocalCache.checkGetOrCreateNote(parsed.aTag())?.let { note ->
returningNote = note
}
}
+
else -> {}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DecryptAndIndexProcessor.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DecryptAndIndexProcessor.kt
index 2c089083a..652d5c5e7 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DecryptAndIndexProcessor.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DecryptAndIndexProcessor.kt
@@ -195,19 +195,24 @@ class DraftEventHandler(
draftEventWrap.replyTo?.forEach { it.addReply(draftEventWrap) }
when (rumor) {
- is ChatroomKeyable -> account.chatroomList.add(rumor, draftEventWrap)
+ is ChatroomKeyable -> {
+ account.chatroomList.add(rumor, draftEventWrap)
+ }
+
is EphemeralChatEvent -> {
rumor.roomId()?.let { roomId ->
val channel = cache.getOrCreateEphemeralChannel(roomId)
channel.addNote(draftEventWrap, null)
}
}
+
is ChannelMessageEvent -> {
rumor.channelId()?.let { channelId ->
val channel = cache.checkGetOrCreatePublicChatChannel(channelId)
channel?.addNote(draftEventWrap, null)
}
}
+
is LiveActivitiesChatMessageEvent -> {
rumor.activityAddress()?.let { channelId ->
val channel = cache.getOrCreateLiveChannel(channelId)
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/default/BookmarkListScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/default/BookmarkListScreen.kt
index 590b64f22..4ccee13ed 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/default/BookmarkListScreen.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/default/BookmarkListScreen.kt
@@ -118,21 +118,23 @@ private fun RenderBookmarkScreen(
Column(Modifier.padding(it).fillMaxHeight()) {
HorizontalPager(state = pagerState) { page ->
when (page) {
- 0 ->
+ 0 -> {
RefresheableFeedView(
privateFeedViewModel,
null,
accountViewModel = accountViewModel,
nav = nav,
)
+ }
- 1 ->
+ 1 -> {
RefresheableFeedView(
publicFeedViewModel,
null,
accountViewModel = accountViewModel,
nav = nav,
)
+ }
}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/ArticleListView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/ArticleListView.kt
index 3b275b953..0c08afd98 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/ArticleListView.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/ArticleListView.kt
@@ -53,7 +53,7 @@ fun RenderArticleList(
HorizontalPager(pagerState, modifier) { page ->
when (page) {
- 0 ->
+ 0 -> {
ArticleList(
modifier = Modifier.fillMaxSize(),
articles = publicArticles,
@@ -67,7 +67,9 @@ fun RenderArticleList(
accountViewModel = accountViewModel,
nav = nav,
)
- 1 ->
+ }
+
+ 1 -> {
ArticleList(
modifier = Modifier.fillMaxSize(),
articles = privateArticles,
@@ -81,6 +83,7 @@ fun RenderArticleList(
accountViewModel = accountViewModel,
nav = nav,
)
+ }
}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupScreen.kt
index 1f8524a62..1a7605f9b 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupScreen.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupScreen.kt
@@ -157,7 +157,7 @@ fun BookmarkGroupScreenView(
.imePadding(),
) {
when (bookmarkType) {
- BookmarkType.PostBookmark ->
+ BookmarkType.PostBookmark -> {
RenderPostList(
bookmarkGroupViewModel,
pagerState,
@@ -182,7 +182,9 @@ fun BookmarkGroupScreenView(
},
nav,
)
- BookmarkType.ArticleBookmark ->
+ }
+
+ BookmarkType.ArticleBookmark -> {
RenderArticleList(
bookmarkGroupViewModel,
pagerState,
@@ -207,6 +209,7 @@ fun BookmarkGroupScreenView(
},
nav,
)
+ }
}
}
}
@@ -246,26 +249,32 @@ fun BookmarkGroupHeaderTabs(
val bookmarkGroup by bookmarkGroupViewModel.selectedBookmarkGroupFlow.collectAsStateWithLifecycle()
val privateItemTypeLabel =
when (bookmarkType) {
- BookmarkType.PostBookmark ->
+ BookmarkType.PostBookmark -> {
bookmarkGroup?.let {
stringRes(R.string.private_posts_count, it.privatePostBookmarks.size)
} ?: stringRes(R.string.private_posts_label)
- BookmarkType.ArticleBookmark ->
+ }
+
+ BookmarkType.ArticleBookmark -> {
bookmarkGroup?.let {
stringRes(R.string.private_articles_count, it.privateArticleBookmarks.size)
} ?: stringRes(R.string.private_posts_label)
+ }
}
val publicItemTypeLabel =
when (bookmarkType) {
- BookmarkType.PostBookmark ->
+ BookmarkType.PostBookmark -> {
bookmarkGroup?.let {
stringRes(R.string.public_posts_count, it.publicPostBookmarks.size)
} ?: stringRes(R.string.public_posts_label)
- BookmarkType.ArticleBookmark ->
+ }
+
+ BookmarkType.ArticleBookmark -> {
bookmarkGroup?.let {
stringRes(R.string.public_articles_count, it.publicArticleBookmarks.size)
} ?: stringRes(R.string.public_articles_label)
+ }
}
TabRow(
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/PostListView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/PostListView.kt
index 9b655a401..7312d0b3a 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/PostListView.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/PostListView.kt
@@ -52,7 +52,7 @@ fun RenderPostList(
HorizontalPager(pagerState, modifier) { page ->
when (page) {
- 0 ->
+ 0 -> {
PostList(
modifier = Modifier.fillMaxSize(),
posts = publicPosts,
@@ -66,7 +66,9 @@ fun RenderPostList(
accountViewModel = accountViewModel,
nav = nav,
)
- 1 ->
+ }
+
+ 1 -> {
PostList(
modifier = Modifier.fillMaxSize(),
posts = privatePosts,
@@ -80,6 +82,7 @@ fun RenderPostList(
accountViewModel = accountViewModel,
nav = nav,
)
+ }
}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/ChatFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/ChatFeedView.kt
index 32786401c..6bceec5d0 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/ChatFeedView.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/ChatFeedView.kt
@@ -84,10 +84,19 @@ fun RenderChatFeedView(
CrossfadeIfEnabled(targetState = feedState, animationSpec = tween(durationMillis = 100), accountViewModel = accountViewModel) { state ->
when (state) {
- is FeedState.Loading -> LoadingFeed()
- is FeedState.Empty -> FeedEmpty { feed.invalidateData() }
- is FeedState.FeedError -> FeedError(state.errorMessage) { feed.invalidateData() }
- is FeedState.Loaded ->
+ is FeedState.Loading -> {
+ LoadingFeed()
+ }
+
+ is FeedState.Empty -> {
+ FeedEmpty { feed.invalidateData() }
+ }
+
+ is FeedState.FeedError -> {
+ FeedError(state.errorMessage) { feed.invalidateData() }
+ }
+
+ is FeedState.Loaded -> {
ChatFeedLoaded(
state,
accountViewModel,
@@ -98,6 +107,7 @@ fun RenderChatFeedView(
onWantsToEditDraft,
avoidDraft,
)
+ }
}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelFileUploadDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelFileUploadDialog.kt
index 4a608ce9f..1888c8b5e 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelFileUploadDialog.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelFileUploadDialog.kt
@@ -93,6 +93,7 @@ fun ChannelFileUploadDialog(
}
}
}
+
is LiveActivitiesChannel -> {
channel.creator?.let {
UserPicture(
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/ChatroomHeaderCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/ChatroomHeaderCompose.kt
index c96afa9e6..a663c1bb8 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/ChatroomHeaderCompose.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/ChatroomHeaderCompose.kt
@@ -120,26 +120,33 @@ private fun ChatroomEntry(
) {
val baseNoteEvent = lastMessage.event
when (baseNoteEvent) {
- is ChannelMessageEvent ->
+ is ChannelMessageEvent -> {
baseNoteEvent.channelId()?.let {
LoadPublicChatChannel(it, accountViewModel) { channel ->
ChannelRoomCompose(lastMessage, channel, accountViewModel, nav)
}
}
- is ChannelMetadataEvent ->
+ }
+
+ is ChannelMetadataEvent -> {
baseNoteEvent.channelId()?.let {
LoadPublicChatChannel(it, accountViewModel) { channel ->
ChannelRoomCompose(lastMessage, channel, accountViewModel, nav)
}
}
- is ChannelCreateEvent ->
+ }
+
+ is ChannelCreateEvent -> {
LoadPublicChatChannel(baseNoteEvent.id, accountViewModel) { channel ->
ChannelRoomCompose(lastMessage, channel, accountViewModel, nav)
}
+ }
+
is ChatroomKeyable -> {
val room = baseNoteEvent.chatroomKey(accountViewModel.userProfile().pubkeyHex)
UserRoomCompose(room, lastMessage, accountViewModel, nav)
}
+
is EphemeralChatEvent -> {
baseNoteEvent.roomId()?.let {
LoadEphemeralChatChannel(it, accountViewModel) { channel ->
@@ -147,7 +154,10 @@ private fun ChatroomEntry(
}
}
}
- else -> BlankNote()
+
+ else -> {
+ BlankNote()
+ }
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/MessagesScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/MessagesScreen.kt
index c6644e864..ab8ac1842 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/MessagesScreen.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/MessagesScreen.kt
@@ -47,9 +47,11 @@ fun MessagesScreen(
derivedStateOf {
when (windowSizeClass.widthSizeClass) {
WindowWidthSizeClass.Compact -> false
+
WindowWidthSizeClass.Expanded,
WindowWidthSizeClass.Medium,
-> true
+
else -> false
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/feed/ChatroomListFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/feed/ChatroomListFeedView.kt
index 842aaf063..60d6fc142 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/feed/ChatroomListFeedView.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/feed/ChatroomListFeedView.kt
@@ -77,12 +77,15 @@ private fun CrossFadeState(
is FeedState.Empty -> {
FeedEmpty { feedContentState.invalidateData() }
}
+
is FeedState.FeedError -> {
FeedError(state.errorMessage) { feedContentState.invalidateData() }
}
+
is FeedState.Loaded -> {
FeedLoaded(state, listState, accountViewModel, nav)
}
+
FeedState.Loading -> {
LoadingFeed()
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/CommunityScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/CommunityScreen.kt
index 9bf5a5340..f8a51f670 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/CommunityScreen.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/CommunityScreen.kt
@@ -196,20 +196,23 @@ fun CommunityScreen(
state = pagerState,
) { page ->
when (page) {
- 0 ->
+ 0 -> {
RefresheableFeedView(
feedViewModel,
null,
accountViewModel = accountViewModel,
nav = nav,
)
- 1 ->
+ }
+
+ 1 -> {
RefresheableFeedView(
modFeedViewModel,
null,
accountViewModel = accountViewModel,
nav = nav,
)
+ }
}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/DiscoverScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/DiscoverScreen.kt
index 14d2de4c1..a4ec83354 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/DiscoverScreen.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/DiscoverScreen.kt
@@ -305,9 +305,11 @@ private fun RenderDiscoverFeed(
is FeedState.Empty -> {
FeedEmpty(feedContentState::invalidateData)
}
+
is FeedState.FeedError -> {
FeedError(state.errorMessage, feedContentState::invalidateData)
}
+
is FeedState.Loaded -> {
DiscoverFeedColumnsLoaded(
state,
@@ -318,6 +320,7 @@ private fun RenderDiscoverFeed(
nav,
)
}
+
is FeedState.Loading -> {
LoadingFeed()
}
@@ -368,9 +371,11 @@ private fun RenderDiscoverFeed(
is FeedState.Empty -> {
FeedEmpty(feedContentState::invalidateData)
}
+
is FeedState.FeedError -> {
FeedError(state.errorMessage, feedContentState::invalidateData)
}
+
is FeedState.Loaded -> {
DiscoverFeedLoaded(
state,
@@ -381,6 +386,7 @@ private fun RenderDiscoverFeed(
nav,
)
}
+
is FeedState.Loading -> {
LoadingFeed()
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/DiscoverLiveFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/DiscoverLiveFeedFilter.kt
index b85001433..9b0e8e684 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/DiscoverLiveFeedFilter.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/DiscoverLiveFeedFilter.kt
@@ -124,9 +124,18 @@ open class DiscoverLiveFeedFilter(
2
}
}
- StatusTag.STATUS.PLANNED -> 1
- StatusTag.STATUS.ENDED -> 0
- else -> 0
+
+ StatusTag.STATUS.PLANNED -> {
+ 1
+ }
+
+ StatusTag.STATUS.ENDED -> {
+ 0
+ }
+
+ else -> {
+ 0
+ }
}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/LiveActivityCard.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/LiveActivityCard.kt
index eb87481d8..41fffe055 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/LiveActivityCard.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/LiveActivityCard.kt
@@ -167,12 +167,15 @@ fun RenderLiveActivityThumb(
}
}
}
+
StatusTag.STATUS.ENDED -> {
EndedFlag()
}
+
StatusTag.STATUS.PLANNED -> {
ScheduledFlag(card.starts)
}
+
else -> {
EndedFlag()
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/FollowPackFeedScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/FollowPackFeedScreen.kt
index 999c5e0e1..a83c8860a 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/FollowPackFeedScreen.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/FollowPackFeedScreen.kt
@@ -176,26 +176,31 @@ fun FollowPackFeedScreen(
state = pagerState,
) { page ->
when (page) {
- 0 ->
+ 0 -> {
RefresheableFeedView(
newThreadFeedViewModel,
null,
accountViewModel = accountViewModel,
nav = nav,
)
- 1 ->
+ }
+
+ 1 -> {
RefresheableFeedView(
conversationsFeedViewModel,
null,
accountViewModel = accountViewModel,
nav = nav,
)
- 2 ->
+ }
+
+ 2 -> {
UserFeedView(
membersFeedViewModel,
accountViewModel,
nav,
)
+ }
}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt
index e2bf11d5f..06fca2a82 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt
@@ -239,8 +239,12 @@ fun HomeScreenFloatingButton(
.collectAsStateWithLifecycle()
when (val myLocation = location) {
- is LocationState.LocationResult.Success -> NewGeoPostButton(myLocation.geoHash.toString(), accountViewModel, nav)
+ is LocationState.LocationResult.Success -> {
+ NewGeoPostButton(myLocation.geoHash.toString(), accountViewModel, nav)
+ }
+
is LocationState.LocationResult.LackPermission -> { }
+
is LocationState.LocationResult.Loading -> { }
}
} else {
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt
index 8d1117337..ffe5d55b1 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt
@@ -581,10 +581,22 @@ open class ShortNotePostViewModel :
val quotes = event.taggedQuotes()
if (quotes.isNotEmpty()) "Quote" else "Post"
}
- is PollNoteEvent -> "Poll"
- is VoiceEvent -> "Voice"
- is VoiceReplyEvent -> "Voice Reply"
- else -> "Post"
+
+ is PollNoteEvent -> {
+ "Poll"
+ }
+
+ is VoiceEvent -> {
+ "Voice"
+ }
+
+ is VoiceReplyEvent -> {
+ "Voice Reply"
+ }
+
+ else -> {
+ "Post"
+ }
}
suspend fun sendDraftSync() {
@@ -1115,6 +1127,7 @@ open class ShortNotePostViewModel :
voiceLocalFile = null
voiceRecording = null
}
+
is UploadOrchestrator.OrchestratorResult.NIP95Result -> {
// For NIP95, we need to create the event and get the nevent URL
// This is handled differently - skip for now
@@ -1122,6 +1135,7 @@ open class ShortNotePostViewModel :
}
}
}
+
is UploadingState.Error -> {
onError(uploadErrorTitle, uploadVoiceFailed)
voiceRecording = null
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/VoiceReplyViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/VoiceReplyViewModel.kt
index 4ffafb4b2..d20e9d3a4 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/VoiceReplyViewModel.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/VoiceReplyViewModel.kt
@@ -286,14 +286,17 @@ class VoiceReplyViewModel : ViewModel() {
onSuccess()
}
+
is UploadOrchestrator.OrchestratorResult.NIP95Result -> {
accountViewModel.toastManager.toast(uploadErrorTitle, uploadVoiceNip95NotSupported)
}
}
}
+
is UploadingState.Error -> {
accountViewModel.toastManager.toast(uploadErrorTitle, uploadVoiceFailed)
}
+
else -> {
accountViewModel.toastManager.toast(uploadErrorTitle, uploadVoiceFailed)
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/live/LiveStatusIndicator.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/live/LiveStatusIndicator.kt
index cefeeaa5c..fdf604366 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/live/LiveStatusIndicator.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/live/LiveStatusIndicator.kt
@@ -94,12 +94,16 @@ private suspend fun checkChannelIsOnline(
}
}
}
+
is EphemeralChatChannel -> {
// Check relay connection for ephemeral chat
val relayUrl = channel.roomId.relayUrl
OnlineChecker.isOnline(relayUrl.url, accountViewModel.httpClientBuilder::okHttpClientForVideo)
}
- else -> false
+
+ else -> {
+ false
+ }
}
} catch (e: Exception) {
Log.d("LiveStatusIndicator", "Network error checking channel ${channel.toBestDisplayName()}: ${e.message}")
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListScreen.kt
index 84e4f4432..39dc82869 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListScreen.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListScreen.kt
@@ -268,7 +268,7 @@ private fun PeopleListPager(
selectedSetState.value?.let { selectedSet ->
HorizontalPager(state = pagerState, modifier) { page ->
when (page) {
- 0 ->
+ 0 -> {
PeopleListView(
memberList = selectedSet.publicMembersList,
onDeleteUser = { user ->
@@ -278,8 +278,9 @@ private fun PeopleListPager(
accountViewModel = accountViewModel,
nav = nav,
)
+ }
- 1 ->
+ 1 -> {
PeopleListView(
memberList = selectedSet.privateMembersList,
onDeleteUser = { user ->
@@ -289,6 +290,7 @@ private fun PeopleListPager(
accountViewModel = accountViewModel,
nav = nav,
)
+ }
}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedView.kt
index cfefe5628..99dcaf5d5 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedView.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedView.kt
@@ -119,9 +119,11 @@ fun RenderCardFeed(
is CardFeedState.Empty -> {
NotificationFeedEmpty(feedContent::invalidateData)
}
+
is CardFeedState.FeedError -> {
FeedError(state.errorMessage, feedContent::invalidateData)
}
+
is CardFeedState.Loaded -> {
FeedLoaded(
loaded = state,
@@ -131,6 +133,7 @@ fun RenderCardFeed(
nav = nav,
)
}
+
CardFeedState.Loading -> {
LoadingFeed()
}
@@ -205,7 +208,7 @@ private fun RenderCardItem(
nav: INav,
) {
when (item) {
- is NoteCard ->
+ is NoteCard -> {
NoteCardCompose(
item,
routeForLastRead = routeForLastRead,
@@ -214,7 +217,9 @@ private fun RenderCardItem(
accountViewModel = accountViewModel,
nav = nav,
)
- is ZapUserSetCard ->
+ }
+
+ is ZapUserSetCard -> {
ZapUserSetCompose(
item,
isInnerNote = false,
@@ -222,7 +227,9 @@ private fun RenderCardItem(
nav = nav,
routeForLastRead = routeForLastRead,
)
- is MultiSetCard ->
+ }
+
+ is MultiSetCard -> {
MultiSetCompose(
item,
accountViewModel = accountViewModel,
@@ -230,14 +237,18 @@ private fun RenderCardItem(
nav = nav,
routeForLastRead = routeForLastRead,
)
- is BadgeCard ->
+ }
+
+ is BadgeCard -> {
BadgeCompose(
item,
accountViewModel = accountViewModel,
nav = nav,
routeForLastRead = routeForLastRead,
)
- is MessageSetCard ->
+ }
+
+ is MessageSetCard -> {
MessageSetCompose(
messageSetCard = item,
routeForLastRead = routeForLastRead,
@@ -245,6 +256,7 @@ private fun RenderCardItem(
accountViewModel = accountViewModel,
nav = nav,
)
+ }
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt
index 782b18011..03aaa59eb 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt
@@ -173,14 +173,17 @@ fun GalleryContentView(
) {
AutoNonlazyGrid(contentList.size) { contentIndex ->
when (val content = contentList[contentIndex]) {
- is MediaUrlImage ->
+ is MediaUrlImage -> {
SensitivityWarning(content.contentWarning != null, accountViewModel) {
UrlImageView(content, accountViewModel, ratio = ratio)
}
- is MediaUrlVideo ->
+ }
+
+ is MediaUrlVideo -> {
SensitivityWarning(content.contentWarning != null, accountViewModel) {
UrlVideoView(content, accountViewModel, ratio = ratio)
}
+ }
}
}
}
@@ -226,12 +229,15 @@ fun UrlImageView(
}
}
}
+
is AsyncImagePainter.State.Error -> {
ClickableUrl(urlText = "${content.url} ", url = content.url)
}
+
is AsyncImagePainter.State.Success -> {
SubcomposeAsyncImageContent(defaultModifier)
}
+
else -> {}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/ProfileGalleryFeed.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/ProfileGalleryFeed.kt
index f2ea87652..a7bdbf0b0 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/ProfileGalleryFeed.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/ProfileGalleryFeed.kt
@@ -61,9 +61,11 @@ fun RenderGalleryFeed(
is FeedState.Empty -> {
FeedEmpty { viewModel.invalidateData() }
}
+
is FeedState.FeedError -> {
FeedError(state.errorMessage) { viewModel.invalidateData() }
}
+
is FeedState.Loaded -> {
GalleryFeedLoaded(
state,
@@ -72,6 +74,7 @@ fun RenderGalleryFeed(
nav,
)
}
+
is FeedState.Loading -> {
LoadingFeed()
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/dal/UserProfileGalleryFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/dal/UserProfileGalleryFeedFilter.kt
index e07ae66bb..83a1f3986 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/dal/UserProfileGalleryFeedFilter.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/dal/UserProfileGalleryFeedFilter.kt
@@ -51,8 +51,7 @@ class UserProfileGalleryFeedFilter(
acceptableEvent(it, params, user)
}
- var sorted = sort(notes)
- return sorted.toList()
+ return sort(notes).toList()
}
override fun applyFilter(newItems: Set): Set = innerApplyFilter(newItems)
@@ -70,7 +69,13 @@ class UserProfileGalleryFeedFilter(
): Boolean {
val noteEvent = it.event
return (
- (it.event?.pubKey == user.pubkeyHex && (noteEvent is PictureEvent || noteEvent is VideoEvent || (noteEvent is ProfileGalleryEntryEvent) && noteEvent.hasUrl() && noteEvent.hasFromEvent())) // && noteEvent.isOneOf(SUPPORTED_VIDEO_FEED_MIME_TYPES_SET))
+ (
+ it.event?.pubKey == user.pubkeyHex && (
+ noteEvent is PictureEvent ||
+ noteEvent is VideoEvent ||
+ (noteEvent is ProfileGalleryEntryEvent && noteEvent.hasUrl() && noteEvent.hasFromEvent())
+ )
+ ) // && noteEvent.isOneOf(SUPPORTED_VIDEO_FEED_MIME_TYPES_SET))
) &&
params.match(noteEvent, it.relays) &&
account.isAcceptable(it)
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DrawAdditionalInfo.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DrawAdditionalInfo.kt
index fd3023df8..6859af7b6 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DrawAdditionalInfo.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DrawAdditionalInfo.kt
@@ -261,6 +261,7 @@ fun DisplayNip05ProfileStatus(
)
}
}
+
else -> { }
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/apps/DisplayAppRecommendations.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/apps/DisplayAppRecommendations.kt
index 8c0610a10..7472571ce 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/apps/DisplayAppRecommendations.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/apps/DisplayAppRecommendations.kt
@@ -63,6 +63,7 @@ fun DisplayAppRecommendations(
Recommends(state, accountViewModel, nav)
}
}
+
else -> {}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/qrcode/ShowQRScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/qrcode/ShowQRScreen.kt
index 218f2d6a4..f8281aa32 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/qrcode/ShowQRScreen.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/qrcode/ShowQRScreen.kt
@@ -263,13 +263,17 @@ fun WatchAndDisplayNip05Row(
val nip05StateMetadata by user.nip05State().flow.collectAsStateWithLifecycle()
when (val nip05State = nip05StateMetadata) {
- is Nip05State.Exists -> ObserveAndDisplayNIP05(nip05State, accountViewModel)
- else ->
+ is Nip05State.Exists -> {
+ ObserveAndDisplayNIP05(nip05State, accountViewModel)
+ }
+
+ else -> {
Text(
text = user.pubkeyDisplayHex(),
fontSize = Font14SP,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
+ }
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt
index e72f6ecfa..c45474b94 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt
@@ -316,7 +316,7 @@ private fun RenderDebugMessage(msg: IRelayDebugMessage) {
}
when (msg) {
- is ErrorDebugMessage ->
+ is ErrorDebugMessage -> {
SelectionContainer {
Text(
text = msg.message,
@@ -324,7 +324,9 @@ private fun RenderDebugMessage(msg: IRelayDebugMessage) {
color = MaterialTheme.colorScheme.onSurface,
)
}
- is NoticeDebugMessage ->
+ }
+
+ is NoticeDebugMessage -> {
SelectionContainer {
Text(
text = msg.message,
@@ -332,7 +334,9 @@ private fun RenderDebugMessage(msg: IRelayDebugMessage) {
color = MaterialTheme.colorScheme.onSurface,
)
}
- is SpamDebugMessage ->
+ }
+
+ is SpamDebugMessage -> {
SelectionContainer {
val uri = LocalUriHandler.current
val start = stringRes(R.string.duplicated_post)
@@ -358,6 +362,7 @@ private fun RenderDebugMessage(msg: IRelayDebugMessage) {
color = MaterialTheme.colorScheme.onSurface,
)
}
+ }
}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/StringFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/StringFeedView.kt
index c2caa8859..ca6b77d74 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/StringFeedView.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/StringFeedView.kt
@@ -59,12 +59,15 @@ fun StringFeedView(
is StringFeedState.Empty -> {
StringFeedEmpty(pre, post) { viewModel.invalidateData() }
}
+
is StringFeedState.FeedError -> {
FeedError(state.errorMessage) { viewModel.invalidateData() }
}
+
is StringFeedState.Loaded -> {
FeedLoaded(state, pre, post, inner)
}
+
is StringFeedState.Loading -> {
LoadingFeed()
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt
index 32823ce3b..27bb11390 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt
@@ -190,12 +190,15 @@ fun RenderPage(
is FeedState.Empty -> {
FeedEmpty(videoFeedContentState::invalidateData)
}
+
is FeedState.FeedError -> {
FeedError(state.errorMessage, videoFeedContentState::invalidateData)
}
+
is FeedState.Loaded -> {
LoadedState(state, pagerStateKey, videoFeedContentState, accountViewModel, nav)
}
+
is FeedState.Loading -> {
LoadingFeed()
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginScreen.kt
index 473003d3b..7a6269393 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginScreen.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginScreen.kt
@@ -155,18 +155,22 @@ fun LoginPage(
loginViewModel.errorManager.error?.let { error ->
when (error) {
- is LoginErrorManager.SingleErrorMsg ->
+ is LoginErrorManager.SingleErrorMsg -> {
Text(
text = stringRes(error.errorResId),
color = MaterialTheme.colorScheme.error,
style = MaterialTheme.typography.bodySmall,
)
- is LoginErrorManager.ParamsErrorMsg ->
+ }
+
+ is LoginErrorManager.ParamsErrorMsg -> {
Text(
text = stringRes(error.errorResId, *error.params),
color = MaterialTheme.colorScheme.error,
style = MaterialTheme.typography.bodySmall,
)
+ }
+
else -> {}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/signup/SignUpScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/signup/SignUpScreen.kt
index 4d2f2b15a..4e741e275 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/signup/SignUpScreen.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/signup/SignUpScreen.kt
@@ -148,18 +148,22 @@ fun SignUpPage(
signUpViewModel.errorManager.error?.let { error ->
when (error) {
- is LoginErrorManager.SingleErrorMsg ->
+ is LoginErrorManager.SingleErrorMsg -> {
Text(
text = stringRes(error.errorResId),
color = MaterialTheme.colorScheme.error,
style = MaterialTheme.typography.bodySmall,
)
- is LoginErrorManager.ParamsErrorMsg ->
+ }
+
+ is LoginErrorManager.ParamsErrorMsg -> {
Text(
text = stringRes(error.errorResId, *error.params),
color = MaterialTheme.colorScheme.error,
style = MaterialTheme.typography.bodySmall,
)
+ }
+
else -> {}
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt
index 3a04e259d..f49b9f6d6 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt
@@ -540,12 +540,16 @@ fun AmethystTheme(
uiManager.nightMode = UiModeManager.MODE_NIGHT_YES
true
}
+
ThemeType.LIGHT -> {
val uiManager = context.getSystemService(Context.UI_MODE_SERVICE) as UiModeManager
uiManager.nightMode = UiModeManager.MODE_NIGHT_NO
false
}
- else -> isSystemInDarkTheme()
+
+ else -> {
+ isSystemInDarkTheme()
+ }
}
val colors = if (darkTheme) DarkColorPalette else LightColorPalette
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Type.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Type.kt
index 4d4c21b5c..eb5cad022 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Type.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Type.kt
@@ -67,41 +67,57 @@ val DefaultParagraphSpacing: TextUnit = 18.sp
internal val DefaultHeadingStyle: HeadingStyle = { level, textStyle ->
when (level) {
- 0 ->
+ 0 -> {
Typography.displayLarge.copy(
fontSize = 32.sp,
lineHeight = 40.sp,
)
- 1 ->
+ }
+
+ 1 -> {
Typography.displayMedium.copy(
fontSize = 28.sp,
lineHeight = 36.sp,
)
- 2 ->
+ }
+
+ 2 -> {
Typography.displaySmall.copy(
fontSize = 26.sp,
lineHeight = 34.sp,
)
- 3 ->
+ }
+
+ 3 -> {
Typography.displaySmall.copy(
fontSize = 24.sp,
lineHeight = 32.sp,
)
- 4 ->
+ }
+
+ 4 -> {
Typography.headlineLarge.copy(
fontSize = 22.sp,
lineHeight = 26.sp,
)
- 5 ->
+ }
+
+ 5 -> {
Typography.headlineMedium.copy(
fontSize = 20.sp,
lineHeight = 24.sp,
)
- 6 ->
+ }
+
+ 6 -> {
Typography.headlineSmall.copy(
fontSize = 18.sp,
lineHeight = 22.sp,
)
- else -> textStyle
+ }
+
+ else -> {
+ textStyle
+ }
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorDialogViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorDialogViewModel.kt
index 2cbba6a9a..ef1e4fc09 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorDialogViewModel.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorDialogViewModel.kt
@@ -20,10 +20,12 @@
*/
package com.vitorpamplona.amethyst.ui.tor
+import androidx.compose.runtime.Stable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.ViewModel
+@Stable
class TorDialogViewModel : ViewModel() {
val torType = mutableStateOf(TorType.INTERNAL)
val socksPortStr = mutableStateOf("9050")
@@ -102,7 +104,7 @@ class TorDialogViewModel : ViewModel() {
TorPresetType.ONLY_WHEN_NEEDED -> resetOnlyFlags(torOnlyWhenNeededPreset)
TorPresetType.SMALL_PAYLOADS -> resetOnlyFlags(torSmallPayloadsPreset)
TorPresetType.FULL_PRIVACY -> resetOnlyFlags(torFullyPrivate)
- TorPresetType.CUSTOM -> { }
+ TorPresetType.CUSTOM -> Unit
}
}
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorManager.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorManager.kt
index b1bfe610f..7c1715556 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorManager.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorManager.kt
@@ -58,9 +58,11 @@ class TorManager(
TorType.INTERNAL -> {
emitAll(service.status)
}
+
TorType.OFF -> {
emit(TorServiceStatus.Off)
}
+
TorType.EXTERNAL -> {
if (externalSocksPort > 0) {
emit(TorServiceStatus.Active(externalSocksPort))
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettings.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettings.kt
index c693cdd3b..d60b06de0 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettings.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettings.kt
@@ -52,9 +52,7 @@ fun parseTorType(code: Int?): TorType =
TorType.OFF.screenCode -> TorType.OFF
TorType.INTERNAL.screenCode -> TorType.INTERNAL
TorType.EXTERNAL.screenCode -> TorType.EXTERNAL
- else -> {
- TorType.INTERNAL
- }
+ else -> TorType.INTERNAL
}
enum class TorPresetType(
@@ -75,9 +73,7 @@ fun parseTorPresetType(code: Int?): TorPresetType =
TorPresetType.DEFAULT.screenCode -> TorPresetType.DEFAULT
TorPresetType.SMALL_PAYLOADS.screenCode -> TorPresetType.SMALL_PAYLOADS
TorPresetType.FULL_PRIVACY.screenCode -> TorPresetType.FULL_PRIVACY
- else -> {
- TorPresetType.CUSTOM
- }
+ else -> TorPresetType.CUSTOM
}
fun isPreset(
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsDialog.kt
index 8b087ea4f..d98bb953a 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsDialog.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsDialog.kt
@@ -257,7 +257,7 @@ fun PrivacySettingsBody(dialogViewModel: TorDialogViewModel) {
dialogViewModel.moneyOperationsViaTor,
)
- /**
+ /*
* Too hard to separate Coil into regular images and profile pics
SwitchSettingsRow(
R.string.tor_use_profile_pictures,
diff --git a/amethyst/src/test/java/com/vitorpamplona/quartz/nip01Core/relay/filters/FilterTest.kt b/amethyst/src/test/java/com/vitorpamplona/quartz/nip01Core/relay/filters/FilterTest.kt
new file mode 100644
index 000000000..b26c6bac2
--- /dev/null
+++ b/amethyst/src/test/java/com/vitorpamplona/quartz/nip01Core/relay/filters/FilterTest.kt
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2025 Vitor Pamplona
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
+ * Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.vitorpamplona.quartz.nip01Core.relay.filters
+
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+class FilterTest {
+ @Test
+ fun testIsEmpty() {
+ assertTrue(Filter().isEmpty())
+ assertTrue(Filter(ids = listOf()).isEmpty())
+ assertTrue(Filter(authors = listOf()).isEmpty())
+ assertTrue(Filter(kinds = listOf()).isEmpty())
+ assertTrue(Filter(tags = mapOf()).isEmpty())
+ assertTrue(Filter(tagsAll = mapOf()).isEmpty())
+ assertTrue(Filter(tags = mapOf("e" to listOf())).isEmpty())
+ assertTrue(Filter(tagsAll = mapOf("e" to listOf())).isEmpty())
+ assertTrue(Filter(search = "").isEmpty())
+ }
+}
diff --git a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/EnsureTest.kt b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/EnsureTest.kt
index 7b67a775d..8be769307 100644
--- a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/EnsureTest.kt
+++ b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/EnsureTest.kt
@@ -93,6 +93,7 @@ class EnsureTest {
(args[1].length == KEY_SIZE),
(args[1].isHex()),
-> null
+
else -> args[0] + args[1]
}
diff --git a/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/blurhash/BlurHashDecoderOld.kt b/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/blurhash/BlurHashDecoderOld.kt
index 44b4d8663..8cde0f052 100644
--- a/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/blurhash/BlurHashDecoderOld.kt
+++ b/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/blurhash/BlurHashDecoderOld.kt
@@ -189,6 +189,7 @@ object BlurHashDecoderOld {
calculate -> {
DoubleArray(height * numCompY).also { cacheCosinesY[height * numCompY] = it }
}
+
else -> {
cacheCosinesY[height * numCompY]!!
}
@@ -202,7 +203,10 @@ object BlurHashDecoderOld {
calculate -> {
DoubleArray(width * numCompX).also { cacheCosinesX[width * numCompX] = it }
}
- else -> cacheCosinesX[width * numCompX]!!
+
+ else -> {
+ cacheCosinesX[width * numCompX]!!
+ }
}
private fun DoubleArray.getCos(
diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/blurhash/CosineCache.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/blurhash/CosineCache.kt
index 9c0e5f095..5510c69ef 100644
--- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/blurhash/CosineCache.kt
+++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/blurhash/CosineCache.kt
@@ -60,6 +60,7 @@ object CosineCache {
cacheCosinesY.put(height * numCompY, it)
}
}
+
else -> {
cacheCosinesY[height * numCompY]!!
}
@@ -77,6 +78,9 @@ object CosineCache {
cos(PI * x * i / width)
}.also { cacheCosinesX.put(width * numCompX, it) }
}
- else -> cacheCosinesX[width * numCompX]!!
+
+ else -> {
+ cacheCosinesX[width * numCompX]!!
+ }
}
}
diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/Note.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/Note.kt
index 177429c0a..ffd4c5dc7 100644
--- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/Note.kt
+++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/Note.kt
@@ -191,7 +191,10 @@ open class Note(
fun relayHintUrl(): NormalizedRelayUrl? {
// checks Community Events first
when (val noteEvent = event) {
- is CommunityDefinitionEvent -> noteEvent.relayUrls().firstOrNull()?.let { return it }
+ is CommunityDefinitionEvent -> {
+ noteEvent.relayUrls().firstOrNull()?.let { return it }
+ }
+
is IsInPublicChatChannel -> {
inGatherers?.forEach {
if (it is com.vitorpamplona.amethyst.commons.model.Channel) {
@@ -199,9 +202,11 @@ open class Note(
}
}
}
+
is LiveActivitiesEvent -> {
noteEvent.relays().ifEmpty { null }?.toSet()
}
+
is LiveActivitiesChatMessageEvent -> {
inGatherers?.forEach {
if (it is com.vitorpamplona.amethyst.commons.model.Channel) {
@@ -209,7 +214,10 @@ open class Note(
}
}
}
- is EphemeralChatEvent -> noteEvent.roomId()?.let { return it.relayUrl }
+
+ is EphemeralChatEvent -> {
+ noteEvent.roomId()?.let { return it.relayUrl }
+ }
}
val currentOutbox = author?.outboxRelays()?.toSet()
diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/preview/MetaTagsParser.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/preview/MetaTagsParser.kt
index 48a4f7ff9..1015b1a6a 100644
--- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/preview/MetaTagsParser.kt
+++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/preview/MetaTagsParser.kt
@@ -108,14 +108,17 @@ object MetaTagsParser {
consume()
break
}
+
// `>` out of quote -> end of tag
quote == null && c == '>' -> {
break
}
+
// entering quote
quote == null && (c == '\'' || c == '"') -> {
quote = c
}
+
// leaving quote
quote != null && c == quote -> {
quote = null
@@ -263,6 +266,7 @@ object MetaTagsParser {
State.AFTER_EQ -> {
when {
c.isWhitespace() -> {}
+
c == '\'' || c == '"' -> {
valueBegin = i + 1
valueQuote = c
diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/preview/OpenGraphParser.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/preview/OpenGraphParser.kt
index 1f5ebbef1..613690f42 100644
--- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/preview/OpenGraphParser.kt
+++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/preview/OpenGraphParser.kt
@@ -66,54 +66,63 @@ class OpenGraphParser {
metaTags.forEach {
when (it.attr(ATTRIBUTE_VALUE_PROPERTY)) {
- in META_X_TITLE ->
+ in META_X_TITLE -> {
if (title.isEmpty()) {
title = it.attr(CONTENT)
}
+ }
- in META_X_DESCRIPTION ->
+ in META_X_DESCRIPTION -> {
if (description.isEmpty()) {
description = it.attr(CONTENT)
}
+ }
- in META_X_IMAGE ->
+ in META_X_IMAGE -> {
if (image.isEmpty()) {
image = it.attr(CONTENT)
}
+ }
}
when (it.attr(ATTRIBUTE_VALUE_NAME)) {
- in META_X_TITLE ->
+ in META_X_TITLE -> {
if (title.isEmpty()) {
title = it.attr(CONTENT)
}
+ }
- in META_X_DESCRIPTION ->
+ in META_X_DESCRIPTION -> {
if (description.isEmpty()) {
description = it.attr(CONTENT)
}
+ }
- in META_X_IMAGE ->
+ in META_X_IMAGE -> {
if (image.isEmpty()) {
image = it.attr(CONTENT)
}
+ }
}
when (it.attr(ATTRIBUTE_VALUE_ITEMPROP)) {
- in META_X_TITLE ->
+ in META_X_TITLE -> {
if (title.isEmpty()) {
title = it.attr(CONTENT)
}
+ }
- in META_X_DESCRIPTION ->
+ in META_X_DESCRIPTION -> {
if (description.isEmpty()) {
description = it.attr(CONTENT)
}
+ }
- in META_X_IMAGE ->
+ in META_X_IMAGE -> {
if (image.isEmpty()) {
image = it.attr(CONTENT)
}
+ }
}
if (title.isNotEmpty() && description.isNotEmpty() && image.isNotEmpty()) {
diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/richtext/GalleryParser.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/richtext/GalleryParser.kt
index 51df7c9db..e72592cb4 100644
--- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/richtext/GalleryParser.kt
+++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/richtext/GalleryParser.kt
@@ -36,14 +36,24 @@ class GalleryParser {
paragraph.words.forEach { word ->
when (word) {
- is ImageSegment, is Base64Segment -> imageCount++
- is VideoSegment -> hasNonWhitespaceNonImageContent = true // Videos are not images
+ is ImageSegment, is Base64Segment -> {
+ imageCount++
+ }
+
+ is VideoSegment -> {
+ hasNonWhitespaceNonImageContent = true
+ }
+
+ // Videos are not images
is RegularTextSegment -> {
if (word.segmentText.isNotBlank()) {
hasNonWhitespaceNonImageContent = true
}
}
- else -> hasNonWhitespaceNonImageContent = true // Links, emojis, etc.
+
+ else -> {
+ hasNonWhitespaceNonImageContent = true
+ } // Links, emojis, etc.
}
}
@@ -159,9 +169,16 @@ class GalleryParser {
hasVideo = true
break
}
- seg is ImageSegment || seg is Base64Segment -> imageSegments.add(seg)
+
+ seg is ImageSegment || seg is Base64Segment -> {
+ imageSegments.add(seg)
+ }
+
seg is RegularTextSegment && seg.segmentText.isBlank() -> { /* skip whitespace */ }
- else -> break
+
+ else -> {
+ break
+ }
}
j++
}
diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/SearchParser.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/SearchParser.kt
index f921c05e1..c2abb6171 100644
--- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/SearchParser.kt
+++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/SearchParser.kt
@@ -59,6 +59,7 @@ fun parseSearchInput(input: String): List {
),
)
}
+
is NProfile -> {
results.add(
SearchResult.UserResult(
@@ -67,6 +68,7 @@ fun parseSearchInput(input: String): List {
),
)
}
+
is NSec -> {
results.add(
SearchResult.UserResult(
@@ -75,6 +77,7 @@ fun parseSearchInput(input: String): List {
),
)
}
+
is NNote -> {
results.add(
SearchResult.NoteResult(
@@ -83,6 +86,7 @@ fun parseSearchInput(input: String): List {
),
)
}
+
is NEvent -> {
results.add(
SearchResult.NoteResult(
@@ -91,6 +95,7 @@ fun parseSearchInput(input: String): List {
),
)
}
+
is NAddress -> {
results.add(
SearchResult.AddressResult(
@@ -101,6 +106,7 @@ fun parseSearchInput(input: String): List {
),
)
}
+
else -> { }
}
return results
diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/util/EmojiUtils.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/util/EmojiUtils.kt
index 2e172179e..e383b1fe4 100644
--- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/util/EmojiUtils.kt
+++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/util/EmojiUtils.kt
@@ -29,10 +29,16 @@ fun String.firstFullCharOld(): String {
return when (this.length) {
0,
1,
- -> return this
+ -> {
+ return this
+ }
+
2,
3,
- -> return if (isUTF16Char(0)) this.take(2) else this.take(1)
+ -> {
+ return if (isUTF16Char(0)) this.take(2) else this.take(1)
+ }
+
else -> {
val first = isUTF16Char(0)
val second = isUTF16Char(2)
diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/util/TimeAgoFormatter.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/util/TimeAgoFormatter.kt
index b2bb319f2..f03474017 100644
--- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/util/TimeAgoFormatter.kt
+++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/util/TimeAgoFormatter.kt
@@ -62,19 +62,24 @@ fun timeAgo(
updateFormattersIfNeeded()
prefix + yearFormatter.format(time * 1000)
}
+
timeDifference > TimeUtils.ONE_MONTH -> {
updateFormattersIfNeeded()
prefix + monthFormatter.format(time * 1000)
}
+
timeDifference > TimeUtils.ONE_DAY -> {
prefix + (timeDifference / TimeUtils.ONE_DAY).toString() + "d"
}
+
timeDifference > TimeUtils.ONE_HOUR -> {
prefix + (timeDifference / TimeUtils.ONE_HOUR).toString() + "h"
}
+
timeDifference > TimeUtils.ONE_MINUTE -> {
prefix + (timeDifference / TimeUtils.ONE_MINUTE).toString() + "m"
}
+
else -> {
prefix + "now"
}
@@ -83,46 +88,22 @@ fun timeAgo(
fun timeDiffAgoLong(timeDifference: Int): String =
when {
- timeDifference > TimeUtils.ONE_YEAR -> {
- (timeDifference / TimeUtils.ONE_YEAR).toString() + " years"
- }
- timeDifference > TimeUtils.ONE_MONTH -> {
- (timeDifference / TimeUtils.ONE_MONTH).toString() + " months"
- }
- timeDifference > TimeUtils.ONE_DAY -> {
- (timeDifference / TimeUtils.ONE_DAY).toString() + " days"
- }
- timeDifference > TimeUtils.ONE_HOUR -> {
- (timeDifference / TimeUtils.ONE_HOUR).toString() + " hours"
- }
- timeDifference > TimeUtils.ONE_MINUTE -> {
- (timeDifference / TimeUtils.ONE_MINUTE).toString() + " minutes"
- }
- else -> {
- "now"
- }
+ timeDifference > TimeUtils.ONE_YEAR -> (timeDifference / TimeUtils.ONE_YEAR).toString() + " years"
+ timeDifference > TimeUtils.ONE_MONTH -> (timeDifference / TimeUtils.ONE_MONTH).toString() + " months"
+ timeDifference > TimeUtils.ONE_DAY -> (timeDifference / TimeUtils.ONE_DAY).toString() + " days"
+ timeDifference > TimeUtils.ONE_HOUR -> (timeDifference / TimeUtils.ONE_HOUR).toString() + " hours"
+ timeDifference > TimeUtils.ONE_MINUTE -> (timeDifference / TimeUtils.ONE_MINUTE).toString() + " minutes"
+ else -> "now"
}
fun timeDiffAgoShortish(timeDifference: Int): String =
when {
- timeDifference > TimeUtils.ONE_YEAR -> {
- (timeDifference / TimeUtils.ONE_YEAR).toString() + " yrs"
- }
- timeDifference > TimeUtils.ONE_MONTH -> {
- (timeDifference / TimeUtils.ONE_MONTH).toString() + " mos"
- }
- timeDifference > TimeUtils.ONE_DAY -> {
- (timeDifference / TimeUtils.ONE_DAY).toString() + " days"
- }
- timeDifference > TimeUtils.ONE_HOUR -> {
- (timeDifference / TimeUtils.ONE_HOUR).toString() + " hrs"
- }
- timeDifference > TimeUtils.ONE_MINUTE -> {
- (timeDifference / TimeUtils.ONE_MINUTE).toString() + " mins"
- }
- else -> {
- "now"
- }
+ timeDifference > TimeUtils.ONE_YEAR -> (timeDifference / TimeUtils.ONE_YEAR).toString() + " yrs"
+ timeDifference > TimeUtils.ONE_MONTH -> (timeDifference / TimeUtils.ONE_MONTH).toString() + " mos"
+ timeDifference > TimeUtils.ONE_DAY -> (timeDifference / TimeUtils.ONE_DAY).toString() + " days"
+ timeDifference > TimeUtils.ONE_HOUR -> (timeDifference / TimeUtils.ONE_HOUR).toString() + " hrs"
+ timeDifference > TimeUtils.ONE_MINUTE -> (timeDifference / TimeUtils.ONE_MINUTE).toString() + " mins"
+ else -> "now"
}
/**
@@ -148,11 +129,15 @@ fun dateFormatter(
updateFormattersIfNeeded()
yearFormatter.format(time * 1000)
}
+
timeDifference > TimeUtils.ONE_DAY -> {
updateFormattersIfNeeded()
monthFormatter.format(time * 1000)
}
- else -> today
+
+ else -> {
+ today
+ }
}
}
diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt
index 84646e51a..358bdd044 100644
--- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt
+++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt
@@ -296,6 +296,7 @@ fun App(
onLoginSuccess = { onScreenChange(DesktopScreen.Feed) },
)
}
+
is AccountState.LoggedIn -> {
val account = accountState as AccountState.LoggedIn
val nwcConnection by accountManager.nwcConnection.collectAsState()
@@ -442,7 +443,7 @@ fun MainContent(
modifier = Modifier.weight(1f).fillMaxHeight().padding(24.dp),
) {
when (currentScreen) {
- DesktopScreen.Feed ->
+ DesktopScreen.Feed -> {
FeedScreen(
relayManager = relayManager,
localCache = localCache,
@@ -458,7 +459,9 @@ fun MainContent(
},
onZapFeedback = onZapFeedback,
)
- DesktopScreen.Reads ->
+ }
+
+ DesktopScreen.Reads -> {
ReadsScreen(
relayManager = relayManager,
localCache = localCache,
@@ -470,7 +473,9 @@ fun MainContent(
onScreenChange(DesktopScreen.Thread(noteId))
},
)
- DesktopScreen.Search ->
+ }
+
+ DesktopScreen.Search -> {
SearchScreen(
localCache = localCache,
relayManager = relayManager,
@@ -482,7 +487,9 @@ fun MainContent(
onScreenChange(DesktopScreen.Thread(noteId))
},
)
- DesktopScreen.Bookmarks ->
+ }
+
+ DesktopScreen.Bookmarks -> {
BookmarksScreen(
relayManager = relayManager,
localCache = localCache,
@@ -497,9 +504,17 @@ fun MainContent(
},
onZapFeedback = onZapFeedback,
)
- DesktopScreen.Messages -> MessagesPlaceholder()
- DesktopScreen.Notifications -> NotificationsScreen(relayManager, account, subscriptionsCoordinator)
- DesktopScreen.MyProfile ->
+ }
+
+ DesktopScreen.Messages -> {
+ MessagesPlaceholder()
+ }
+
+ DesktopScreen.Notifications -> {
+ NotificationsScreen(relayManager, account, subscriptionsCoordinator)
+ }
+
+ DesktopScreen.MyProfile -> {
UserProfileScreen(
pubKeyHex = account.pubKeyHex,
relayManager = relayManager,
@@ -514,7 +529,9 @@ fun MainContent(
},
onZapFeedback = onZapFeedback,
)
- is DesktopScreen.UserProfile ->
+ }
+
+ is DesktopScreen.UserProfile -> {
UserProfileScreen(
pubKeyHex = currentScreen.pubKeyHex,
relayManager = relayManager,
@@ -529,7 +546,9 @@ fun MainContent(
},
onZapFeedback = onZapFeedback,
)
- is DesktopScreen.Thread ->
+ }
+
+ is DesktopScreen.Thread -> {
ThreadScreen(
noteId = currentScreen.noteId,
relayManager = relayManager,
@@ -547,7 +566,11 @@ fun MainContent(
onZapFeedback = onZapFeedback,
onReply = onShowReplyDialog,
)
- DesktopScreen.Settings -> RelaySettingsScreen(relayManager, account, accountManager)
+ }
+
+ DesktopScreen.Settings -> {
+ RelaySettingsScreen(relayManager, account, accountManager)
+ }
}
}
}
diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandler.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandler.kt
index 7564715bc..fc9119db8 100644
--- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandler.kt
+++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandler.kt
@@ -171,9 +171,11 @@ class NwcPaymentHandler(
is PayInvoiceSuccessResponse -> {
PaymentResult.Success(response.result?.preimage)
}
+
is PayInvoiceErrorResponse -> {
PaymentResult.Error(response.error?.message ?: "Unknown error")
}
+
else -> {
PaymentResult.Error("Unexpected response type: ${response.resultType}")
}
diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/BookmarksScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/BookmarksScreen.kt
index 473be40b8..d8e915825 100644
--- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/BookmarksScreen.kt
+++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/BookmarksScreen.kt
@@ -266,6 +266,7 @@ fun BookmarksScreen(
isLoading && !hasReceivedEose -> {
LoadingState(message = "Loading bookmarks...")
}
+
currentBookmarkIds.isEmpty() && hasReceivedEose -> {
EmptyState(
title = if (selectedTab == BookmarkTab.PUBLIC) "No public bookmarks" else "No private bookmarks",
@@ -277,6 +278,7 @@ fun BookmarksScreen(
},
)
}
+
else -> {
LazyColumn(
modifier = Modifier.fillMaxSize(),
diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/FeedScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/FeedScreen.kt
index e08950f56..224971776 100644
--- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/FeedScreen.kt
+++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/FeedScreen.kt
@@ -268,6 +268,7 @@ fun FeedScreen(
},
)
}
+
FeedMode.FOLLOWING -> {
if (followedUsers.isNotEmpty()) {
createFollowingFeedSubscription(
diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NoteActions.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NoteActions.kt
index 9584f0692..af9106f90 100644
--- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NoteActions.kt
+++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NoteActions.kt
@@ -971,9 +971,11 @@ private suspend fun zapNote(
is NwcPaymentHandler.PaymentResult.Success -> {
ZapFeedback.Success(amountSats)
}
+
is NwcPaymentHandler.PaymentResult.Error -> {
ZapFeedback.Error(paymentResult.message)
}
+
is NwcPaymentHandler.PaymentResult.Timeout -> {
ZapFeedback.Timeout
}
@@ -984,6 +986,7 @@ private suspend fun zapNote(
ZapFeedback.ExternalWallet(amountSats)
}
}
+
is ZapAction.ZapResult.Error -> {
ZapFeedback.Error(result.message)
}
diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NotificationsScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NotificationsScreen.kt
index 04461403e..6956d0e8e 100644
--- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NotificationsScreen.kt
+++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NotificationsScreen.kt
@@ -153,17 +153,21 @@ fun NotificationsScreen(
val notification =
when (event) {
- is ReactionEvent ->
+ is ReactionEvent -> {
NotificationItem.Reaction(
event = event,
timestamp = event.createdAt,
content = event.content,
)
- is RepostEvent, is GenericRepostEvent ->
+ }
+
+ is RepostEvent, is GenericRepostEvent -> {
NotificationItem.Repost(
event = event,
timestamp = event.createdAt,
)
+ }
+
is LnZapEvent -> {
val amount = event.amount?.toLong()
NotificationItem.Zap(
@@ -172,6 +176,7 @@ fun NotificationsScreen(
amount = amount,
)
}
+
is TextNoteEvent -> {
val eTags = event.tags.filter { it.size > 1 && it[0] == "e" }
val isReply = eTags.isNotEmpty()
@@ -181,7 +186,10 @@ fun NotificationsScreen(
NotificationItem.Mention(event, event.createdAt)
}
}
- else -> NotificationItem.Mention(event, event.createdAt)
+
+ else -> {
+ NotificationItem.Mention(event, event.createdAt)
+ }
}
notificationState.addItem(notification)
@@ -230,15 +238,26 @@ fun NotificationsScreen(
fun NotificationCard(notification: NotificationItem) {
val (icon, label, color) =
when (notification) {
- is NotificationItem.Mention -> Triple(Icons.Default.Favorite, "mentioned you", MaterialTheme.colorScheme.primary)
- is NotificationItem.Reply -> Triple(Reply, "replied", MaterialTheme.colorScheme.secondary)
- is NotificationItem.Reaction ->
+ is NotificationItem.Mention -> {
+ Triple(Icons.Default.Favorite, "mentioned you", MaterialTheme.colorScheme.primary)
+ }
+
+ is NotificationItem.Reply -> {
+ Triple(Reply, "replied", MaterialTheme.colorScheme.secondary)
+ }
+
+ is NotificationItem.Reaction -> {
Triple(
Icons.Default.Favorite,
"reacted ${notification.content}",
MaterialTheme.colorScheme.tertiary,
)
- is NotificationItem.Repost -> Triple(Repost, "reposted", MaterialTheme.colorScheme.primary)
+ }
+
+ is NotificationItem.Repost -> {
+ Triple(Repost, "reposted", MaterialTheme.colorScheme.primary)
+ }
+
is NotificationItem.Zap -> {
val amountText = notification.amount?.let { " ${it / 1000} sats" } ?: ""
Triple(Zap, "zapped$amountText", MaterialTheme.colorScheme.primary)
diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/ReadsScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/ReadsScreen.kt
index 1548f33d7..c1096316e 100644
--- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/ReadsScreen.kt
+++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/ReadsScreen.kt
@@ -237,6 +237,7 @@ fun ReadsScreen(
},
)
}
+
FeedMode.FOLLOWING -> {
if (followedUsers.isNotEmpty()) {
createFollowingLongFormFeedSubscription(
@@ -322,12 +323,15 @@ fun ReadsScreen(
connectedRelays.isEmpty() -> {
LoadingState("Connecting to relays...")
}
+
feedMode == FeedMode.FOLLOWING && followedUsers.isEmpty() -> {
LoadingState("Loading followed users...")
}
+
events.isEmpty() && !initialLoadComplete -> {
LoadingState("Loading articles...")
}
+
events.isEmpty() && initialLoadComplete -> {
EmptyState(
title =
@@ -345,6 +349,7 @@ fun ReadsScreen(
onRefresh = { relayManager.connect() },
)
}
+
else -> {
LazyColumn(
verticalArrangement = Arrangement.spacedBy(12.dp),
diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/SearchScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/SearchScreen.kt
index 34a5e5cdd..c787c3471 100644
--- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/SearchScreen.kt
+++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/SearchScreen.kt
@@ -384,13 +384,25 @@ private fun SearchResultCard(
.fillMaxWidth()
.clickable {
when (result) {
- is SearchResult.UserResult -> onNavigateToProfile(result.pubKeyHex)
- is SearchResult.CachedUserResult -> onNavigateToProfile(result.user.pubkeyHex)
- is SearchResult.NoteResult -> onNavigateToThread(result.noteIdHex)
+ is SearchResult.UserResult -> {
+ onNavigateToProfile(result.pubKeyHex)
+ }
+
+ is SearchResult.CachedUserResult -> {
+ onNavigateToProfile(result.user.pubkeyHex)
+ }
+
+ is SearchResult.NoteResult -> {
+ onNavigateToThread(result.noteIdHex)
+ }
+
is SearchResult.AddressResult -> {
onNavigateToThread("${result.kind}:${result.pubKeyHex}:${result.dTag}")
}
- is SearchResult.HashtagResult -> onNavigateToHashtag(result.hashtag)
+
+ is SearchResult.HashtagResult -> {
+ onNavigateToHashtag(result.hashtag)
+ }
}
},
colors =
diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/UserProfileScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/UserProfileScreen.kt
index a537f90f5..c239218ae 100644
--- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/UserProfileScreen.kt
+++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/UserProfileScreen.kt
@@ -339,6 +339,7 @@ fun UserProfileScreen(
Spacer(Modifier.width(8.dp))
Text("Loading...")
}
+
isLoading -> {
androidx.compose.material3.CircularProgressIndicator(
modifier = Modifier.size(16.dp),
@@ -348,6 +349,7 @@ fun UserProfileScreen(
Spacer(Modifier.width(8.dp))
Text(if (isFollowing) "Unfollowing..." else "Following...")
}
+
else -> {
Icon(
if (isFollowing) Icons.Default.PersonRemove else Icons.Default.PersonAdd,
@@ -529,6 +531,7 @@ fun UserProfileScreen(
}
}
}
+
postsLoading -> {
// Loading state
Box(
@@ -546,6 +549,7 @@ fun UserProfileScreen(
}
}
}
+
events.isEmpty() -> {
// Empty state (loaded but no posts)
Box(
@@ -559,6 +563,7 @@ fun UserProfileScreen(
)
}
}
+
else -> {
// Posts loaded successfully
LazyColumn(
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index bb3ef8db3..86b423a56 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,7 +1,7 @@
[versions]
accompanistAdaptive = "0.37.3"
-composeMultiplatform = "1.9.3"
-activityCompose = "1.12.2"
+composeMultiplatform = "1.10.0"
+activityCompose = "1.12.3"
agp = "9.0.0"
android-compileSdk = "36"
android-minSdk = "26"
@@ -10,60 +10,60 @@ androidKotlinGeohash = "b481c6a64e"
androidxJunit = "1.3.0"
appcompat = "1.7.1"
audiowaveform = "1.1.2"
-benchmark = "1.5.0-alpha01"
+benchmark = "1.5.0-alpha02"
biometricKtx = "1.2.0-alpha05"
coil = "3.3.0"
-composeBom = "2025.12.01"
-composeRuntimeAnnotation = "1.10.0"
+composeBom = "2026.01.01"
+composeRuntimeAnnotation = "1.10.2"
coreKtx = "1.17.0"
datastore = "1.2.0"
espressoCore = "3.7.0"
-firebaseBom = "34.7.0"
+firebaseBom = "34.9.0"
fragmentKtx = "1.8.9"
gms = "4.4.4"
-jacksonModuleKotlin = "2.20.1"
+jacksonModuleKotlin = "2.21.0"
javaKeyring = "1.0.4"
jna = "5.18.1"
jtorctl = "0.4.5.7"
junit = "4.13.2"
-kotlin = "2.3.0"
+kotlin = "2.3.10"
kotlinxCollectionsImmutable = "0.4.0"
kotlinxCoroutinesCore = "1.10.2"
-kotlinxSerialization = "1.9.0"
-kotlinxSerializationPlugin = "2.3.0"
+kotlinxSerialization = "1.10.0"
+kotlinxSerializationPlugin = "2.3.10"
languageId = "17.0.6"
lazysodiumAndroid = "5.2.0"
lazysodiumJava = "5.2.0"
lifecycleRuntimeKtx = "2.10.0"
lightcompressor-enhanced = "1.6.0"
markdown = "f92ef49c9d"
-media3 = "1.9.0"
-mockk = "1.14.7"
+media3 = "1.9.2"
+mockk = "1.14.9"
kotlinx-coroutines-test = "1.10.2"
-navigationCompose = "2.9.6"
+navigationCompose = "2.9.7"
okhttp = "5.3.2"
runner = "1.7.0"
rfc3986 = "0.1.2"
secp256k1KmpJniAndroid = "0.22.0"
securityCryptoKtx = "1.1.0"
-spotless = "8.1.0"
+spotless = "8.2.1"
tarsosdsp = "2.5"
-torAndroid = "0.4.8.21.1"
+torAndroid = "0.4.8.22"
translate = "17.0.3"
unifiedpush = "3.0.10"
urlDetector = "0.1.23"
-vico-charts = "2.4.1"
+vico-charts = "2.4.3"
zelory = "3.0.1"
-zoomable = "2.9.0"
+zoomable = "2.11.0"
zxing = "3.5.4"
zxingAndroidEmbedded = "4.3.0"
windowCoreAndroid = "1.5.1"
-androidxCamera = "1.5.2"
+androidxCamera = "1.5.3"
androidxCollection = "1.5.0"
kotlinStdlib = "2.3.0"
kotlinTest = "2.2.20"
core = "1.7.0"
-mavenPublish = "0.35.0"
+mavenPublish = "0.36.0"
[libraries]
abedElazizShe-video-compressor-fork = { group = "com.github.davotoula", name = "LightCompressor-enhanced", version.ref = "lightcompressor-enhanced" }
@@ -165,7 +165,6 @@ androidBenchmark = { id = "androidx.benchmark", version.ref = "benchmark" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
diffplugSpotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
googleServices = { id = "com.google.gms.google-services", version.ref = "gms" }
-jetbrainsKotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
jetbrainsKotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
jetbrainsComposeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
serialization = { id = 'org.jetbrains.kotlin.plugin.serialization', version.ref = 'kotlinxSerializationPlugin' }
diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/sql/SqlSelectionBuilder.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/sql/SqlSelectionBuilder.kt
index 88f63cd3f..2c8544fe5 100644
--- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/sql/SqlSelectionBuilder.kt
+++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/sql/SqlSelectionBuilder.kt
@@ -41,9 +41,11 @@ class SqlSelectionBuilder(
is Condition.Empty -> {
""
}
+
is Condition.Raw -> {
cond.condition
}
+
is Condition.Equals -> {
if (cond.value == null) {
"${cond.column} IS NULL"
@@ -52,6 +54,7 @@ class SqlSelectionBuilder(
"${cond.column} = ?"
}
}
+
is Condition.NotEquals -> {
if (cond.value == null) {
"${cond.column} IS NULL"
@@ -60,36 +63,45 @@ class SqlSelectionBuilder(
"${cond.column} != ?"
}
}
+
is Condition.GreaterThan -> {
selectionArgs.add(cond.value.toString())
"${cond.column} > ?"
}
+
is Condition.GreaterThanOrEquals -> {
selectionArgs.add(cond.value.toString())
"${cond.column} >= ?"
}
+
is Condition.LessThan -> {
selectionArgs.add(cond.value.toString())
"${cond.column} < ?"
}
+
is Condition.LessThanOrEquals -> {
selectionArgs.add(cond.value.toString())
"${cond.column} <= ?"
}
+
is Condition.Like -> {
selectionArgs.add(cond.value)
"${cond.column} LIKE ?"
}
+
is Condition.Match -> {
selectionArgs.add(cond.value)
"${cond.table} MATCH ?"
}
+
is Condition.IsNull -> {
"${cond.column} IS NULL"
}
+
is Condition.IsNotNull -> {
"${cond.column} IS NOT NULL"
}
+
is Condition.In -> {
if (cond.values.isEmpty()) {
// Handle empty IN clause gracefully, perhaps by making it always false
@@ -102,6 +114,7 @@ class SqlSelectionBuilder(
"${cond.column} IN ($placeholders)"
}
}
+
is Condition.And -> {
if (cond.conditions.isEmpty()) {
"1 = 1" // Always true for an empty AND
@@ -109,6 +122,7 @@ class SqlSelectionBuilder(
cond.conditions.joinToString(" AND ") { "(${buildCondition(it)})" }
}
}
+
is Condition.Or -> {
if (cond.conditions.isEmpty()) {
"1 = 0" // Always false for an empty OR
diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/NostrSignerExternal.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/NostrSignerExternal.kt
index 513f2351d..5f5c98e24 100644
--- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/NostrSignerExternal.kt
+++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/NostrSignerExternal.kt
@@ -184,10 +184,8 @@ class NostrSignerExternal(
is SignerResult.RequestAddressed.Successful<*> -> IllegalStateException("$title: This should not happen. There is a bug on Quartz.")
is SignerResult.RequestAddressed.ReceivedButCouldNotParseEventFromResult<*> -> IllegalStateException("$title: Failed to parse event: ${result.eventJson}.")
is SignerResult.RequestAddressed.ReceivedButCouldNotVerifyResultingEvent<*> -> IllegalStateException("$title: Failed to verify event: ${result.invalidEvent.toJson()}.")
-
is SignerResult.RequestAddressed.ReceivedButCouldNotPerform<*> -> SignerExceptions.CouldNotPerformException("$title: ${result.message}")
is SignerResult.RequestAddressed.SignerNotFound<*> -> SignerExceptions.SignerNotFoundException("$title: Signer app was not found.")
-
is SignerResult.RequestAddressed.AutomaticallyRejected<*> -> SignerExceptions.AutomaticallyUnauthorizedException("$title: User has rejected the request.")
is SignerResult.RequestAddressed.ManuallyRejected<*> -> SignerExceptions.ManuallyUnauthorizedException("$title: User has rejected the request.")
is SignerResult.RequestAddressed.TimedOut<*> -> SignerExceptions.TimedOutException("$title: User didn't accept or reject in time.")
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/pool/PoolCounts.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/pool/PoolCounts.kt
index 7bb845d93..c64c0a607 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/pool/PoolCounts.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/pool/PoolCounts.kt
@@ -136,6 +136,7 @@ class PoolCounts {
relay.sendOrConnectAndSync(cmd)
}
}
+
is ClosedMessage -> {
subState(msg.subId).onClosed(relay.url)
sendToRelayIfChanged(msg.subId, relay.url) { cmd ->
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/pool/PoolRequests.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/pool/PoolRequests.kt
index 6255b1845..c0e41864e 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/pool/PoolRequests.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/pool/PoolRequests.kt
@@ -170,6 +170,7 @@ class PoolRequests {
forFilters = cmd.filters,
)
}
+
is CloseCmd -> {
subState(cmd.subId).onCloseReq(relay)
desiredSubListeners.get(cmd.subId)?.onCloseReq(
@@ -197,6 +198,7 @@ class PoolRequests {
forFilters = state?.lastKnownFilterStates(relay.url),
)
}
+
is EoseMessage -> {
val state = relayState.get(msg.subId)
state?.onEose(relay.url)
@@ -210,6 +212,7 @@ class PoolRequests {
relay.sendOrConnectAndSync(cmd)
}
}
+
is ClosedMessage -> {
val state = relayState.get(msg.subId)
state?.onClosed(relay.url)
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/stats/RelayStats.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/stats/RelayStats.kt
index 8d4c4334e..44c8fb084 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/stats/RelayStats.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/stats/RelayStats.kt
@@ -83,14 +83,23 @@ class RelayStats(
stat.addBytesReceived(msgStr.bytesUsedInMemory())
when (msg) {
- is NoticeMessage -> stat.newNotice(msg.message)
- is NotifyMessage -> stat.newNotice("Notify user: " + msg.message)
+ is NoticeMessage -> {
+ stat.newNotice(msg.message)
+ }
+
+ is NotifyMessage -> {
+ stat.newNotice("Notify user: " + msg.message)
+ }
+
is OkMessage -> {
if (!msg.success) {
stat.newNotice("Rejected event ${msg.eventId}: ${msg.message}")
}
}
- is ClosedMessage -> stat.newNotice("Subscription closed: ${msg.subId} ${msg.message}")
+
+ is ClosedMessage -> {
+ stat.newNotice("Subscription closed: ${msg.subId} ${msg.message}")
+ }
}
}
}
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/filters/Filter.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/filters/Filter.kt
index 4368a737e..67537aeab 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/filters/Filter.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/filters/Filter.kt
@@ -80,8 +80,8 @@ class Filter(
(ids == null || ids.isEmpty()) &&
(authors == null || authors.isEmpty()) &&
(kinds == null || kinds.isEmpty()) &&
- (tags == null || tags.isEmpty() && tags.values.all { it.isNotEmpty() }) &&
- (tagsAll == null || tagsAll.isEmpty() && tagsAll.values.all { it.isNotEmpty() }) &&
+ (tags == null || tags.isEmpty() || tags.values.all { it.isEmpty() }) &&
+ (tagsAll == null || tagsAll.isEmpty() || tagsAll.values.all { it.isEmpty() }) &&
(since == null) &&
(until == null) &&
(limit == null) &&
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/caches/DecryptCache.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/caches/DecryptCache.kt
index 6bdcd9420..3ea3b896b 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/caches/DecryptCache.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/caches/DecryptCache.kt
@@ -100,8 +100,14 @@ abstract class DecryptCache(
suspend fun decrypt(input: I): T? {
val cachedResult = cache
return when (cachedResult) {
- is CacheResults.Success -> cachedResult.value
- is CacheResults.DontTryAgain -> null
+ is CacheResults.Success -> {
+ cachedResult.value
+ }
+
+ is CacheResults.DontTryAgain -> {
+ null
+ }
+
is CacheResults.CanTryAgain -> {
if (TimeUtils.now() > cachedResult.after) {
performDecrypt(input)
@@ -109,6 +115,7 @@ abstract class DecryptCache(
null
}
}
+
is CacheResults.NeedsForegroundActivityToTryAgain<*> -> {
if (TimeUtils.now() > cachedResult.after && signer.hasForegroundSupport()) {
performDecrypt(input)
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/VerificationStateCache.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/VerificationStateCache.kt
index 3e0afb39d..05d99b69e 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/VerificationStateCache.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/VerificationStateCache.kt
@@ -38,8 +38,14 @@ class VerificationStateCache(
suspend fun cacheVerify(event: OtsEvent): VerificationState =
when (val verif = cache[event.id]) {
- is VerificationState.Verifying -> verif
- is VerificationState.Verified -> verif
+ is VerificationState.Verifying -> {
+ verif
+ }
+
+ is VerificationState.Verified -> {
+ verif
+ }
+
is VerificationState.NetworkError -> {
// try again in 5 mins
if (verif.time < TimeUtils.fiveMinutesAgo()) {
@@ -48,7 +54,11 @@ class VerificationStateCache(
verif
}
}
- is VerificationState.Error -> verif
+
+ is VerificationState.Error -> {
+ verif
+ }
+
else -> {
verify(event)
}
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/Timestamp.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/Timestamp.kt
index b0b7b9be2..f2d77a500 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/Timestamp.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/Timestamp.kt
@@ -399,7 +399,7 @@ class Timestamp(
}
val isTimestampComplete: Boolean
- /**
+ /*
* Determine if timestamp is complete and can be verified.
*
* @return True if the timestamp is complete, False otherwise.
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/op/OpUnary.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/op/OpUnary.kt
index 59990079c..40d8004da 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/op/OpUnary.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/op/OpUnary.kt
@@ -39,10 +39,22 @@ abstract class OpUnary : Op() {
tag: Byte,
): Op? =
when (tag) {
- OpSHA1.TAG -> OpSHA1()
- OpSHA256.TAG -> OpSHA256()
- OpRIPEMD160.TAG -> OpRIPEMD160()
- OpKECCAK256.TAG -> OpKECCAK256()
+ OpSHA1.TAG -> {
+ OpSHA1()
+ }
+
+ OpSHA256.TAG -> {
+ OpSHA256()
+ }
+
+ OpRIPEMD160.TAG -> {
+ OpRIPEMD160()
+ }
+
+ OpKECCAK256.TAG -> {
+ OpKECCAK256()
+ }
+
else -> {
Log.e("OpenTimestamp", "Unknown operation tag: $tag")
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip10Notes/tags/Positional.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip10Notes/tags/Positional.kt
index f22298ff6..78dc402f0 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip10Notes/tags/Positional.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip10Notes/tags/Positional.kt
@@ -41,10 +41,19 @@ fun List.positionalMarkedTags(
sortedWith { o1, o2 ->
when {
o1.eventId == o2.eventId -> 0
- o1.eventId == root?.eventId -> -1 // root goes first
- o2.eventId == root?.eventId -> 1 // root goes first
- o1.eventId == replyingTo?.eventId -> 1 // reply event being responded to goes last
- o2.eventId == replyingTo?.eventId -> -1 // reply event being responded to goes last
+
+ o1.eventId == root?.eventId -> -1
+
+ // root goes first
+ o2.eventId == root?.eventId -> 1
+
+ // root goes first
+ o1.eventId == replyingTo?.eventId -> 1
+
+ // reply event being responded to goes last
+ o2.eventId == replyingTo?.eventId -> -1
+
+ // reply event being responded to goes last
else -> 0 // keep the relative order for any other tag
}
}.map {
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip11RelayInfo/FlexibleIntListSerializer.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip11RelayInfo/FlexibleIntListSerializer.kt
index 07a4e88be..fa2a3cd12 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip11RelayInfo/FlexibleIntListSerializer.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip11RelayInfo/FlexibleIntListSerializer.kt
@@ -45,7 +45,9 @@ object FlexibleIntListSerializer : KSerializer?> {
return when (val element = decoder.decodeJsonElement()) {
// Handle JSON null
- is JsonNull -> null
+ is JsonNull -> {
+ null
+ }
// Handle array format (spec-compliant): [1, 2, 3]
is JsonArray -> {
@@ -72,7 +74,9 @@ object FlexibleIntListSerializer : KSerializer?> {
}
// Unsupported format (strings, objects, etc.)
- else -> null
+ else -> {
+ null
+ }
}
}
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip18Reposts/quotes/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip18Reposts/quotes/TagArrayBuilderExt.kt
index 19016e528..7a5bf1d0f 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip18Reposts/quotes/TagArrayBuilderExt.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip18Reposts/quotes/TagArrayBuilderExt.kt
@@ -43,9 +43,7 @@ fun TagArrayBuilder.quote(entity: Entity) =
is NEmbed -> add(entity.toQuoteTagArray())
is NPub -> add(entity.toQuoteTagArray())
is NProfile -> add(entity.toQuoteTagArray())
- else -> {
- this
- }
+ else -> this
}
fun TagArrayBuilder.quotes(entities: List) = entities.forEach { quote(it) }
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip44Encryption/Nip44.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip44Encryption/Nip44.kt
index ba870d143..c5eb78b4f 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip44Encryption/Nip44.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip44Encryption/Nip44.kt
@@ -102,7 +102,9 @@ object Nip44 {
v2.decrypt(encryptedInfo, privateKey, pubKey)
}
- else -> throw IllegalArgumentException("Invalid or unsupported NIP-44 version code ${info.v}")
+ else -> {
+ throw IllegalArgumentException("Invalid or unsupported NIP-44 version code ${info.v}")
+ }
}
}
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/Nip04DecryptResponse.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/Nip04DecryptResponse.kt
index a98994454..aec2b9206 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/Nip04DecryptResponse.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/Nip04DecryptResponse.kt
@@ -31,9 +31,11 @@ class Nip04DecryptResponse {
is BunkerResponseDecrypt -> {
SignerResult.RequestAddressed.Successful(DecryptionResult(response.plaintext))
}
+
is BunkerResponseError -> {
SignerResult.RequestAddressed.Rejected()
}
+
else -> {
SignerResult.RequestAddressed.ReceivedButCouldNotPerform()
}
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip56Reports/ReportType.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip56Reports/ReportType.kt
index 48e179ad8..d2d00f93f 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip56Reports/ReportType.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip56Reports/ReportType.kt
@@ -46,14 +46,12 @@ enum class ReportType(
"harassment" -> HARASSMENT
"Harassment" -> HARASSMENT
"Harrassment" -> HARASSMENT
-
"impersonation" -> IMPERSONATION
"Impersonation" -> IMPERSONATION
"Falsificação de identidade \uD83E\uDD78" -> IMPERSONATION
"Suplantación de identidad \uD83E\uDD78" -> IMPERSONATION
"Impersonation \uD83E\uDD78" -> IMPERSONATION
"Předstírání identity \uD83E\uDD78" -> IMPERSONATION
-
"illegal" -> ILLEGAL
"Illegal" -> ILLEGAL
"Illegal Material" -> ILLEGAL
@@ -63,7 +61,6 @@ enum class ReportType(
"csam" -> ILLEGAL
"abuse" -> ILLEGAL
"fraud" -> ILLEGAL
-
"explicit" -> NUDITY
"explıcıt" -> NUDITY
"Explicit" -> NUDITY
@@ -73,14 +70,11 @@ enum class ReportType(
"sexual-content" -> NUDITY
"inappropriate" -> NUDITY
"Naaktheid \uD83C\uDF51\uD83C\uDF46" -> NUDITY
-
"profanity" -> PROFANITY
"Profanity" -> PROFANITY
"Profanity \uD83D\uDDEF\uFE0F" -> PROFANITY
-
"malware" -> MALWARE
"Malware" -> MALWARE
-
"other" -> OTHER
"Other" -> OTHER
"mod" -> OTHER
@@ -89,20 +83,14 @@ enum class ReportType(
"ai-generated" -> OTHER
"duplicate" -> OTHER
"" -> OTHER
-
"spam" -> SPAM
"Spam" -> SPAM
"Spam \uD83D\uDCE3" -> SPAM
"Bot Activity" -> SPAM
"スパム \uD83D\uDCE3" -> SPAM
"Pourriel \uD83D\uDCE3" -> SPAM
-
"violence" -> VIOLENCE
-
- else -> {
- Log.w("ReportedEventTag", "Report type not supported: `$code` ${tag.joinToString(", ")}")
- OTHER
- }
+ else -> Log.w("ReportedEventTag", "Report type not supported: `$code` ${tag.joinToString(", ")}").let { OTHER }
}
}
}
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestEvent.kt
index d38c8e6e7..b204dafdb 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestEvent.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestEvent.kt
@@ -111,16 +111,23 @@ class LnZapRequestEvent(
}
return when (zapType) {
- LnZapEvent.ZapType.PUBLIC -> signer.sign(createdAt, KIND, tags.toTypedArray(), message)
+ LnZapEvent.ZapType.PUBLIC -> {
+ signer.sign(createdAt, KIND, tags.toTypedArray(), message)
+ }
+
LnZapEvent.ZapType.ANONYMOUS -> {
tags = tags + listOf(arrayOf("anon"))
NostrSignerInternal(KeyPair()).sign(createdAt, KIND, tags.toTypedArray(), message)
}
+
LnZapEvent.ZapType.PRIVATE -> {
tags = tags + listOf(arrayOf("anon", ""))
signer.sign(createdAt, KIND, tags.toTypedArray(), message)
}
- LnZapEvent.ZapType.NONZAP -> throw IllegalArgumentException("Invalid zap type")
+
+ LnZapEvent.ZapType.NONZAP -> {
+ throw IllegalArgumentException("Invalid zap type")
+ }
}
}
@@ -139,16 +146,23 @@ class LnZapRequestEvent(
)
return when (zapType) {
- LnZapEvent.ZapType.PUBLIC -> signer.sign(createdAt, KIND, tags, message)
+ LnZapEvent.ZapType.PUBLIC -> {
+ signer.sign(createdAt, KIND, tags, message)
+ }
+
LnZapEvent.ZapType.ANONYMOUS -> {
tags += arrayOf(arrayOf("anon", ""))
NostrSignerInternal(KeyPair()).sign(createdAt, KIND, tags, message)
}
+
LnZapEvent.ZapType.PRIVATE -> {
tags += arrayOf(arrayOf("anon", ""))
signer.sign(createdAt, KIND, tags, message)
}
- LnZapEvent.ZapType.NONZAP -> throw IllegalArgumentException("Invalid zap type")
+
+ LnZapEvent.ZapType.NONZAP -> {
+ throw IllegalArgumentException("Invalid zap type")
+ }
}
}
}
diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/utils/EventFactory.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/utils/EventFactory.kt
index 6cffa2de4..2b79f5074 100644
--- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/utils/EventFactory.kt
+++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/utils/EventFactory.kt
@@ -189,34 +189,8 @@ class EventFactory {
ChannelMessageEvent.KIND -> ChannelMessageEvent(id, pubKey, createdAt, tags, content, sig)
ChannelMetadataEvent.KIND -> ChannelMetadataEvent(id, pubKey, createdAt, tags, content, sig)
ChannelMuteUserEvent.KIND -> ChannelMuteUserEvent(id, pubKey, createdAt, tags, content, sig)
- ChatMessageEncryptedFileHeaderEvent.KIND -> {
- if (id.isBlank()) {
- ChatMessageEncryptedFileHeaderEvent(
- EventHasher.hashId(pubKey, createdAt, kind, tags, content),
- pubKey,
- createdAt,
- tags,
- content,
- sig,
- )
- } else {
- ChatMessageEncryptedFileHeaderEvent(id, pubKey, createdAt, tags, content, sig)
- }
- }
- ChatMessageEvent.KIND -> {
- if (id.isBlank()) {
- ChatMessageEvent(
- EventHasher.hashId(pubKey, createdAt, kind, tags, content),
- pubKey,
- createdAt,
- tags,
- content,
- sig,
- )
- } else {
- ChatMessageEvent(id, pubKey, createdAt, tags, content, sig)
- }
- }
+ ChatMessageEncryptedFileHeaderEvent.KIND -> ChatMessageEncryptedFileHeaderEvent(id.ifBlank { EventHasher.hashId(pubKey, createdAt, kind, tags, content) }, pubKey, createdAt, tags, content, sig)
+ ChatMessageEvent.KIND -> ChatMessageEvent(id.ifBlank { EventHasher.hashId(pubKey, createdAt, kind, tags, content) }, pubKey, createdAt, tags, content, sig)
ChatMessageRelayListEvent.KIND -> ChatMessageRelayListEvent(id, pubKey, createdAt, tags, content, sig)
ClassifiedsEvent.KIND -> ClassifiedsEvent(id, pubKey, createdAt, tags, content, sig)
CommentEvent.KIND -> CommentEvent(id, pubKey, createdAt, tags, content, sig)
@@ -307,10 +281,7 @@ class EventFactory {
VoiceEvent.KIND -> VoiceEvent(id, pubKey, createdAt, tags, content, sig)
VoiceReplyEvent.KIND -> VoiceReplyEvent(id, pubKey, createdAt, tags, content, sig)
WikiNoteEvent.KIND -> WikiNoteEvent(id, pubKey, createdAt, tags, content, sig)
- else -> {
- factories[kind]?.build(id, pubKey, createdAt, tags, content, sig)
- ?: Event(id, pubKey, createdAt, kind, tags, content, sig)
- }
+ else -> factories[kind]?.build(id, pubKey, createdAt, tags, content, sig) ?: Event(id, pubKey, createdAt, kind, tags, content, sig)
} as T
}
}
diff --git a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toClient/MessageDeserializer.kt b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toClient/MessageDeserializer.kt
index 815ead96f..f3ab111d7 100644
--- a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toClient/MessageDeserializer.kt
+++ b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toClient/MessageDeserializer.kt
@@ -51,38 +51,44 @@ class MessageDeserializer : StdDeserializer(Message::class.java) {
)
}
- EoseMessage.LABEL ->
+ EoseMessage.LABEL -> {
EoseMessage(
subId = jp.nextTextValue(),
)
+ }
- NoticeMessage.LABEL ->
+ NoticeMessage.LABEL -> {
NoticeMessage(
message = jp.nextTextValue(),
)
+ }
- OkMessage.LABEL ->
+ OkMessage.LABEL -> {
OkMessage(
eventId = jp.nextTextValue(),
success = jp.nextBooleanValue(),
message = jp.nextTextValue() ?: "",
)
+ }
- AuthMessage.LABEL ->
+ AuthMessage.LABEL -> {
AuthMessage(
challenge = jp.nextTextValue(),
)
+ }
- NotifyMessage.LABEL ->
+ NotifyMessage.LABEL -> {
NotifyMessage(
message = jp.nextTextValue(),
)
+ }
- ClosedMessage.LABEL ->
+ ClosedMessage.LABEL -> {
ClosedMessage(
subId = jp.nextTextValue(),
message = jp.nextTextValue() ?: "",
)
+ }
CountMessage.LABEL -> {
val queryId = jp.nextTextValue()
diff --git a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toClient/MessageSerializer.kt b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toClient/MessageSerializer.kt
index 78056dc2a..470360c80 100644
--- a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toClient/MessageSerializer.kt
+++ b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toClient/MessageSerializer.kt
@@ -72,7 +72,9 @@ class MessageSerializer : StdSerializer(Message::class.java) {
countSerializer.serialize(msg.result, gen, provider)
}
- else -> null
+ else -> {
+ null
+ }
}
gen.writeEndArray()
diff --git a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toRelay/CommandDeserializer.kt b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toRelay/CommandDeserializer.kt
index 6c326a147..f8265d069 100644
--- a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toRelay/CommandDeserializer.kt
+++ b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toRelay/CommandDeserializer.kt
@@ -84,10 +84,11 @@ class CommandDeserializer : StdDeserializer(Command::class.java) {
)
}
- CloseCmd.LABEL ->
+ CloseCmd.LABEL -> {
CloseCmd(
subId = jp.nextTextValue(),
)
+ }
AuthCmd.LABEL -> {
jp.nextToken()
diff --git a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toRelay/CommandSerializer.kt b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toRelay/CommandSerializer.kt
index 8336d696b..bacbb8bf1 100644
--- a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toRelay/CommandSerializer.kt
+++ b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/commands/toRelay/CommandSerializer.kt
@@ -65,7 +65,9 @@ class CommandSerializer : StdSerializer(Command::class.java) {
}
}
- else -> null
+ else -> {
+ null
+ }
}
gen.writeEndArray()
diff --git a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/jackson/BunkerRequestDeserializer.kt b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/jackson/BunkerRequestDeserializer.kt
index ed14ef650..01f03ce8c 100644
--- a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/jackson/BunkerRequestDeserializer.kt
+++ b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/jackson/BunkerRequestDeserializer.kt
@@ -50,12 +50,10 @@ class BunkerRequestDeserializer : StdDeserializer(BunkerRequest::
BunkerRequestConnect.METHOD_NAME -> BunkerRequestConnect.parse(id, params)
BunkerRequestGetPublicKey.METHOD_NAME -> BunkerRequestGetPublicKey.parse(id, params)
BunkerRequestGetRelays.METHOD_NAME -> BunkerRequestGetRelays.parse(id, params)
-
BunkerRequestNip04Decrypt.METHOD_NAME -> BunkerRequestNip04Decrypt.parse(id, params)
BunkerRequestNip04Encrypt.METHOD_NAME -> BunkerRequestNip04Encrypt.parse(id, params)
BunkerRequestNip44Decrypt.METHOD_NAME -> BunkerRequestNip44Decrypt.parse(id, params)
BunkerRequestNip44Encrypt.METHOD_NAME -> BunkerRequestNip44Encrypt.parse(id, params)
-
BunkerRequestPing.METHOD_NAME -> BunkerRequestPing.parse(id, params)
BunkerRequestSign.METHOD_NAME -> BunkerRequestSign.parse(id, params)
else -> BunkerRequest(id, method, params)
diff --git a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/jackson/BunkerResponseDeserializer.kt b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/jackson/BunkerResponseDeserializer.kt
index 425ccf49b..ccaf834c4 100644
--- a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/jackson/BunkerResponseDeserializer.kt
+++ b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/jackson/BunkerResponseDeserializer.kt
@@ -50,8 +50,14 @@ class BunkerResponseDeserializer : StdDeserializer(BunkerRespons
if (result != null) {
when (result) {
- BunkerResponseAck.RESULT -> return BunkerResponseAck.parse(id, result, error)
- BunkerResponsePong.RESULT -> return BunkerResponsePong.parse(id, result, error)
+ BunkerResponseAck.RESULT -> {
+ return BunkerResponseAck.parse(id, result, error)
+ }
+
+ BunkerResponsePong.RESULT -> {
+ return BunkerResponsePong.parse(id, result, error)
+ }
+
else -> {
if (result.length == 64 && Hex.isHex(result)) {
return BunkerResponsePublicKey.parse(id, result)
diff --git a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/relay/NostrClientRepeatSubTest.kt b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/relay/NostrClientRepeatSubTest.kt
index d077fc0b9..e583343c5 100644
--- a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/relay/NostrClientRepeatSubTest.kt
+++ b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/relay/NostrClientRepeatSubTest.kt
@@ -64,14 +64,17 @@ class NostrClientRepeatSubTest : BaseNostrClientTest() {
) {
Log.d("Test", "Receiving message: $msgStr")
when (msg) {
- is EventMessage ->
+ is EventMessage -> {
if (mySubId == msg.subId) {
resultChannel.trySend(msg.event.id)
}
- is EoseMessage ->
+ }
+
+ is EoseMessage -> {
if (mySubId == msg.subId) {
resultChannel.trySend("EOSE")
}
+ }
}
}
}