Fixes mark as seen when drafts are the last post in messages
This commit is contained in:
+5
-13
@@ -62,6 +62,7 @@ import com.vitorpamplona.amethyst.ui.components.UrlPreviewState
|
|||||||
import com.vitorpamplona.amethyst.ui.components.toasts.ToastManager
|
import com.vitorpamplona.amethyst.ui.components.toasts.ToastManager
|
||||||
import com.vitorpamplona.amethyst.ui.feeds.FeedState
|
import com.vitorpamplona.amethyst.ui.feeds.FeedState
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.Route
|
import com.vitorpamplona.amethyst.ui.navigation.Route
|
||||||
|
import com.vitorpamplona.amethyst.ui.navigation.routeFor
|
||||||
import com.vitorpamplona.amethyst.ui.note.ZapAmountCommentNotification
|
import com.vitorpamplona.amethyst.ui.note.ZapAmountCommentNotification
|
||||||
import com.vitorpamplona.amethyst.ui.note.ZapraiserStatus
|
import com.vitorpamplona.amethyst.ui.note.ZapraiserStatus
|
||||||
import com.vitorpamplona.amethyst.ui.note.showAmount
|
import com.vitorpamplona.amethyst.ui.note.showAmount
|
||||||
@@ -1221,24 +1222,15 @@ class AccountViewModel(
|
|||||||
|
|
||||||
fun markAllAsRead(
|
fun markAllAsRead(
|
||||||
notes: ImmutableList<Note>,
|
notes: ImmutableList<Note>,
|
||||||
|
accountViewModel: AccountViewModel,
|
||||||
onDone: () -> Unit,
|
onDone: () -> Unit,
|
||||||
) {
|
) {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
for (note in notes) {
|
for (note in notes) {
|
||||||
note.event?.let { noteEvent ->
|
note.event?.createdAt?.let { date ->
|
||||||
val channelHex = note.channelHex()
|
val route = routeFor(note, accountViewModel.account.userProfile())
|
||||||
val route =
|
|
||||||
if (channelHex != null) {
|
|
||||||
"Channel/$channelHex"
|
|
||||||
} else if (note.event is ChatroomKeyable) {
|
|
||||||
val withKey = (note.event as ChatroomKeyable).chatroomKey(userProfile().pubkeyHex)
|
|
||||||
"Room/${withKey.hashCode()}"
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
route?.let {
|
route?.let {
|
||||||
account.markAsRead(route, noteEvent.createdAt)
|
account.markAsRead(route, date)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -102,7 +102,7 @@ private fun FeedLoaded(
|
|||||||
|
|
||||||
LaunchedEffect(key1 = markAsRead.value) {
|
LaunchedEffect(key1 = markAsRead.value) {
|
||||||
if (markAsRead.value) {
|
if (markAsRead.value) {
|
||||||
accountViewModel.markAllAsRead(items.list) { markAsRead.value = false }
|
accountViewModel.markAllAsRead(items.list, accountViewModel) { markAsRead.value = false }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user