mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-2966 Chats | Fix | Misc. fixes (#2452)
This commit is contained in:
parent
e685e4ea53
commit
202cea41f6
7 changed files with 20 additions and 6 deletions
|
@ -5,6 +5,7 @@ import com.anytypeio.anytype.domain.chats.ChatPreviewContainer
|
|||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.debounce
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.emitAll
|
||||
import kotlinx.coroutines.flow.flow
|
||||
|
@ -14,7 +15,7 @@ class SpaceChatWidgetContainer @Inject constructor(
|
|||
private val widget: Widget,
|
||||
private val container: ChatPreviewContainer
|
||||
) : WidgetContainer {
|
||||
override val view: Flow<WidgetView> = flow {
|
||||
override val view: Flow<WidgetView.SpaceChat> = flow {
|
||||
emitAll(
|
||||
container
|
||||
.observePreview(space = SpaceId(widget.config.space))
|
||||
|
@ -22,6 +23,7 @@ class SpaceChatWidgetContainer @Inject constructor(
|
|||
(preview?.state?.unreadMessages?.counter ?: 0) to (preview?.state?.unreadMentions?.counter ?: 0)
|
||||
}
|
||||
.distinctUntilChanged()
|
||||
.debounce(DEBOUNCE_DURATION)
|
||||
.map { (unreadMessageCount, unreadMentionCount) ->
|
||||
WidgetView.SpaceChat(
|
||||
id = widget.id,
|
||||
|
@ -39,4 +41,8 @@ class SpaceChatWidgetContainer @Inject constructor(
|
|||
)
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val DEBOUNCE_DURATION = 500L
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue