Skip to content

Commit

Permalink
Avoids recomposition of the entire line when changing status.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorpamplona committed Jul 22, 2024
1 parent ca00c87 commit 231ca44
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -991,11 +991,7 @@ fun FirstUserInfoRow(
BoostedMark()
}

if (editState.value is GenericLoadable.Loaded) {
(editState.value as? GenericLoadable.Loaded<EditState>)?.loaded?.let {
DisplayEditStatus(it)
}
}
CheckAndDisplayEditStatus(editState)

if (baseNote.isDraft()) {
DisplayDraft()
Expand All @@ -1007,6 +1003,15 @@ fun FirstUserInfoRow(
}
}

@Composable
fun CheckAndDisplayEditStatus(editState: State<GenericLoadable<EditState>>) {
if (editState.value is GenericLoadable.Loaded) {
(editState.value as? GenericLoadable.Loaded<EditState>)?.loaded?.let {
DisplayEditStatus(it)
}
}
}

@Composable
fun observeEdits(
baseNote: Note,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import com.vitorpamplona.amethyst.ui.components.ObserveDisplayNip05Status
import com.vitorpamplona.amethyst.ui.components.mockAccountViewModel
import com.vitorpamplona.amethyst.ui.navigation.routeFor
import com.vitorpamplona.amethyst.ui.navigation.routeToMessage
import com.vitorpamplona.amethyst.ui.note.CheckAndDisplayEditStatus
import com.vitorpamplona.amethyst.ui.note.CheckHiddenFeedWatchBlockAndReport
import com.vitorpamplona.amethyst.ui.note.DisplayDraft
import com.vitorpamplona.amethyst.ui.note.DisplayOtsIfInOriginal
Expand All @@ -95,7 +96,6 @@ import com.vitorpamplona.amethyst.ui.note.RenderRepost
import com.vitorpamplona.amethyst.ui.note.WatchNoteEvent
import com.vitorpamplona.amethyst.ui.note.calculateBackgroundColor
import com.vitorpamplona.amethyst.ui.note.elements.DefaultImageHeader
import com.vitorpamplona.amethyst.ui.note.elements.DisplayEditStatus
import com.vitorpamplona.amethyst.ui.note.elements.DisplayFollowingCommunityInPost
import com.vitorpamplona.amethyst.ui.note.elements.DisplayFollowingHashtagsInPost
import com.vitorpamplona.amethyst.ui.note.elements.DisplayLocation
Expand Down Expand Up @@ -421,11 +421,7 @@ private fun FullBleedNoteCompose(
DisplayFollowingHashtagsInPost(baseNote, accountViewModel, nav)
}

if (editState.value is GenericLoadable.Loaded) {
(editState.value as? GenericLoadable.Loaded<EditState>)?.loaded?.let {
DisplayEditStatus(it)
}
}
CheckAndDisplayEditStatus(editState)

TimeAgo(note = baseNote)

Expand Down

0 comments on commit 231ca44

Please sign in to comment.