From 5cb6f9717811357e6462e0497be8bd4c038ee852 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Fri, 16 Aug 2024 10:48:30 -0400 Subject: [PATCH] linting cleanup --- .../amethyst/ui/actions/EditPostView.kt | 8 ++-- .../amethyst/ui/actions/NewPostView.kt | 8 ++-- .../amethyst/ui/components/RichTextViewer.kt | 10 ++--- .../amethyst/ui/feeds/FeedLoaded.kt | 2 +- .../amethyst/ui/note/MultiSetCompose.kt | 2 +- .../amethyst/ui/note/NoteCompose.kt | 39 +++++++++---------- .../ui/note/types/RenderPostApproval.kt | 2 +- .../amethyst/ui/note/types/Report.kt | 2 +- .../amethyst/ui/screen/ThreadFeedView.kt | 2 +- .../ui/screen/loggedIn/DraftListScreen.kt | 2 +- .../notifications/CardFeedContentState.kt | 1 - .../loggedIn/notifications/CardFeedView.kt | 16 ++++---- 12 files changed, 45 insertions(+), 49 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostView.kt index cb351bcf3..988cc5420 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostView.kt @@ -258,11 +258,11 @@ fun EditPostView( Row(Modifier.heightIn(max = 200.dp)) { NoteCompose( baseNote = it, - makeItShort = true, - unPackReply = false, - isQuotedNote = true, - quotesLeft = 1, modifier = MaterialTheme.colorScheme.replyModifier, + isQuotedNote = true, + unPackReply = false, + makeItShort = true, + quotesLeft = 1, accountViewModel = accountViewModel, nav = nav, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt index e7406e80e..5b6dd6f5d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt @@ -351,11 +351,11 @@ fun NewPostView( Row(Modifier.heightIn(max = 200.dp)) { NoteCompose( baseNote = it, - makeItShort = true, - unPackReply = false, - isQuotedNote = true, - quotesLeft = 1, modifier = MaterialTheme.colorScheme.replyModifier, + isQuotedNote = true, + unPackReply = false, + makeItShort = true, + quotesLeft = 1, accountViewModel = accountViewModel, nav = nav, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt index d81c0340b..40765dfcf 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt @@ -519,11 +519,11 @@ fun DisplayFullNote( ) { NoteCompose( baseNote = note, - accountViewModel = accountViewModel, modifier = MaterialTheme.colorScheme.innerPostModifier, - parentBackgroundColor = backgroundColor, - quotesLeft = quotesLeft - 1, isQuotedNote = true, + quotesLeft = quotesLeft - 1, + parentBackgroundColor = backgroundColor, + accountViewModel = accountViewModel, nav = nav, ) @@ -671,11 +671,11 @@ private fun DisplayNoteFromTag( if (canPreview && quotesLeft > 0) { NoteCompose( baseNote = baseNote, - accountViewModel = accountViewModel, modifier = MaterialTheme.colorScheme.innerPostModifier, - parentBackgroundColor = backgroundColor, isQuotedNote = true, quotesLeft = quotesLeft - 1, + parentBackgroundColor = backgroundColor, + accountViewModel = accountViewModel, nav = nav, ) } else { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/FeedLoaded.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/FeedLoaded.kt index 0242420a9..9cd1045f5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/FeedLoaded.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/FeedLoaded.kt @@ -51,8 +51,8 @@ fun FeedLoaded( Row(Modifier.fillMaxWidth().animateItemPlacement()) { NoteCompose( item, - routeForLastRead = routeForLastRead, modifier = Modifier.fillMaxWidth(), + routeForLastRead = routeForLastRead, isBoostedNote = false, isHiddenFeed = state.showHidden.value, quotesLeft = 3, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt index fa1767f91..9f944ab91 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt @@ -141,8 +141,8 @@ fun MultiSetCompose( NoteCompose( baseNote = baseNote, - routeForLastRead = null, modifier = HalfTopPadding, + routeForLastRead = null, isBoostedNote = true, isHiddenFeed = showHidden, quotesLeft = 1, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt index 142adf506..3e5573403 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt @@ -189,8 +189,8 @@ import com.vitorpamplona.quartz.events.WikiNoteEvent @Composable fun NoteCompose( baseNote: Note, - routeForLastRead: String? = null, modifier: Modifier = Modifier, + routeForLastRead: String? = null, isBoostedNote: Boolean = false, isQuotedNote: Boolean = false, unPackReply: Boolean = true, @@ -216,8 +216,8 @@ fun NoteCompose( ) { canPreview -> AcceptableNote( baseNote = baseNote, - routeForLastRead = routeForLastRead, modifier = modifier, + routeForLastRead = routeForLastRead, isBoostedNote = isBoostedNote, isQuotedNote = isQuotedNote, unPackReply = unPackReply, @@ -235,8 +235,8 @@ fun NoteCompose( @Composable fun AcceptableNote( baseNote: Note, - routeForLastRead: String? = null, modifier: Modifier = Modifier, + routeForLastRead: String? = null, isBoostedNote: Boolean = false, isQuotedNote: Boolean = false, unPackReply: Boolean = true, @@ -272,8 +272,8 @@ fun AcceptableNote( LongPressToQuickAction(baseNote = baseNote, accountViewModel = accountViewModel) { showPopup -> CheckNewAndRenderNote( baseNote = baseNote, - routeForLastRead = routeForLastRead, modifier = modifier, + routeForLastRead = routeForLastRead, isBoostedNote = isBoostedNote, isQuotedNote = isQuotedNote, unPackReply = unPackReply, @@ -315,8 +315,8 @@ fun AcceptableNote( LongPressToQuickAction(baseNote = baseNote, accountViewModel = accountViewModel) { showPopup -> CheckNewAndRenderNote( baseNote = baseNote, - routeForLastRead = routeForLastRead, modifier = modifier, + routeForLastRead = routeForLastRead, isBoostedNote = isBoostedNote, isQuotedNote = isQuotedNote, unPackReply = unPackReply, @@ -343,7 +343,7 @@ fun calculateBackgroundColor( val defaultBackgroundColor = MaterialTheme.colorScheme.background val newItemColor = MaterialTheme.colorScheme.newItemBackgroundColor return remember(createdAt) { - mutableStateOf( + mutableStateOf( if (routeForLastRead != null) { val isNew = accountViewModel.loadAndMarkAsRead(routeForLastRead, createdAt) @@ -366,8 +366,8 @@ fun calculateBackgroundColor( @Composable private fun CheckNewAndRenderNote( baseNote: Note, - routeForLastRead: String? = null, modifier: Modifier = Modifier, + routeForLastRead: String? = null, isBoostedNote: Boolean = false, isQuotedNote: Boolean = false, unPackReply: Boolean = true, @@ -504,7 +504,7 @@ fun InnerNoteWithReactions( if (isNotRepost) { if (makeItShort) { - if (isBoostedNote) { + if (!isBoostedNote) { } else { Spacer(modifier = DoubleVertSpacer) } @@ -594,8 +594,7 @@ private fun RenderNoteRow( accountViewModel: AccountViewModel, nav: (String) -> Unit, ) { - val noteEvent = baseNote.event - when (noteEvent) { + when (val noteEvent = baseNote.event) { is AppDefinitionEvent -> RenderAppDefinition(baseNote, accountViewModel, nav) is AudioTrackEvent -> RenderAudioTrack(baseNote, false, accountViewModel, nav) is AudioHeaderEvent -> RenderAudioHeader(baseNote, false, accountViewModel, nav) @@ -862,11 +861,11 @@ fun ReplyNoteComposition( ) { NoteCompose( baseNote = replyingDirectlyTo, - isQuotedNote = true, - quotesLeft = 0, modifier = MaterialTheme.colorScheme.replyModifier, + isQuotedNote = true, unPackReply = false, makeItShort = true, + quotesLeft = 0, parentBackgroundColor = backgroundColor, accountViewModel = accountViewModel, nav = nav, @@ -921,12 +920,12 @@ fun DisplayOtsIfInOriginal( editState: State>, accountViewModel: AccountViewModel, ) { - val editState = (editState.value as? GenericLoadable.Loaded)?.loaded?.modificationToShow?.value + val editNote = (editState.value as? GenericLoadable.Loaded)?.loaded?.modificationToShow?.value - if (editState == null) { + if (editNote == null) { DisplayOts(note = note, accountViewModel = accountViewModel) } else { - DisplayOts(note = editState, accountViewModel = accountViewModel) + DisplayOts(note = editNote, accountViewModel = accountViewModel) } } @@ -1018,7 +1017,7 @@ fun observeEdits( accountViewModel: AccountViewModel, ): State> { if (baseNote.event !is TextNoteEvent) { - return remember { mutableStateOf(GenericLoadable.Empty()) } + return remember { mutableStateOf(GenericLoadable.Empty()) } } val editState = @@ -1027,14 +1026,14 @@ fun observeEdits( mutableStateOf( if (cached != null) { if (cached.isEmpty()) { - GenericLoadable.Empty() + GenericLoadable.Empty() } else { val state = EditState() state.updateModifications(cached) - GenericLoadable.Loaded(state) + GenericLoadable.Loaded(state) } } else { - GenericLoadable.Loading() + GenericLoadable.Loading() }, ) } @@ -1046,7 +1045,7 @@ fun observeEdits( accountViewModel.findModificationEventsForNote(it) { newModifications -> if (newModifications.isEmpty()) { if (editState.value !is GenericLoadable.Empty) { - editState.value = GenericLoadable.Empty() + editState.value = GenericLoadable.Empty() } } else { if (editState.value is GenericLoadable.Loaded) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/RenderPostApproval.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/RenderPostApproval.kt index 79bf456d7..576267940 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/RenderPostApproval.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/RenderPostApproval.kt @@ -83,9 +83,9 @@ fun RenderPostApproval( NoteCompose( it, modifier = MaterialTheme.colorScheme.replyModifier, + isQuotedNote = true, unPackReply = false, makeItShort = true, - isQuotedNote = true, quotesLeft = quotesLeft - 1, parentBackgroundColor = backgroundColor, accountViewModel = accountViewModel, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Report.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Report.kt index 9ff23be26..342b6d5ff 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Report.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Report.kt @@ -90,8 +90,8 @@ fun RenderReport( note.replyTo?.lastOrNull()?.let { NoteCompose( baseNote = it, - isQuotedNote = true, modifier = MaterialTheme.colorScheme.replyModifier, + isQuotedNote = true, unPackReply = false, makeItShort = true, quotesLeft = quotesLeft - 1, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt index e49095d4d..824230d5e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt @@ -285,10 +285,10 @@ fun RenderThreadFeed( MaterialTheme.colorScheme.placeholderText }, ), - parentBackgroundColor = background, isBoostedNote = false, unPackReply = false, quotesLeft = 3, + parentBackgroundColor = background, accountViewModel = accountViewModel, nav = nav, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DraftListScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DraftListScreen.kt index 2612f0f6f..dfa7f05a5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DraftListScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DraftListScreen.kt @@ -193,8 +193,8 @@ private fun DraftFeedLoaded( ) { NoteCompose( item, - routeForLastRead = routeForLastRead, modifier = MaterialTheme.colorScheme.maxWidthWithBackground, + routeForLastRead = routeForLastRead, isBoostedNote = false, isHiddenFeed = state.showHidden.value, quotesLeft = 3, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt index 917d53319..3490ac696 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt @@ -24,7 +24,6 @@ import android.util.Log import androidx.compose.runtime.Immutable import androidx.compose.runtime.Stable import androidx.compose.runtime.mutableStateOf -import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.model.Note diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedView.kt index 6bce54e3f..46198d315 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedView.kt @@ -205,11 +205,11 @@ private fun RenderCardItem( is NoteCard -> NoteCardCompose( item, - isBoostedNote = false, - accountViewModel = accountViewModel, - showHidden = showHidden, - nav = nav, routeForLastRead = routeForLastRead, + isBoostedNote = false, + showHidden = showHidden, + accountViewModel = accountViewModel, + nav = nav, ) is ZapUserSetCard -> ZapUserSetCompose( @@ -248,8 +248,8 @@ private fun RenderCardItem( @Composable fun NoteCardCompose( baseNote: NoteCard, + modifier: Modifier = Modifier, routeForLastRead: String? = null, - modifier: Modifier = remember { Modifier }, isBoostedNote: Boolean = false, isQuotedNote: Boolean = false, unPackReply: Boolean = true, @@ -259,12 +259,10 @@ fun NoteCardCompose( accountViewModel: AccountViewModel, nav: (String) -> Unit, ) { - val note = remember(baseNote) { baseNote.note } - NoteCompose( - baseNote = note, - routeForLastRead = routeForLastRead, + baseNote = baseNote.note, modifier = modifier, + routeForLastRead = routeForLastRead, isBoostedNote = isBoostedNote, isQuotedNote = isQuotedNote, unPackReply = unPackReply,