Lambda argument should be moved out of parentheses

This commit is contained in:
davotoula
2026-03-06 22:17:32 +01:00
parent d7d9352a90
commit 6bfb508ddc
4 changed files with 48 additions and 50 deletions
@@ -127,7 +127,7 @@ class ImageUploadTesting {
// assertEquals(server.baseUrl, "${server.baseUrl}/$initialHash", result.url?.removeSuffix(".png")) // assertEquals(server.baseUrl, "${server.baseUrl}/$initialHash", result.url?.removeSuffix(".png"))
val imageData: ByteArray = val imageData: ByteArray =
ImageDownloader().waitAndGetImage(result.url!!, { client })?.bytes ImageDownloader().waitAndGetImage(result.url!!) { client }?.bytes
?: run { ?: run {
fail("${server.name}: Should not be null") fail("${server.name}: Should not be null")
return return
@@ -142,8 +142,7 @@ class ImageUploadTesting {
ServerInfoRetriever() ServerInfoRetriever()
.loadInfo( .loadInfo(
server.baseUrl, server.baseUrl,
{ client }, ) { client }
)
val payload = getBitmap() val payload = getBitmap()
val inputStream = payload.inputStream() val inputStream = payload.inputStream()
@@ -172,7 +171,7 @@ class ImageUploadTesting {
Assert.assertTrue("${server.name}: Invalid result url", url.startsWith("http")) Assert.assertTrue("${server.name}: Invalid result url", url.startsWith("http"))
val imageData: ByteArray = val imageData: ByteArray =
ImageDownloader().waitAndGetImage(url, { client })?.bytes ImageDownloader().waitAndGetImage(url) { client }?.bytes
?: run { ?: run {
fail("${server.name}: Should not be null") fail("${server.name}: Should not be null")
return return
@@ -117,7 +117,7 @@ fun SensitivityWarning(
@Composable @Composable
fun ContentWarningNotePreview() { fun ContentWarningNotePreview() {
ThemeComparisonColumn { ThemeComparisonColumn {
ContentWarningNote({}) ContentWarningNote {}
} }
} }
@@ -555,8 +555,8 @@ open class ShortNotePostViewModel :
val serverToUse = voiceSelectedServer ?: accountViewModel.account.settings.defaultFileServer val serverToUse = voiceSelectedServer ?: accountViewModel.account.settings.defaultFileServer
uploadVoiceMessageSync( uploadVoiceMessageSync(
serverToUse, serverToUse,
{ _, _ -> }, // Error handling is done by checking voiceMetadata below ) { _, _ -> } // Error handling is done by checking voiceMetadata below
)
// Abort if upload failed - don't post without voice data // Abort if upload failed - don't post without voice data
if (voiceMetadata == null) { if (voiceMetadata == null) {
Log.w("ShortNotePostViewModel", "Voice upload failed, aborting post") Log.w("ShortNotePostViewModel", "Voice upload failed, aborting post")
@@ -165,13 +165,13 @@ class CardFeedContentState(
val reactionsPerEvent = mutableMapOf<Note, MutableList<Note>>() val reactionsPerEvent = mutableMapOf<Note, MutableList<Note>>()
notes notes
.filter { it.event is ReactionEvent } .filter { it.event is ReactionEvent }
.forEach { .forEach { note ->
val reactedPost = val reactedPost =
it.replyTo?.lastOrNull { note.replyTo?.lastOrNull {
it.event !is ChannelMetadataEvent && it.event !is ChannelCreateEvent it.event !is ChannelMetadataEvent && it.event !is ChannelCreateEvent
} }
if (reactedPost != null) { if (reactedPost != null) {
reactionsPerEvent.getOrPut(reactedPost, { mutableListOf() }).add(it) reactionsPerEvent.getOrPut(reactedPost) { mutableListOf() }.add(note)
} }
} }
@@ -192,7 +192,7 @@ class CardFeedContentState(
// var newZapRequestEvent = LocalCache.checkPrivateZap(zapRequest.event as Event) // var newZapRequestEvent = LocalCache.checkPrivateZap(zapRequest.event as Event)
// zapRequest.event = newZapRequestEvent // zapRequest.event = newZapRequestEvent
zapsPerEvent zapsPerEvent
.getOrPut(zappedPost, { mutableListOf() }) .getOrPut(zappedPost) { mutableListOf() }
.add(CombinedZap(zapRequest, zapEvent)) .add(CombinedZap(zapRequest, zapEvent))
} }
} else { } else {
@@ -215,7 +215,7 @@ class CardFeedContentState(
val zapRequestNote = getNoteIfExists(zapRequest.id) val zapRequestNote = getNoteIfExists(zapRequest.id)
if (zapRequestNote != null) { if (zapRequestNote != null) {
zapsPerUser zapsPerUser
.getOrPut(author, { mutableListOf() }) .getOrPut(author) { mutableListOf() }
.add(CombinedZap(zapRequestNote, zapEvent)) .add(CombinedZap(zapRequestNote, zapEvent))
} }
} }
@@ -226,13 +226,13 @@ class CardFeedContentState(
val boostsPerEvent = mutableMapOf<Note, MutableList<Note>>() val boostsPerEvent = mutableMapOf<Note, MutableList<Note>>()
notes notes
.filter { it.event is RepostEvent || it.event is GenericRepostEvent } .filter { it.event is RepostEvent || it.event is GenericRepostEvent }
.forEach { .forEach { note ->
val boostedPost = val boostedPost =
it.replyTo?.lastOrNull { note.replyTo?.lastOrNull {
it.event !is ChannelMetadataEvent && it.event !is ChannelCreateEvent it.event !is ChannelMetadataEvent && it.event !is ChannelCreateEvent
} }
if (boostedPost != null) { if (boostedPost != null) {
boostsPerEvent.getOrPut(boostedPost, { mutableListOf() }).add(it) boostsPerEvent.getOrPut(boostedPost) { mutableListOf() }.add(note)
} }
} }
@@ -240,42 +240,41 @@ class CardFeedContentState(
val allBaseNotes = zapsPerEvent.keys + boostsPerEvent.keys + reactionsPerEvent.keys val allBaseNotes = zapsPerEvent.keys + boostsPerEvent.keys + reactionsPerEvent.keys
val multiCards = val multiCards =
allBaseNotes allBaseNotes.flatMap { baseNote ->
.map { baseNote -> val boostsInCard = boostsPerEvent[baseNote] ?: emptyList()
val boostsInCard = boostsPerEvent[baseNote] ?: emptyList() val reactionsInCard = reactionsPerEvent[baseNote] ?: emptyList()
val reactionsInCard = reactionsPerEvent[baseNote] ?: emptyList() val zapsInCard = zapsPerEvent[baseNote] ?: emptyList()
val zapsInCard = zapsPerEvent[baseNote] ?: emptyList()
val singleList = val singleList =
(boostsInCard + zapsInCard.map { it.response } + reactionsInCard).groupBy { (boostsInCard + zapsInCard.map { it.response } + reactionsInCard).groupBy {
sdf.format( sdf.format(
Instant Instant
.ofEpochSecond(it.createdAt() ?: 0L) .ofEpochSecond(it.createdAt() ?: 0L)
.atZone(ZoneId.systemDefault()) .atZone(ZoneId.systemDefault())
.toLocalDateTime(), .toLocalDateTime(),
)
}
val days = singleList.keys.sortedBy { it }
days
.mapNotNull { string ->
val sortedList =
singleList
.get(string)
?.sortedWith(compareBy({ it.createdAt() }, { it.idHex }))
?.reversed()
sortedList?.chunked(30)?.map { chunk ->
MultiSetCard(
baseNote,
boostsInCard.filter { it in chunk }.toImmutableList(),
reactionsInCard.filter { it in chunk }.toImmutableList(),
zapsInCard.filter { it.response in chunk }.toImmutableList(),
) )
} }
}.flatten()
val days = singleList.keys.sortedBy { it } }
days
.mapNotNull {
val sortedList =
singleList
.get(it)
?.sortedWith(compareBy({ it.createdAt() }, { it.idHex }))
?.reversed()
sortedList?.chunked(30)?.map { chunk ->
MultiSetCard(
baseNote,
boostsInCard.filter { it in chunk }.toImmutableList(),
reactionsInCard.filter { it in chunk }.toImmutableList(),
zapsInCard.filter { it.response in chunk }.toImmutableList(),
)
}
}.flatten()
}.flatten()
val userZaps = val userZaps =
zapsPerUser zapsPerUser
@@ -290,10 +289,10 @@ class CardFeedContentState(
) )
} }
byDay.values.map { byDay.values.map { zaps ->
ZapUserSetCard( ZapUserSetCard(
user.key, user.key,
it zaps
.sortedWith(compareBy({ it.createdAt() }, { it.idHex() })) .sortedWith(compareBy({ it.createdAt() }, { it.idHex() }))
.reversed() .reversed()
.toImmutableList(), .toImmutableList(),