mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-09-20 00:35:47 +01:00
Allow event filtering.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user