Skip to content

Commit

Permalink
[fix]: clearing logs with logging paused
Browse files Browse the repository at this point in the history
  • Loading branch information
F0x1d committed Jul 13, 2024
1 parent 7ef7939 commit aa4be24
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
}
}
}

dependenciesInfo {
// https://gitlab.com/IzzyOnDroid/repo/-/issues/569#note_1997934495
includeInApk = false
includeInBundle = false
}
}

dependencies { coreDependencies() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,29 @@ class LogsViewModel @Inject constructor(
if (!viewingFile) paused else flowOf(false)
) { logs, filters, query, paused ->
LogsData(logs, filters, query, paused)
}.scan(null as LogsData?) { accumulator, data ->
}.scan(LogsData()) { accumulator, data ->
when {
!data.paused -> data

data.query != accumulator?.query || data.filters != accumulator?.filters -> data.copy(
logs = accumulator?.logs ?: emptyList()
data.query != accumulator.query
|| data.filters != accumulator.filters
|| data.logs.isNotEmpty() // Logs were cleared
-> data.copy(
logs = accumulator.logs,
)

else -> data.copy(logs = accumulator.logs, passing = false)
}
}.filter {
it?.passing == true
}.mapNotNull {
it?.run {
logs.filterAndSearch(filters, query)
else -> data.copy(
logs = accumulator.logs,
passing = false,
)
}
}.filter { data ->
data.passing
}.mapNotNull { data ->
data.logs.filterAndSearch(
filters = data.filters,
query = data.query,
)
}.flowOn(
ioDispatcher,
).stateIn(
Expand Down Expand Up @@ -155,10 +162,10 @@ class LogsViewModel @Inject constructor(
}

private data class LogsData(
val logs: List<LogLine>,
val filters: List<UserFilter>,
val query: String?,
val paused: Boolean,
val logs: List<LogLine> = emptyList(),
val filters: List<UserFilter> = emptyList(),
val query: String? = null,
val paused: Boolean = false,
val passing: Boolean = true,
)
}

0 comments on commit aa4be24

Please sign in to comment.