Fixes notification autoupdating

This commit is contained in:
Vitor Pamplona
2023-01-25 13:29:44 -03:00
parent 4c15420b05
commit 542bd485d0
6 changed files with 11 additions and 8 deletions

View File

@@ -40,7 +40,7 @@ fun isValidURL(url: String?): Boolean {
} }
@Composable @Composable
fun RichTextViewer(content: String, tags: List<List<String>>?, note: Note, accountViewModel: AccountViewModel, navController: NavController) { fun RichTextViewer(content: String, tags: List<List<String>>?, navController: NavController) {
Column(modifier = Modifier.padding(top = 5.dp)) { Column(modifier = Modifier.padding(top = 5.dp)) {
// FlowRow doesn't work well with paragraphs. So we need to split them // FlowRow doesn't work well with paragraphs. So we need to split them
content.split('\n').forEach { paragraph -> content.split('\n').forEach { paragraph ->

View File

@@ -177,16 +177,12 @@ fun ChatroomMessageCompose(baseNote: Note, innerQuote: Boolean = false, accountV
RichTextViewer( RichTextViewer(
eventContent, eventContent,
note.event?.tags, note.event?.tags,
note,
accountViewModel,
navController navController
) )
else else
RichTextViewer( RichTextViewer(
"Could Not decrypt the message", "Could Not decrypt the message",
note.event?.tags, note.event?.tags,
note,
accountViewModel,
navController navController
) )

View File

@@ -183,7 +183,7 @@ fun NoteCompose(baseNote: Note, modifier: Modifier = Modifier, isInnerNote: Bool
} else { } else {
val eventContent = note.event?.content val eventContent = note.event?.content
if (eventContent != null) if (eventContent != null)
RichTextViewer(eventContent, note.event?.tags, note, accountViewModel, navController) RichTextViewer(eventContent, note.event?.tags, navController)
if (note.event !is ChannelMessageEvent) { if (note.event !is ChannelMessageEvent) {
ReactionsRowState(note, accountViewModel) ReactionsRowState(note, accountViewModel)

View File

@@ -4,12 +4,15 @@ import com.vitorpamplona.amethyst.model.Note
abstract class Card() { abstract class Card() {
abstract fun createdAt(): Long abstract fun createdAt(): Long
abstract fun id(): String
} }
class NoteCard(val note: Note): Card() { class NoteCard(val note: Note): Card() {
override fun createdAt(): Long { override fun createdAt(): Long {
return note.event?.createdAt ?: 0 return note.event?.createdAt ?: 0
} }
override fun id() = note.idHex
} }
class LikeSetCard(val note: Note, val likeEvents: List<Note>): Card() { class LikeSetCard(val note: Note, val likeEvents: List<Note>): Card() {
@@ -18,6 +21,8 @@ class LikeSetCard(val note: Note, val likeEvents: List<Note>): Card() {
override fun createdAt(): Long { override fun createdAt(): Long {
return createdAt return createdAt
} }
override fun id() = note.idHex + createdAt
} }
class BoostSetCard(val note: Note, val boostEvents: List<Note>): Card() { class BoostSetCard(val note: Note, val boostEvents: List<Note>): Card() {
@@ -26,6 +31,8 @@ class BoostSetCard(val note: Note, val boostEvents: List<Note>): Card() {
override fun createdAt(): Long { override fun createdAt(): Long {
return createdAt return createdAt
} }
override fun id() = note.idHex + createdAt
} }
sealed class CardFeedState { sealed class CardFeedState {

View File

@@ -66,7 +66,7 @@ fun CardFeedView(viewModel: CardFeedViewModel, accountViewModel: AccountViewMode
), ),
state = listState state = listState
) { ) {
itemsIndexed(state.feed) { index, item -> itemsIndexed(state.feed, key = { _, item -> item.id() }) { index, item ->
when (item) { when (item) {
is NoteCard -> NoteCompose(item.note, isInnerNote = false, accountViewModel = accountViewModel, navController = navController) is NoteCard -> NoteCompose(item.note, isInnerNote = false, accountViewModel = accountViewModel, navController = navController)
is LikeSetCard -> LikeSetCompose(item, isInnerNote = false, accountViewModel = accountViewModel, navController = navController) is LikeSetCard -> LikeSetCompose(item, isInnerNote = false, accountViewModel = accountViewModel, navController = navController)

View File

@@ -203,7 +203,7 @@ fun NoteMaster(baseNote: Note, accountViewModel: AccountViewModel, navController
Column() { Column() {
val eventContent = note.event?.content val eventContent = note.event?.content
if (eventContent != null) if (eventContent != null)
RichTextViewer(eventContent, note.event?.tags, note, accountViewModel, navController) RichTextViewer(eventContent, note.event?.tags, navController)
ReactionsRowState(note, accountViewModel) ReactionsRowState(note, accountViewModel)