Allow event filtering.

This commit is contained in:
Alex Hart
2026-09-02 16:11:29 -03:00
parent 24bac8c8ed
commit 5b3e77db31
2 changed files with 6 additions and 3 deletions
@@ -50,7 +50,7 @@ import kotlin.time.Duration.Companion.milliseconds
class MainNavigationViewModel(
savedStateHandle: SavedStateHandle,
initialListLocation: MainListRoute = MainListRoute.Chats
) : EventDrivenViewModel<MainNavigationEvents>(TAG), MainNavigationEventSink {
) : EventDrivenViewModel<MainNavigationEvents>(TAG, shouldLogEvents = false), MainNavigationEventSink {
companion object {
private val TAG = Log.tag(MainNavigationViewModel::class)
@@ -17,7 +17,8 @@ import org.signal.core.util.logging.Log
* to avoid gotcha's around threading and race conditions.
*/
abstract class EventDrivenViewModel<E : Any>(
private val tag: String
private val tag: String,
private val shouldLogEvents: Boolean = true
) : ViewModel() {
private val eventChannel = Channel<E>(Channel.UNLIMITED)
@@ -25,7 +26,9 @@ abstract class EventDrivenViewModel<E : Any>(
init {
viewModelScope.launch {
for (event in eventChannel) {
Log.d(tag, "[Event] $event")
if (shouldLogEvents) {
Log.d(tag, "[Event] $event")
}
processEvent(event)
}
}