From b654f93957dbb9e4844bf9b56b4cff0b94e04a48 Mon Sep 17 00:00:00 2001 From: Alashov Berkeli Date: Thu, 23 Dec 2021 20:50:55 -0600 Subject: [PATCH] Fix SnackbarManager flow builder usage --- .../main/java/tm/alashow/base/ui/SnackbarManager.kt | 10 +++++----- .../datmusic/ui/library/playlists/edit/EditPlaylist.kt | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/base-android/src/main/java/tm/alashow/base/ui/SnackbarManager.kt b/modules/base-android/src/main/java/tm/alashow/base/ui/SnackbarManager.kt index 573ada81..260099f7 100644 --- a/modules/base-android/src/main/java/tm/alashow/base/ui/SnackbarManager.kt +++ b/modules/base-android/src/main/java/tm/alashow/base/ui/SnackbarManager.kt @@ -9,10 +9,10 @@ import javax.inject.Singleton import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.channelFlow import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.firstOrNull -import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.merge import kotlinx.coroutines.flow.receiveAsFlow import org.threeten.bp.Duration @@ -39,11 +39,11 @@ class SnackbarManager @Inject constructor( * or [removeCurrentError] is called (if before that) `null` will be emitted to remove * the current error. */ - val errors: Flow = flow { - emit(null) + val errors: Flow = channelFlow { + send(null) pendingErrors.receiveAsFlow().collectLatest { - emit(it) + send(it) // Wait for either a maxDuration timeout, or a remove signal (whichever comes first) merge( @@ -52,7 +52,7 @@ class SnackbarManager @Inject constructor( ).firstOrNull() // Remove the error - emit(null) + send(null) } } diff --git a/modules/ui-library/src/main/java/tm/alashow/datmusic/ui/library/playlists/edit/EditPlaylist.kt b/modules/ui-library/src/main/java/tm/alashow/datmusic/ui/library/playlists/edit/EditPlaylist.kt index e4b76e72..92048158 100644 --- a/modules/ui-library/src/main/java/tm/alashow/datmusic/ui/library/playlists/edit/EditPlaylist.kt +++ b/modules/ui-library/src/main/java/tm/alashow/datmusic/ui/library/playlists/edit/EditPlaylist.kt @@ -84,8 +84,6 @@ import tm.alashow.ui.simpleClickable import tm.alashow.ui.theme.AppTheme import tm.alashow.ui.theme.Orange -private const val DRAGGABLE_ITEM_PREFIX = "draggable_" - @Composable fun EditPlaylist( viewModel: EditPlaylistViewModel = hiltViewModel(),