Explicit type arguments can be inferred

This commit is contained in:
davotoula
2026-03-06 19:28:17 +01:00
parent bd71e9ae8f
commit 8868b1b0e6
45 changed files with 61 additions and 64 deletions
@@ -186,8 +186,8 @@ class AccountSettings(
var backupEphemeralChatList: EphemeralChatListEvent? = null, var backupEphemeralChatList: EphemeralChatListEvent? = null,
var backupTrustProviderList: TrustProviderListEvent? = null, var backupTrustProviderList: TrustProviderListEvent? = null,
val lastReadPerRoute: MutableStateFlow<Map<String, MutableStateFlow<Long>>> = MutableStateFlow(mapOf()), val lastReadPerRoute: MutableStateFlow<Map<String, MutableStateFlow<Long>>> = MutableStateFlow(mapOf()),
val hasDonatedInVersion: MutableStateFlow<Set<String>> = MutableStateFlow(setOf<String>()), val hasDonatedInVersion: MutableStateFlow<Set<String>> = MutableStateFlow(setOf()),
val pendingAttestations: MutableStateFlow<Map<HexKey, String>> = MutableStateFlow<Map<HexKey, String>>(mapOf()), val pendingAttestations: MutableStateFlow<Map<HexKey, String>> = MutableStateFlow(mapOf()),
var backupNipA3PaymentTargets: PaymentTargetsEvent? = null, var backupNipA3PaymentTargets: PaymentTargetsEvent? = null,
) : EphemeralChatRepository, ) : EphemeralChatRepository,
PublicChatListRepository { PublicChatListRepository {
@@ -612,7 +612,7 @@ class AccountSettings(
route: String, route: String,
timestampInSecs: Long, timestampInSecs: Long,
): MutableStateFlow<Long> = ): MutableStateFlow<Long> =
MutableStateFlow<Long>(timestampInSecs).also { newFlow -> MutableStateFlow(timestampInSecs).also { newFlow ->
lastReadPerRoute.update { it + Pair(route, newFlow) } lastReadPerRoute.update { it + Pair(route, newFlow) }
saveAccountSettings() saveAccountSettings()
} }
@@ -170,7 +170,7 @@ class AntiSpamFilter {
} }
} }
val flowSpam = MutableStateFlow<AntiSpamState>(AntiSpamState(this)) val flowSpam = MutableStateFlow(AntiSpamState(this))
} }
class AntiSpamState( class AntiSpamState(
@@ -35,7 +35,7 @@ fun <T> DataStore<Preferences>.getProperty(
serializer: (T) -> String, serializer: (T) -> String,
scope: CoroutineScope, scope: CoroutineScope,
): UpdatablePropertyFlow<T> = ): UpdatablePropertyFlow<T> =
UpdatablePropertyFlow<T>( UpdatablePropertyFlow(
flow = flow =
data data
.catch { e -> .catch { e ->
@@ -72,7 +72,7 @@ class EncryptedDataStore(
parser: (String) -> T, parser: (String) -> T,
serializer: (T) -> String, serializer: (T) -> String,
): UpdatablePropertyFlow<T> = ): UpdatablePropertyFlow<T> =
UpdatablePropertyFlow<T>( UpdatablePropertyFlow(
flow = flow =
store.data store.data
.catch { e -> .catch { e ->
@@ -60,8 +60,8 @@ class MergedFollowListsState(
val geotags: Set<String> = emptySet(), val geotags: Set<String> = emptySet(),
val communities: Set<String> = emptySet(), val communities: Set<String> = emptySet(),
) { ) {
val geotagScopes: Set<String> = geotags.mapTo(mutableSetOf<String>()) { GeohashId.toScope(it) } val geotagScopes: Set<String> = geotags.mapTo(mutableSetOf()) { GeohashId.toScope(it) }
val hashtagScopes: Set<String> = hashtags.mapTo(mutableSetOf<String>()) { HashtagId.toScope(it) } val hashtagScopes: Set<String> = hashtags.mapTo(mutableSetOf()) { HashtagId.toScope(it) }
} }
fun mergeLists( fun mergeLists(
@@ -52,8 +52,8 @@ class AllFollowsByOutboxTopNavFilter(
val defaultRelays: StateFlow<Set<NormalizedRelayUrl>>, val defaultRelays: StateFlow<Set<NormalizedRelayUrl>>,
val blockedRelays: StateFlow<Set<NormalizedRelayUrl>>, val blockedRelays: StateFlow<Set<NormalizedRelayUrl>>,
) : IFeedTopNavFilter { ) : IFeedTopNavFilter {
val geotagScopes: Set<String>? = geotags?.mapTo(mutableSetOf<String>()) { GeohashId.toScope(it) } val geotagScopes: Set<String>? = geotags?.mapTo(mutableSetOf()) { GeohashId.toScope(it) }
val hashtagScopes: Set<String>? = hashtags?.mapTo(mutableSetOf<String>()) { HashtagId.toScope(it) } val hashtagScopes: Set<String>? = hashtags?.mapTo(mutableSetOf()) { HashtagId.toScope(it) }
override fun matchAuthor(pubkey: HexKey): Boolean = authors == null || pubkey in authors override fun matchAuthor(pubkey: HexKey): Boolean = authors == null || pubkey in authors
@@ -35,6 +35,6 @@ class AllFollowsTopNavPerRelayFilter(
val geotags: Set<String>? = null, val geotags: Set<String>? = null,
val communities: Set<String>? = null, val communities: Set<String>? = null,
) : IFeedTopNavPerRelayFilter { ) : IFeedTopNavPerRelayFilter {
val geotagScopes: Set<String>? = geotags?.mapTo(mutableSetOf<String>()) { GeohashId.toScope(it) } val geotagScopes: Set<String>? = geotags?.mapTo(mutableSetOf()) { GeohashId.toScope(it) }
val hashtagScopes: Set<String>? = hashtags?.mapTo(mutableSetOf<String>()) { HashtagId.toScope(it) } val hashtagScopes: Set<String>? = hashtags?.mapTo(mutableSetOf()) { HashtagId.toScope(it) }
} }
@@ -37,7 +37,7 @@ class LocationTopNavFilter(
val geotags: Set<String>, val geotags: Set<String>,
val relayList: Set<NormalizedRelayUrl>, val relayList: Set<NormalizedRelayUrl>,
) : IFeedTopNavFilter { ) : IFeedTopNavFilter {
val geotagScopes: Set<String> = geotags.mapTo(mutableSetOf<String>()) { GeohashId.toScope(it) } val geotagScopes: Set<String> = geotags.mapTo(mutableSetOf()) { GeohashId.toScope(it) }
override fun matchAuthor(pubkey: HexKey): Boolean = true override fun matchAuthor(pubkey: HexKey): Boolean = true
@@ -28,5 +28,5 @@ import com.vitorpamplona.quartz.nip73ExternalIds.location.GeohashId
class LocationTopNavPerRelayFilter( class LocationTopNavPerRelayFilter(
val geotags: Set<String>, val geotags: Set<String>,
) : IFeedTopNavPerRelayFilter { ) : IFeedTopNavPerRelayFilter {
val geotagScopes: Set<String> = geotags.mapTo(mutableSetOf<String>()) { GeohashId.toScope(it) } val geotagScopes: Set<String> = geotags.mapTo(mutableSetOf()) { GeohashId.toScope(it) }
} }
@@ -55,7 +55,7 @@ class LocationState(
object Loading : LocationResult() object Loading : LocationResult()
} }
private var hasLocationPermission = MutableStateFlow<Boolean>(false) private var hasLocationPermission = MutableStateFlow(false)
private var latestLocation: LocationResult = LocationResult.Loading private var latestLocation: LocationResult = LocationResult.Loading
fun setLocationPermission(newValue: Boolean) { fun setLocationPermission(newValue: Boolean) {
@@ -102,7 +102,7 @@ fun VideoView(
) { ) {
val automaticallyStartPlayback = val automaticallyStartPlayback =
remember { remember {
mutableStateOf<Boolean>( mutableStateOf(
if (alwaysShowVideo) true else accountViewModel.settings.startVideoPlayback(), if (alwaysShowVideo) true else accountViewModel.settings.startVideoPlayback(),
) )
} }
@@ -76,7 +76,7 @@ fun MuteButton(
) { ) {
val holdOn = val holdOn =
remember { remember {
mutableStateOf<Boolean>( mutableStateOf(
true, true,
) )
} }
@@ -26,7 +26,7 @@ class ListWithUniqueSetCache<T, U>(
val key: (T) -> U, val key: (T) -> U,
) { ) {
private val list = AtomicReference(listOf<T>()) private val list = AtomicReference(listOf<T>())
private val cacheSet = AtomicReference<Set<U>?>(setOf<U>()) private val cacheSet = AtomicReference<Set<U>?>(setOf())
fun isEmpty() = list.get().isEmpty() fun isEmpty() = list.get().isEmpty()
@@ -49,7 +49,7 @@ class ListWithUniqueSetCache<T, U>(
} }
// Compute and attempt to atomically update the cache // Compute and attempt to atomically update the cache
val newSet = list.get().mapTo(mutableSetOf<U>(), key) val newSet = list.get().mapTo(mutableSetOf(), key)
cacheSet.compareAndSet(currentSet, newSet) cacheSet.compareAndSet(currentSet, newSet)
return newSet return newSet
} }
@@ -20,7 +20,6 @@
*/ */
package com.vitorpamplona.amethyst.service.relayClient.reqCommand package com.vitorpamplona.amethyst.service.relayClient.reqCommand
import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManagerControls
import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.model.LocalCache
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.account.AccountFilterAssembler import com.vitorpamplona.amethyst.service.relayClient.reqCommand.account.AccountFilterAssembler
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.ChannelFinderFilterAssemblyGroup import com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.ChannelFinderFilterAssemblyGroup
@@ -88,7 +87,7 @@ class RelaySubscriptionsCoordinator(
val nwc = NWCPaymentFilterAssembler(client) val nwc = NWCPaymentFilterAssembler(client)
val all = val all =
listOf<ComposeSubscriptionManagerControls>( listOf(
account, account,
home, home,
chatroomList, chatroomList,
@@ -72,7 +72,7 @@ class AccountFollowsLoaderSubAssembler(
* This assembler saves the EOSE per user key. That EOSE includes their metadata, etc * This assembler saves the EOSE per user key. That EOSE includes their metadata, etc
* and reports, but only from trusted accounts (follows of all logged in users). * and reports, but only from trusted accounts (follows of all logged in users).
*/ */
val hasTried: EOSEAccountFast<User> = EOSEAccountFast<User>(2000) val hasTried: EOSEAccountFast<User> = EOSEAccountFast(2000)
// updates all filters // updates all filters
override fun invalidateFilters(ignoreIfDoing: Boolean) { override fun invalidateFilters(ignoreIfDoing: Boolean) {
@@ -37,7 +37,7 @@ class EventWatcherSubAssembler(
allKeys: () -> Set<EventFinderQueryState>, allKeys: () -> Set<EventFinderQueryState>,
) : SingleSubEoseManager<EventFinderQueryState>(client, allKeys) { ) : SingleSubEoseManager<EventFinderQueryState>(client, allKeys) {
var lastNotesOnFilter = emptyList<Note>() var lastNotesOnFilter = emptyList<Note>()
var latestEOSEs: EOSEAccountFast<Note> = EOSEAccountFast<Note>(1000) var latestEOSEs: EOSEAccountFast<Note> = EOSEAccountFast(1000)
override fun newEose( override fun newEose(
relay: NormalizedRelayUrl, relay: NormalizedRelayUrl,
@@ -49,7 +49,7 @@ class UserOutboxFinderSubAssembler(
* This assembler saves the EOSE per user key. That EOSE includes their metadata, etc * This assembler saves the EOSE per user key. That EOSE includes their metadata, etc
* and reports, but only from trusted accounts (follows of all logged in users). * and reports, but only from trusted accounts (follows of all logged in users).
*/ */
var hasTried: EOSEAccountFast<User> = EOSEAccountFast<User>(200) var hasTried: EOSEAccountFast<User> = EOSEAccountFast(200)
fun newEose( fun newEose(
relay: NormalizedRelayUrl, relay: NormalizedRelayUrl,
@@ -30,8 +30,8 @@ import kotlin.concurrent.atomics.ExperimentalAtomicApi
class KindGroup( class KindGroup(
var count: AtomicInteger = AtomicInteger(0), var count: AtomicInteger = AtomicInteger(0),
var memory: AtomicInteger = AtomicInteger(0), var memory: AtomicInteger = AtomicInteger(0),
val subs: LargeCache<String, AtomicInteger> = LargeCache<String, AtomicInteger>(), val subs: LargeCache<String, AtomicInteger> = LargeCache(),
val relays: LargeCache<NormalizedRelayUrl, AtomicInteger> = LargeCache<NormalizedRelayUrl, AtomicInteger>(), val relays: LargeCache<NormalizedRelayUrl, AtomicInteger> = LargeCache(),
) { ) {
companion object { companion object {
const val MB: Int = 1024 const val MB: Int = 1024
@@ -32,7 +32,7 @@ typealias MutableTime = com.vitorpamplona.amethyst.commons.relays.MutableTime
open class EOSEByKey<U : Any>( open class EOSEByKey<U : Any>(
cacheSize: Int = 200, cacheSize: Int = 200,
) { ) {
var followList: LruCache<U, EOSERelayList> = LruCache<U, EOSERelayList>(cacheSize) var followList: LruCache<U, EOSERelayList> = LruCache(cacheSize)
fun addOrUpdate( fun addOrUpdate(
listCode: U, listCode: U,
@@ -99,7 +99,7 @@ open class EOSEAccountKey<U : Any>(
class EOSEAccountFast<T : Any>( class EOSEAccountFast<T : Any>(
cacheSize: Int = 20, cacheSize: Int = 20,
) { ) {
private val users: LruCache<T, EOSERelayList> = LruCache<T, EOSERelayList>(cacheSize) private val users: LruCache<T, EOSERelayList> = LruCache(cacheSize)
private val lock = Any() private val lock = Any()
fun addOrUpdate( fun addOrUpdate(
@@ -108,7 +108,7 @@ fun LoadOrCreateNote(
content: @Composable (Note?) -> Unit, content: @Composable (Note?) -> Unit,
) { ) {
var note by var note by
remember(event.id) { mutableStateOf<Note?>(accountViewModel.getNoteIfExists(event.id)) } remember(event.id) { mutableStateOf(accountViewModel.getNoteIfExists(event.id)) }
if (note == null) { if (note == null) {
LaunchedEffect(key1 = event.id) { LaunchedEffect(key1 = event.id) {
@@ -49,7 +49,7 @@ class ChannelFeedContentState(
val feedContent = _feedContent.asStateFlow() val feedContent = _feedContent.asStateFlow()
// Simple counter that changes when it needs to invalidate everything // Simple counter that changes when it needs to invalidate everything
private val _scrollToTop = MutableStateFlow<Int>(0) private val _scrollToTop = MutableStateFlow(0)
val scrollToTop = _scrollToTop.asStateFlow() val scrollToTop = _scrollToTop.asStateFlow()
var scrolltoTopPending = false var scrolltoTopPending = false
@@ -98,10 +98,10 @@ class ChannelFeedContentState(
if (notes.isEmpty()) { if (notes.isEmpty()) {
_feedContent.tryEmit(ChannelFeedState.Empty) _feedContent.tryEmit(ChannelFeedState.Empty)
} else if (currentState is ChannelFeedState.Loaded) { } else if (currentState is ChannelFeedState.Loaded) {
currentState.feed.tryEmit(LoadedFeedState<Channel>(notes, localFilter.showHiddenKey())) currentState.feed.tryEmit(LoadedFeedState(notes, localFilter.showHiddenKey()))
} else { } else {
_feedContent.tryEmit( _feedContent.tryEmit(
ChannelFeedState.Loaded(MutableStateFlow(LoadedFeedState<Channel>(notes, localFilter.showHiddenKey()))), ChannelFeedState.Loaded(MutableStateFlow(LoadedFeedState(notes, localFilter.showHiddenKey()))),
) )
} }
} }
@@ -130,7 +130,7 @@ fun DisplayAccount(
accountSessionManager: AccountSessionManager, accountSessionManager: AccountSessionManager,
) { ) {
var baseUser by remember(acc) { var baseUser by remember(acc) {
mutableStateOf<User?>( mutableStateOf(
decodePublicKeyAsHexOrNull(acc.npub)?.let { decodePublicKeyAsHexOrNull(acc.npub)?.let {
LocalCache.getUserIfExists(it) LocalCache.getUserIfExists(it)
}, },
@@ -87,7 +87,7 @@ class Nav(
) { ) {
navigationScope.launch { navigationScope.launch {
controller.navigate(route) { controller.navigate(route) {
popUpTo<T>(klass) { inclusive = true } popUpTo(klass) { inclusive = true }
} }
} }
} }
@@ -98,7 +98,7 @@ fun HiddenNotePreview() {
ThemeComparisonColumn( ThemeComparisonColumn(
toPreview = { toPreview = {
HiddenNote( HiddenNote(
reports = persistentSetOf<Note>(), reports = persistentSetOf(),
isHiddenAuthor = true, isHiddenAuthor = true,
accountViewModel = mockAccountViewModel(), accountViewModel = mockAccountViewModel(),
nav = EmptyNav(), nav = EmptyNav(),
@@ -481,7 +481,7 @@ private fun ReactionDetailGallery(
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
) { ) {
val defaultBackgroundColor = MaterialTheme.colorScheme.background val defaultBackgroundColor = MaterialTheme.colorScheme.background
val backgroundColor = remember { mutableStateOf<Color>(defaultBackgroundColor) } val backgroundColor = remember { mutableStateOf(defaultBackgroundColor) }
val hasReactions by observeNoteReferences(baseNote, accountViewModel) val hasReactions by observeNoteReferences(baseNote, accountViewModel)
@@ -757,7 +757,7 @@ private fun SlidingAnimationCount(
if (accountViewModel.settings.isPerformanceMode()) { if (accountViewModel.settings.isPerformanceMode()) {
TextCount(baseCount, textColor) TextCount(baseCount, textColor)
} else { } else {
AnimatedContent<Int>( AnimatedContent(
targetState = baseCount, targetState = baseCount,
transitionSpec = AnimatedContentTransitionScope<Int>::transitionSpec, transitionSpec = AnimatedContentTransitionScope<Int>::transitionSpec,
label = "SlidingAnimationCount", label = "SlidingAnimationCount",
@@ -34,9 +34,9 @@ import kotlin.uuid.Uuid
@Stable @Stable
class DraftTagState { class DraftTagState {
var current: String by mutableStateOf(newTag()) var current: String by mutableStateOf(newTag())
var usedDraftTags by mutableStateOf(setOf<String>(current)) var usedDraftTags by mutableStateOf(setOf(current))
private val _versions = MutableStateFlow<Int>(0) private val _versions = MutableStateFlow(0)
@OptIn(FlowPreview::class) @OptIn(FlowPreview::class)
val versions = _versions.debounce(1000) val versions = _versions.debounce(1000)
@@ -43,7 +43,7 @@ class UserSuggestionState(
val account: Account, val account: Account,
val requireAtSymbol: Boolean = true, val requireAtSymbol: Boolean = true,
) { ) {
val invalidations = MutableStateFlow<Int>(0) val invalidations = MutableStateFlow(0)
val currentWord = MutableStateFlow("") val currentWord = MutableStateFlow("")
val searchDataSourceState = SearchQueryState(MutableStateFlow(""), account) val searchDataSourceState = SearchQueryState(MutableStateFlow(""), account)
@@ -51,7 +51,7 @@ fun DisplayZapSplits(
remember(noteEvent) { remember(noteEvent) {
val list = noteEvent.zapSplitSetup() val list = noteEvent.zapSplitSetup()
if (list.isEmpty() && useAuthorIfEmpty) { if (list.isEmpty() && useAuthorIfEmpty) {
listOf<ZapSplitSetup>( listOf(
ZapSplitSetup( ZapSplitSetup(
pubKeyHex = noteEvent.pubKey, pubKeyHex = noteEvent.pubKey,
relay = null, relay = null,
@@ -116,13 +116,13 @@ private fun RenderPledgeAmount(
) { ) {
val repliesState by observeNoteReplies(baseNote, accountViewModel) val repliesState by observeNoteReplies(baseNote, accountViewModel)
var reward by remember { var reward by remember {
mutableStateOf<String>( mutableStateOf(
showAmount(baseReward.amount), showAmount(baseReward.amount),
) )
} }
var hasPledge by remember { var hasPledge by remember {
mutableStateOf<Boolean>( mutableStateOf(
false, false,
) )
} }
@@ -58,7 +58,7 @@ fun DisplayUncitedHashtags(
nav: INav, nav: INav,
) { ) {
val unusedHashtags by val unusedHashtags by
produceState(initialValue = emptyList<String>()) { produceState(initialValue = emptyList()) {
val tagsInEvent = event.hashtags() val tagsInEvent = event.hashtags()
if (tagsInEvent.isNotEmpty()) { if (tagsInEvent.isNotEmpty()) {
val state = CachedRichTextParser.parseText(content, event.tags.toImmutableListOfLists(), callbackUri) val state = CachedRichTextParser.parseText(content, event.tags.toImmutableListOfLists(), callbackUri)
@@ -35,7 +35,6 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import com.vitorpamplona.amethyst.commons.model.toImmutableListOfLists import com.vitorpamplona.amethyst.commons.model.toImmutableListOfLists
import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.Note
import com.vitorpamplona.amethyst.model.User
import com.vitorpamplona.amethyst.ui.components.RenderUserAsClickableText import com.vitorpamplona.amethyst.ui.components.RenderUserAsClickableText
import com.vitorpamplona.amethyst.ui.components.SensitivityWarning import com.vitorpamplona.amethyst.ui.components.SensitivityWarning
import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer
@@ -102,7 +101,7 @@ fun DisplayUncitedUsers(
nav: INav, nav: INav,
) { ) {
@Suppress("ProduceStateDoesNotAssignValue") @Suppress("ProduceStateDoesNotAssignValue")
val uncitedUsers by produceState(initialValue = emptyList<User>()) { val uncitedUsers by produceState(initialValue = emptyList()) {
val users = event.groupKeySetWithoutOwner() - event.citedUsers() val users = event.groupKeySetWithoutOwner() - event.citedUsers()
if (users.isNotEmpty()) { if (users.isNotEmpty()) {
val newUsers = accountViewModel.loadUsersSync(users.toList()) val newUsers = accountViewModel.loadUsersSync(users.toList())
@@ -511,7 +511,7 @@ class AccountViewModel(
}.toMutableMap() }.toMutableMap()
val results = val results =
mapNotNullAsync<CombinedZap, DecryptedInfo>( mapNotNullAsync(
zaps.filter { (it.request.event as? LnZapRequestEvent)?.isPrivateZap() == true }, zaps.filter { (it.request.event as? LnZapRequestEvent)?.isPrivateZap() == true },
) { next -> ) { next ->
val info = innerDecryptAmountMessage(next.request, next.response) val info = innerDecryptAmountMessage(next.request, next.response)
@@ -1609,7 +1609,7 @@ class AccountViewModel(
}.stateIn( }.stateIn(
viewModelScope, viewModelScope,
SharingStarted.WhileSubscribed(5000), SharingStarted.WhileSubscribed(5000),
emptySet<HexKey>(), emptySet(),
) )
val draftNoteCache = CachedDraftNotes(this) val draftNoteCache = CachedDraftNotes(this)
@@ -173,7 +173,7 @@ fun ChatBubbleLayout(
private fun BubblePreview() { private fun BubblePreview() {
val bgColor = val bgColor =
remember { remember {
mutableStateOf<Color>(Color.Transparent) mutableStateOf(Color.Transparent)
} }
Column { Column {
@@ -73,14 +73,14 @@ fun NewChatroomSubjectDialog(
Surface { Surface {
val groupName = val groupName =
remember { remember {
mutableStateOf<String>( mutableStateOf(
accountViewModel.account.chatroomList.rooms accountViewModel.account.chatroomList.rooms
.get(room) .get(room)
?.subject ?.subject
?.value ?: "", ?.value ?: "",
) )
} }
val message = remember { mutableStateOf<String>("") } val message = remember { mutableStateOf("") }
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
Column( Column(
@@ -129,7 +129,7 @@ class ChannelMetadataViewModel : ViewModel() {
val template = val template =
if (event != null) { if (event != null) {
val hint = EventHintBundle<ChannelCreateEvent>(event, channel.relays().firstOrNull()) val hint = EventHintBundle(event, channel.relays().firstOrNull())
ChannelMetadataEvent.build( ChannelMetadataEvent.build(
channelName.value.text, channelName.value.text,
@@ -238,7 +238,7 @@ fun LoadParticipants(
} }
} }
val hostsAuthor = hosts + (baseNote.author?.let { listOf(it) } ?: emptyList<User>()) val hostsAuthor = hosts + (baseNote.author?.let { listOf(it) } ?: emptyList())
val topFilter = accountViewModel.account.liveDiscoveryFollowLists.value val topFilter = accountViewModel.account.liveDiscoveryFollowLists.value
@@ -142,7 +142,7 @@ open class NewProductViewModel :
var price by mutableStateOf(TextFieldValue("")) var price by mutableStateOf(TextFieldValue(""))
var locationText by mutableStateOf(TextFieldValue("")) var locationText by mutableStateOf(TextFieldValue(""))
var category by mutableStateOf(TextFieldValue("")) var category by mutableStateOf(TextFieldValue(""))
var condition by mutableStateOf<ConditionTag.CONDITION>(ConditionTag.CONDITION.USED_LIKE_NEW) var condition by mutableStateOf(ConditionTag.CONDITION.USED_LIKE_NEW)
// Invoices // Invoices
var canAddInvoice by mutableStateOf(false) var canAddInvoice by mutableStateOf(false)
@@ -57,7 +57,7 @@ class GeoHashFeedFilter(
override fun applyFilter(newItems: Set<Note>): Set<Note> = innerApplyFilter(newItems) override fun applyFilter(newItems: Set<Note>): Set<Note> = innerApplyFilter(newItems)
private fun innerApplyFilter(collection: Collection<Note>): Set<Note> = collection.filterTo(HashSet<Note>()) { acceptableEvent(it, tag) } private fun innerApplyFilter(collection: Collection<Note>): Set<Note> = collection.filterTo(HashSet()) { acceptableEvent(it, tag) }
fun acceptableEvent( fun acceptableEvent(
it: Note, it: Note,
@@ -59,7 +59,7 @@ class HashtagFeedFilter(
override fun applyFilter(newItems: Set<Note>): Set<Note> = innerApplyFilter(newItems) override fun applyFilter(newItems: Set<Note>): Set<Note> = innerApplyFilter(newItems)
private fun innerApplyFilter(collection: Collection<Note>): Set<Note> = collection.filterTo(HashSet<Note>()) { acceptableEvent(it, tag) } private fun innerApplyFilter(collection: Collection<Note>): Set<Note> = collection.filterTo(HashSet()) { acceptableEvent(it, tag) }
fun acceptableEvent( fun acceptableEvent(
it: Note, it: Note,
@@ -194,7 +194,7 @@ class HomeLiveFilter(
return collection.sortedWith( return collection.sortedWith(
compareByDescending<Channel> { followCounts[it] } compareByDescending<Channel> { followCounts[it] }
.thenByDescending<Channel> { it.lastNote?.createdAt() ?: 0L } .thenByDescending { it.lastNote?.createdAt() ?: 0L }
.thenBy { it.hashCode() }, .thenBy { it.hashCode() },
) )
} }
@@ -426,7 +426,7 @@ private fun ListModifyDescriptionDialog(
onDismissDialog: () -> Unit, onDismissDialog: () -> Unit,
onModifyDescription: (String) -> Unit, onModifyDescription: (String) -> Unit,
) { ) {
val updatedDescription = remember { mutableStateOf<String>("") } val updatedDescription = remember { mutableStateOf("") }
val modifyIndicatorLabel = val modifyIndicatorLabel =
if (currentDescription == null) { if (currentDescription == null) {
@@ -72,7 +72,7 @@ class CardFeedContentState(
val feedContent = _feedContent.asStateFlow() val feedContent = _feedContent.asStateFlow()
// Simple counter that changes when it needs to invalidate everything // Simple counter that changes when it needs to invalidate everything
private val _scrollToTop = MutableStateFlow<Int>(0) private val _scrollToTop = MutableStateFlow(0)
val scrollToTop = _scrollToTop.asStateFlow() val scrollToTop = _scrollToTop.asStateFlow()
var scrolltoTopPending = false var scrolltoTopPending = false
@@ -38,7 +38,7 @@ class UserProfileReportsFeedFilter(
private fun innerApplyFilter(collection: Collection<Note>): Set<Note> = private fun innerApplyFilter(collection: Collection<Note>): Set<Note> =
collection collection
.filterTo(mutableSetOf<Note>()) { .filterTo(mutableSetOf()) {
it.event is ReportEvent && it.event?.isTaggedUser(user.pubkeyHex) == true it.event is ReportEvent && it.event?.isTaggedUser(user.pubkeyHex) == true
} }
@@ -22,7 +22,6 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common
import androidx.compose.runtime.Stable import androidx.compose.runtime.Stable
import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.model.LocalCache
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
@@ -48,7 +47,7 @@ class RelaySuggestionState {
.sortedBy { it.url } .sortedBy { it.url }
.take(20) .take(20)
} else { } else {
emptyList<NormalizedRelayUrl>() emptyList()
} }
}.flowOn(Dispatchers.IO) }.flowOn(Dispatchers.IO)
@@ -62,8 +62,8 @@ class SearchBarViewModel(
val focusRequester = FocusRequester() val focusRequester = FocusRequester()
var searchValue by mutableStateOf("") var searchValue by mutableStateOf("")
val invalidations = MutableStateFlow<Int>(0) val invalidations = MutableStateFlow(0)
val searchValueFlow = MutableStateFlow<String>("") val searchValueFlow = MutableStateFlow("")
val searchTerm = val searchTerm =
searchValueFlow searchValueFlow