mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-09 16:14:40 +00:00
fix: resolve LocalCache override, dropdown deprecation, and shadowed extension warnings
- Rename LocalCache Dao overrides to match supertype parameter names (getOrCreateUser: pubkey->hex, getOrCreateNote: idHex->hex, getOrCreateAddressableNote: key->address) so named-argument calls stay safe. - Replace deprecated MenuAnchorType with ExposedDropdownMenuAnchorType in the Buzz dropdown composables. - Remove the buzzChannelType() extension in BuzzChannelMetadata, now shadowed by the equivalent (stricter) member on GroupMetadataEvent, and drop its unused imports. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VBP6HGj9M2kzA4WKAivjC
This commit is contained in:
@@ -687,12 +687,12 @@ object LocalCache : ILocalCache, ICacheProvider, Dao {
|
||||
|
||||
fun load(keys: Set<String>): Set<User> = keys.mapNotNullTo(mutableSetOf(), ::checkGetOrCreateUser)
|
||||
|
||||
override fun getOrCreateUser(pubkey: HexKey): User {
|
||||
require(isValidHex(key = pubkey)) { "$pubkey is not a valid hex" }
|
||||
override fun getOrCreateUser(hex: HexKey): User {
|
||||
require(isValidHex(key = hex)) { "$hex is not a valid hex" }
|
||||
// Pass `this` as the UserContext — User now resolves each pinned
|
||||
// addressable note (kind:10002 / 10050 / 10019) lazily on first
|
||||
// read, instead of all-or-nothing at construction time.
|
||||
return users.getOrCreate(pubkey) { User(it, userContext) }
|
||||
return users.getOrCreate(hex) { User(it, userContext) }
|
||||
}
|
||||
|
||||
/** [UserContext] bridge to this cache's addressable lookup. */
|
||||
@@ -823,11 +823,11 @@ object LocalCache : ILocalCache, ICacheProvider, Dao {
|
||||
}
|
||||
}
|
||||
|
||||
override fun getOrCreateNote(idHex: String): Note {
|
||||
require(isValidHex(idHex)) { "$idHex is not a valid hex" }
|
||||
override fun getOrCreateNote(hex: String): Note {
|
||||
require(isValidHex(hex)) { "$hex is not a valid hex" }
|
||||
|
||||
return notes.getOrCreate(idHex) {
|
||||
Note(idHex)
|
||||
return notes.getOrCreate(hex) {
|
||||
Note(hex)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -945,11 +945,11 @@ object LocalCache : ILocalCache, ICacheProvider, Dao {
|
||||
|
||||
fun getOrCreateAddressableNoteInternal(key: Address): AddressableNote = addressables.getOrCreate(key) { AddressableNote(key) }
|
||||
|
||||
override fun getOrCreateAddressableNote(key: Address): AddressableNote {
|
||||
val note = getOrCreateAddressableNoteInternal(key)
|
||||
override fun getOrCreateAddressableNote(address: Address): AddressableNote {
|
||||
val note = getOrCreateAddressableNoteInternal(address)
|
||||
// Loads the user outside a Syncronized block to avoid blocking
|
||||
if (note.author == null) {
|
||||
note.author = checkGetOrCreateUser(key.pubKeyHex)
|
||||
note.author = checkGetOrCreateUser(address.pubKeyHex)
|
||||
}
|
||||
return note
|
||||
}
|
||||
|
||||
+2
-2
@@ -24,9 +24,9 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExposedDropdownMenuAnchorType
|
||||
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||
import androidx.compose.material3.ExposedDropdownMenuDefaults
|
||||
import androidx.compose.material3.MenuAnchorType
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -77,7 +77,7 @@ fun EditableSuggestDropdown(
|
||||
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = showMenu) },
|
||||
keyboardOptions = keyboardOptions,
|
||||
supportingText = supportingText?.let { { Text(it) } },
|
||||
modifier = modifier.fillMaxWidth().menuAnchor(MenuAnchorType.PrimaryEditable),
|
||||
modifier = modifier.fillMaxWidth().menuAnchor(ExposedDropdownMenuAnchorType.PrimaryEditable),
|
||||
)
|
||||
ExposedDropdownMenu(expanded = showMenu, onDismissRequest = { expanded = false }) {
|
||||
filtered.forEach { opt ->
|
||||
|
||||
+2
-2
@@ -55,13 +55,13 @@ import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ColorScheme
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExposedDropdownMenuAnchorType
|
||||
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||
import androidx.compose.material3.ExposedDropdownMenuDefaults
|
||||
import androidx.compose.material3.ExtendedFloatingActionButton
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.MenuAnchorType
|
||||
import androidx.compose.material3.ModalBottomSheet
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
@@ -823,7 +823,7 @@ private fun WorkflowPicker(
|
||||
label = { Text(stringRes(R.string.buzz_workflow_picker_label)) },
|
||||
placeholder = { Text(if (definitions.isEmpty()) stringRes(R.string.buzz_workflow_picker_empty) else stringRes(R.string.buzz_workflow_picker_choose)) },
|
||||
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) },
|
||||
modifier = Modifier.fillMaxWidth().menuAnchor(MenuAnchorType.PrimaryNotEditable),
|
||||
modifier = Modifier.fillMaxWidth().menuAnchor(ExposedDropdownMenuAnchorType.PrimaryNotEditable),
|
||||
)
|
||||
ExposedDropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }) {
|
||||
definitions.forEach { def ->
|
||||
|
||||
-1
@@ -98,7 +98,6 @@ import com.vitorpamplona.amethyst.ui.stringRes
|
||||
import com.vitorpamplona.amethyst.ui.theme.warningColor
|
||||
import com.vitorpamplona.quartz.buzz.workspace.BUZZ_CHANNEL_TYPE_DM
|
||||
import com.vitorpamplona.quartz.buzz.workspace.BUZZ_CHANNEL_TYPE_FORUM
|
||||
import com.vitorpamplona.quartz.buzz.workspace.buzzChannelType
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
|
||||
|
||||
-1
@@ -71,7 +71,6 @@ import com.vitorpamplona.amethyst.ui.stringRes
|
||||
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
||||
import com.vitorpamplona.quartz.buzz.forum.ForumPostEvent
|
||||
import com.vitorpamplona.quartz.buzz.workspace.BUZZ_CHANNEL_TYPE_FORUM
|
||||
import com.vitorpamplona.quartz.buzz.workspace.buzzChannelType
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
|
||||
import com.vitorpamplona.quartz.nip29RelayGroups.GroupId
|
||||
|
||||
-4
@@ -21,7 +21,6 @@
|
||||
package com.vitorpamplona.quartz.buzz.workspace
|
||||
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.firstTagValue
|
||||
import com.vitorpamplona.quartz.nip01Core.core.toHexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.people.PTag
|
||||
import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent
|
||||
@@ -38,9 +37,6 @@ import com.vitorpamplona.quartz.utils.RandomInstance
|
||||
* (emit_group_discovery_events).
|
||||
*/
|
||||
|
||||
/** The Buzz channel type from the relay's `t` tag ("stream" / "forum" / "dm"), or null. */
|
||||
fun GroupMetadataEvent.buzzChannelType(): String? = tags.firstTagValue("t")
|
||||
|
||||
/** True when the relay marks this channel a DM (`t` = "dm"). */
|
||||
fun GroupMetadataEvent.isBuzzDm(): Boolean = buzzChannelType() == BUZZ_CHANNEL_TYPE_DM
|
||||
|
||||
|
||||
Reference in New Issue
Block a user