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 backupTrustProviderList: TrustProviderListEvent? = null,
val lastReadPerRoute: MutableStateFlow<Map<String, MutableStateFlow<Long>>> = MutableStateFlow(mapOf()),
val hasDonatedInVersion: MutableStateFlow<Set<String>> = MutableStateFlow(setOf<String>()),
val pendingAttestations: MutableStateFlow<Map<HexKey, String>> = MutableStateFlow<Map<HexKey, String>>(mapOf()),
val hasDonatedInVersion: MutableStateFlow<Set<String>> = MutableStateFlow(setOf()),
val pendingAttestations: MutableStateFlow<Map<HexKey, String>> = MutableStateFlow(mapOf()),
var backupNipA3PaymentTargets: PaymentTargetsEvent? = null,
) : EphemeralChatRepository,
PublicChatListRepository {
@@ -612,7 +612,7 @@ class AccountSettings(
route: String,
timestampInSecs: Long,
): MutableStateFlow<Long> =
MutableStateFlow<Long>(timestampInSecs).also { newFlow ->
MutableStateFlow(timestampInSecs).also { newFlow ->
lastReadPerRoute.update { it + Pair(route, newFlow) }
saveAccountSettings()
}
@@ -170,7 +170,7 @@ class AntiSpamFilter {
}
}
val flowSpam = MutableStateFlow<AntiSpamState>(AntiSpamState(this))
val flowSpam = MutableStateFlow(AntiSpamState(this))
}
class AntiSpamState(
@@ -35,7 +35,7 @@ fun <T> DataStore<Preferences>.getProperty(
serializer: (T) -> String,
scope: CoroutineScope,
): UpdatablePropertyFlow<T> =
UpdatablePropertyFlow<T>(
UpdatablePropertyFlow(
flow =
data
.catch { e ->
@@ -72,7 +72,7 @@ class EncryptedDataStore(
parser: (String) -> T,
serializer: (T) -> String,
): UpdatablePropertyFlow<T> =
UpdatablePropertyFlow<T>(
UpdatablePropertyFlow(
flow =
store.data
.catch { e ->
@@ -60,8 +60,8 @@ class MergedFollowListsState(
val geotags: Set<String> = emptySet(),
val communities: Set<String> = emptySet(),
) {
val geotagScopes: Set<String> = geotags.mapTo(mutableSetOf<String>()) { GeohashId.toScope(it) }
val hashtagScopes: Set<String> = hashtags.mapTo(mutableSetOf<String>()) { HashtagId.toScope(it) }
val geotagScopes: Set<String> = geotags.mapTo(mutableSetOf()) { GeohashId.toScope(it) }
val hashtagScopes: Set<String> = hashtags.mapTo(mutableSetOf()) { HashtagId.toScope(it) }
}
fun mergeLists(
@@ -52,8 +52,8 @@ class AllFollowsByOutboxTopNavFilter(
val defaultRelays: StateFlow<Set<NormalizedRelayUrl>>,
val blockedRelays: StateFlow<Set<NormalizedRelayUrl>>,
) : IFeedTopNavFilter {
val geotagScopes: Set<String>? = geotags?.mapTo(mutableSetOf<String>()) { GeohashId.toScope(it) }
val hashtagScopes: Set<String>? = hashtags?.mapTo(mutableSetOf<String>()) { HashtagId.toScope(it) }
val geotagScopes: Set<String>? = geotags?.mapTo(mutableSetOf()) { GeohashId.toScope(it) }
val hashtagScopes: Set<String>? = hashtags?.mapTo(mutableSetOf()) { HashtagId.toScope(it) }
override fun matchAuthor(pubkey: HexKey): Boolean = authors == null || pubkey in authors
@@ -35,6 +35,6 @@ class AllFollowsTopNavPerRelayFilter(
val geotags: Set<String>? = null,
val communities: Set<String>? = null,
) : IFeedTopNavPerRelayFilter {
val geotagScopes: Set<String>? = geotags?.mapTo(mutableSetOf<String>()) { GeohashId.toScope(it) }
val hashtagScopes: Set<String>? = hashtags?.mapTo(mutableSetOf<String>()) { HashtagId.toScope(it) }
val geotagScopes: Set<String>? = geotags?.mapTo(mutableSetOf()) { GeohashId.toScope(it) }
val hashtagScopes: Set<String>? = hashtags?.mapTo(mutableSetOf()) { HashtagId.toScope(it) }
}
@@ -37,7 +37,7 @@ class LocationTopNavFilter(
val geotags: Set<String>,
val relayList: Set<NormalizedRelayUrl>,
) : 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
@@ -28,5 +28,5 @@ import com.vitorpamplona.quartz.nip73ExternalIds.location.GeohashId
class LocationTopNavPerRelayFilter(
val geotags: Set<String>,
) : 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()
}
private var hasLocationPermission = MutableStateFlow<Boolean>(false)
private var hasLocationPermission = MutableStateFlow(false)
private var latestLocation: LocationResult = LocationResult.Loading
fun setLocationPermission(newValue: Boolean) {
@@ -102,7 +102,7 @@ fun VideoView(
) {
val automaticallyStartPlayback =
remember {
mutableStateOf<Boolean>(
mutableStateOf(
if (alwaysShowVideo) true else accountViewModel.settings.startVideoPlayback(),
)
}
@@ -76,7 +76,7 @@ fun MuteButton(
) {
val holdOn =
remember {
mutableStateOf<Boolean>(
mutableStateOf(
true,
)
}
@@ -26,7 +26,7 @@ class ListWithUniqueSetCache<T, U>(
val key: (T) -> U,
) {
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()
@@ -49,7 +49,7 @@ class ListWithUniqueSetCache<T, U>(
}
// 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)
return newSet
}
@@ -20,7 +20,6 @@
*/
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.service.relayClient.reqCommand.account.AccountFilterAssembler
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.ChannelFinderFilterAssemblyGroup
@@ -88,7 +87,7 @@ class RelaySubscriptionsCoordinator(
val nwc = NWCPaymentFilterAssembler(client)
val all =
listOf<ComposeSubscriptionManagerControls>(
listOf(
account,
home,
chatroomList,
@@ -72,7 +72,7 @@ class AccountFollowsLoaderSubAssembler(
* 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).
*/
val hasTried: EOSEAccountFast<User> = EOSEAccountFast<User>(2000)
val hasTried: EOSEAccountFast<User> = EOSEAccountFast(2000)
// updates all filters
override fun invalidateFilters(ignoreIfDoing: Boolean) {
@@ -37,7 +37,7 @@ class EventWatcherSubAssembler(
allKeys: () -> Set<EventFinderQueryState>,
) : SingleSubEoseManager<EventFinderQueryState>(client, allKeys) {
var lastNotesOnFilter = emptyList<Note>()
var latestEOSEs: EOSEAccountFast<Note> = EOSEAccountFast<Note>(1000)
var latestEOSEs: EOSEAccountFast<Note> = EOSEAccountFast(1000)
override fun newEose(
relay: NormalizedRelayUrl,
@@ -49,7 +49,7 @@ class UserOutboxFinderSubAssembler(
* 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).
*/
var hasTried: EOSEAccountFast<User> = EOSEAccountFast<User>(200)
var hasTried: EOSEAccountFast<User> = EOSEAccountFast(200)
fun newEose(
relay: NormalizedRelayUrl,
@@ -30,8 +30,8 @@ import kotlin.concurrent.atomics.ExperimentalAtomicApi
class KindGroup(
var count: AtomicInteger = AtomicInteger(0),
var memory: AtomicInteger = AtomicInteger(0),
val subs: LargeCache<String, AtomicInteger> = LargeCache<String, AtomicInteger>(),
val relays: LargeCache<NormalizedRelayUrl, AtomicInteger> = LargeCache<NormalizedRelayUrl, AtomicInteger>(),
val subs: LargeCache<String, AtomicInteger> = LargeCache(),
val relays: LargeCache<NormalizedRelayUrl, AtomicInteger> = LargeCache(),
) {
companion object {
const val MB: Int = 1024
@@ -32,7 +32,7 @@ typealias MutableTime = com.vitorpamplona.amethyst.commons.relays.MutableTime
open class EOSEByKey<U : Any>(
cacheSize: Int = 200,
) {
var followList: LruCache<U, EOSERelayList> = LruCache<U, EOSERelayList>(cacheSize)
var followList: LruCache<U, EOSERelayList> = LruCache(cacheSize)
fun addOrUpdate(
listCode: U,
@@ -99,7 +99,7 @@ open class EOSEAccountKey<U : Any>(
class EOSEAccountFast<T : Any>(
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()
fun addOrUpdate(
@@ -108,7 +108,7 @@ fun LoadOrCreateNote(
content: @Composable (Note?) -> Unit,
) {
var note by
remember(event.id) { mutableStateOf<Note?>(accountViewModel.getNoteIfExists(event.id)) }
remember(event.id) { mutableStateOf(accountViewModel.getNoteIfExists(event.id)) }
if (note == null) {
LaunchedEffect(key1 = event.id) {
@@ -49,7 +49,7 @@ class ChannelFeedContentState(
val feedContent = _feedContent.asStateFlow()
// 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()
var scrolltoTopPending = false
@@ -98,10 +98,10 @@ class ChannelFeedContentState(
if (notes.isEmpty()) {
_feedContent.tryEmit(ChannelFeedState.Empty)
} else if (currentState is ChannelFeedState.Loaded) {
currentState.feed.tryEmit(LoadedFeedState<Channel>(notes, localFilter.showHiddenKey()))
currentState.feed.tryEmit(LoadedFeedState(notes, localFilter.showHiddenKey()))
} else {
_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,
) {
var baseUser by remember(acc) {
mutableStateOf<User?>(
mutableStateOf(
decodePublicKeyAsHexOrNull(acc.npub)?.let {
LocalCache.getUserIfExists(it)
},
@@ -87,7 +87,7 @@ class Nav(
) {
navigationScope.launch {
controller.navigate(route) {
popUpTo<T>(klass) { inclusive = true }
popUpTo(klass) { inclusive = true }
}
}
}
@@ -98,7 +98,7 @@ fun HiddenNotePreview() {
ThemeComparisonColumn(
toPreview = {
HiddenNote(
reports = persistentSetOf<Note>(),
reports = persistentSetOf(),
isHiddenAuthor = true,
accountViewModel = mockAccountViewModel(),
nav = EmptyNav(),
@@ -481,7 +481,7 @@ private fun ReactionDetailGallery(
accountViewModel: AccountViewModel,
) {
val defaultBackgroundColor = MaterialTheme.colorScheme.background
val backgroundColor = remember { mutableStateOf<Color>(defaultBackgroundColor) }
val backgroundColor = remember { mutableStateOf(defaultBackgroundColor) }
val hasReactions by observeNoteReferences(baseNote, accountViewModel)
@@ -757,7 +757,7 @@ private fun SlidingAnimationCount(
if (accountViewModel.settings.isPerformanceMode()) {
TextCount(baseCount, textColor)
} else {
AnimatedContent<Int>(
AnimatedContent(
targetState = baseCount,
transitionSpec = AnimatedContentTransitionScope<Int>::transitionSpec,
label = "SlidingAnimationCount",
@@ -34,9 +34,9 @@ import kotlin.uuid.Uuid
@Stable
class DraftTagState {
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)
val versions = _versions.debounce(1000)
@@ -43,7 +43,7 @@ class UserSuggestionState(
val account: Account,
val requireAtSymbol: Boolean = true,
) {
val invalidations = MutableStateFlow<Int>(0)
val invalidations = MutableStateFlow(0)
val currentWord = MutableStateFlow("")
val searchDataSourceState = SearchQueryState(MutableStateFlow(""), account)
@@ -51,7 +51,7 @@ fun DisplayZapSplits(
remember(noteEvent) {
val list = noteEvent.zapSplitSetup()
if (list.isEmpty() && useAuthorIfEmpty) {
listOf<ZapSplitSetup>(
listOf(
ZapSplitSetup(
pubKeyHex = noteEvent.pubKey,
relay = null,
@@ -116,13 +116,13 @@ private fun RenderPledgeAmount(
) {
val repliesState by observeNoteReplies(baseNote, accountViewModel)
var reward by remember {
mutableStateOf<String>(
mutableStateOf(
showAmount(baseReward.amount),
)
}
var hasPledge by remember {
mutableStateOf<Boolean>(
mutableStateOf(
false,
)
}
@@ -58,7 +58,7 @@ fun DisplayUncitedHashtags(
nav: INav,
) {
val unusedHashtags by
produceState(initialValue = emptyList<String>()) {
produceState(initialValue = emptyList()) {
val tagsInEvent = event.hashtags()
if (tagsInEvent.isNotEmpty()) {
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 com.vitorpamplona.amethyst.commons.model.toImmutableListOfLists
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.SensitivityWarning
import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer
@@ -102,7 +101,7 @@ fun DisplayUncitedUsers(
nav: INav,
) {
@Suppress("ProduceStateDoesNotAssignValue")
val uncitedUsers by produceState(initialValue = emptyList<User>()) {
val uncitedUsers by produceState(initialValue = emptyList()) {
val users = event.groupKeySetWithoutOwner() - event.citedUsers()
if (users.isNotEmpty()) {
val newUsers = accountViewModel.loadUsersSync(users.toList())
@@ -511,7 +511,7 @@ class AccountViewModel(
}.toMutableMap()
val results =
mapNotNullAsync<CombinedZap, DecryptedInfo>(
mapNotNullAsync(
zaps.filter { (it.request.event as? LnZapRequestEvent)?.isPrivateZap() == true },
) { next ->
val info = innerDecryptAmountMessage(next.request, next.response)
@@ -1609,7 +1609,7 @@ class AccountViewModel(
}.stateIn(
viewModelScope,
SharingStarted.WhileSubscribed(5000),
emptySet<HexKey>(),
emptySet(),
)
val draftNoteCache = CachedDraftNotes(this)
@@ -173,7 +173,7 @@ fun ChatBubbleLayout(
private fun BubblePreview() {
val bgColor =
remember {
mutableStateOf<Color>(Color.Transparent)
mutableStateOf(Color.Transparent)
}
Column {
@@ -73,14 +73,14 @@ fun NewChatroomSubjectDialog(
Surface {
val groupName =
remember {
mutableStateOf<String>(
mutableStateOf(
accountViewModel.account.chatroomList.rooms
.get(room)
?.subject
?.value ?: "",
)
}
val message = remember { mutableStateOf<String>("") }
val message = remember { mutableStateOf("") }
val scope = rememberCoroutineScope()
Column(
@@ -129,7 +129,7 @@ class ChannelMetadataViewModel : ViewModel() {
val template =
if (event != null) {
val hint = EventHintBundle<ChannelCreateEvent>(event, channel.relays().firstOrNull())
val hint = EventHintBundle(event, channel.relays().firstOrNull())
ChannelMetadataEvent.build(
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
@@ -142,7 +142,7 @@ open class NewProductViewModel :
var price by mutableStateOf(TextFieldValue(""))
var locationText 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
var canAddInvoice by mutableStateOf(false)
@@ -57,7 +57,7 @@ class GeoHashFeedFilter(
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(
it: Note,
@@ -59,7 +59,7 @@ class HashtagFeedFilter(
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(
it: Note,
@@ -194,7 +194,7 @@ class HomeLiveFilter(
return collection.sortedWith(
compareByDescending<Channel> { followCounts[it] }
.thenByDescending<Channel> { it.lastNote?.createdAt() ?: 0L }
.thenByDescending { it.lastNote?.createdAt() ?: 0L }
.thenBy { it.hashCode() },
)
}
@@ -426,7 +426,7 @@ private fun ListModifyDescriptionDialog(
onDismissDialog: () -> Unit,
onModifyDescription: (String) -> Unit,
) {
val updatedDescription = remember { mutableStateOf<String>("") }
val updatedDescription = remember { mutableStateOf("") }
val modifyIndicatorLabel =
if (currentDescription == null) {
@@ -72,7 +72,7 @@ class CardFeedContentState(
val feedContent = _feedContent.asStateFlow()
// 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()
var scrolltoTopPending = false
@@ -38,7 +38,7 @@ class UserProfileReportsFeedFilter(
private fun innerApplyFilter(collection: Collection<Note>): Set<Note> =
collection
.filterTo(mutableSetOf<Note>()) {
.filterTo(mutableSetOf()) {
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 com.vitorpamplona.amethyst.model.LocalCache
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.MutableStateFlow
@@ -48,7 +47,7 @@ class RelaySuggestionState {
.sortedBy { it.url }
.take(20)
} else {
emptyList<NormalizedRelayUrl>()
emptyList()
}
}.flowOn(Dispatchers.IO)
@@ -62,8 +62,8 @@ class SearchBarViewModel(
val focusRequester = FocusRequester()
var searchValue by mutableStateOf("")
val invalidations = MutableStateFlow<Int>(0)
val searchValueFlow = MutableStateFlow<String>("")
val invalidations = MutableStateFlow(0)
val searchValueFlow = MutableStateFlow("")
val searchTerm =
searchValueFlow