From f3cefe0e1312f9f12eb96e7239c1d90eb06f54dd Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Sat, 28 Mar 2026 15:35:45 -0400 Subject: [PATCH] resolving some more warnings --- .../vitorpamplona/amethyst/desktop/ui/EventExtensions.kt | 3 +-- .../com/vitorpamplona/amethyst/desktop/ui/SearchScreen.kt | 3 +-- .../amethyst/desktop/ui/chats/ChatFileAttachment.kt | 8 +++++--- .../vitorpamplona/amethyst/desktop/ui/chats/ChatPane.kt | 5 ++--- .../amethyst/desktop/ui/chats/ChatroomListState.kt | 4 ++-- .../amethyst/desktop/ui/chats/NewDmDialog.kt | 3 +-- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/EventExtensions.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/EventExtensions.kt index cd76024c0..26650f514 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/EventExtensions.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/EventExtensions.kt @@ -20,7 +20,6 @@ */ package com.vitorpamplona.amethyst.desktop.ui -import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.desktop.ui.note.NoteDisplayData import com.vitorpamplona.quartz.nip01Core.core.Event @@ -31,7 +30,7 @@ import com.vitorpamplona.quartz.nip19Bech32.toNpub * Extension to convert Event to NoteDisplayData for the shared NoteCard. */ fun Event.toNoteDisplayData(cache: ICacheProvider? = null): NoteDisplayData { - val user = (cache?.getUserIfExists(pubKey) as? User) + val user = (cache?.getUserIfExists(pubKey)) val displayName = user?.toBestDisplayName() 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 c866b0ba5..fad441d4c 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 @@ -83,7 +83,6 @@ import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.commons.chess.RelaySyncStatus -import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.search.AdvancedSearchBarState import com.vitorpamplona.amethyst.commons.search.QuerySerializer import com.vitorpamplona.amethyst.commons.search.SavedSearch @@ -195,7 +194,7 @@ fun SearchScreen( if (event is MetadataEvent) { localCache.consumeMetadata(event) @Suppress("UNCHECKED_CAST") - val user = localCache.getUserIfExists(event.pubKey) as? User + val user = localCache.getUserIfExists(event.pubKey) if (user != null) { state.addPeopleResult(user) } diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatFileAttachment.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatFileAttachment.kt index 8c9993d67..7eff3e0b8 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatFileAttachment.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatFileAttachment.kt @@ -33,6 +33,8 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.Forward +import androidx.compose.material.icons.automirrored.filled.InsertDriveFile import androidx.compose.material.icons.filled.Download import androidx.compose.material.icons.filled.Forward import androidx.compose.material.icons.filled.InsertDriveFile @@ -92,7 +94,7 @@ fun ChatFileAttachment( // Auto-decrypt images LaunchedEffect(url) { - if (keyBytes != null && nonce != null && url != null) { + if (keyBytes != null && nonce != null) { isLoading = true try { val bytes = EncryptedMediaService.downloadAndDecrypt(url, keyBytes, nonce) @@ -191,7 +193,7 @@ fun ChatFileAttachment( // Non-image file Row(verticalAlignment = Alignment.CenterVertically) { Icon( - Icons.Default.InsertDriveFile, + Icons.AutoMirrored.Filled.InsertDriveFile, contentDescription = "File", modifier = Modifier.size(32.dp), ) @@ -237,7 +239,7 @@ fun ChatFileAttachment( DropdownMenuItem( text = { Text("Forward") }, leadingIcon = { - Icon(Icons.Default.Forward, contentDescription = null, modifier = Modifier.size(18.dp)) + Icon(Icons.AutoMirrored.Filled.Forward, contentDescription = null, modifier = Modifier.size(18.dp)) }, onClick = { showContextMenu = false diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatPane.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatPane.kt index da3745002..8b3dd7956 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatPane.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatPane.kt @@ -85,7 +85,6 @@ import androidx.compose.ui.window.Popup import androidx.compose.ui.window.PopupProperties import com.vitorpamplona.amethyst.commons.model.IAccount import com.vitorpamplona.amethyst.commons.model.Note -import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.ui.chat.ChatMessageCompose import com.vitorpamplona.amethyst.commons.ui.chat.ChatroomHeader @@ -196,7 +195,7 @@ fun ChatPane( } // Resolve users for the header - val users = roomKey.users.mapNotNull { cacheProvider.getUserIfExists(it) as? User } + val users = roomKey.users.mapNotNull { cacheProvider.getUserIfExists(it) } val isGroup = users.size > 1 // Load room into message state @@ -804,7 +803,7 @@ private suspend fun sendEncryptedFiles( ) { val orchestrator = DesktopUploadOrchestrator() val server = DesktopPreferences.preferredBlossomServer - val recipients = roomKey.users.mapNotNull { cacheProvider.getUserIfExists(it) as? User }.map { it.toPTag() } + val recipients = roomKey.users.mapNotNull { cacheProvider.getUserIfExists(it) }.map { it.toPTag() } for (file in files) { val cipher = AESGCM() diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatroomListState.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatroomListState.kt index 26e0cbd81..fad2585ae 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatroomListState.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatroomListState.kt @@ -199,11 +199,11 @@ class ChatroomListState( // Skip rooms with no messages if (chatroom.messages.isEmpty()) continue - val users = key.users.mapNotNull { cacheProvider.getUserIfExists(it) as? User } + val users = key.users.mapNotNull { cacheProvider.getUserIfExists(it) } // Collect pubkeys without profile info for (pubkey in key.users) { - val user = cacheProvider.getUserIfExists(pubkey) as? User + val user = cacheProvider.getUserIfExists(pubkey) if (user == null || user.metadataOrNull() == null) { pubkeysNeedingMetadata.add(pubkey) } diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/NewDmDialog.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/NewDmDialog.kt index d50cbbb33..aadf364f3 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/NewDmDialog.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/NewDmDialog.kt @@ -51,7 +51,6 @@ import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog -import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.search.SearchResult import com.vitorpamplona.amethyst.commons.ui.components.UserSearchCard @@ -183,7 +182,7 @@ fun NewDmDialog( bech32Results.filterIsInstance() items(userResults) { result -> val user = - cacheProvider.getUserIfExists(result.pubKeyHex) as? User + cacheProvider.getUserIfExists(result.pubKeyHex) if (user != null) { UserSearchCard( user = user,