Fix broken timeline when there are only expired filters (#2689)
* Fix broken timeline when there are only expired filters The issue happened when the only applicable filters are expired. There was a check to not produce an empty regex when there are no filters but it was done before removing expired filters so we would produce an empty regex that would match (and remove) everything and the timeline would get stuck. * Make a mini-optimization for FilterModel
This commit is contained in:
parent
4665637086
commit
257f3a5c1c
1 changed files with 6 additions and 4 deletions
|
@ -38,7 +38,8 @@ class FilterModel @Inject constructor() {
|
|||
(spoilerText.isNotEmpty() && matcher.reset(spoilerText).find()) ||
|
||||
(
|
||||
attachmentsDescriptions.isNotEmpty() &&
|
||||
matcher.reset(attachmentsDescriptions.joinToString("\n")).find()
|
||||
matcher.reset(attachmentsDescriptions.joinToString("\n"))
|
||||
.find()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -54,9 +55,10 @@ class FilterModel @Inject constructor() {
|
|||
}
|
||||
|
||||
private fun makeFilter(filters: List<Filter>): Pattern? {
|
||||
if (filters.isEmpty()) return null
|
||||
val tokens = filters
|
||||
.filter { it.expiresAt?.before(Date()) != true }
|
||||
val now = Date()
|
||||
val nonExpiredFilters = filters.filter { it.expiresAt?.before(now) != true }
|
||||
if (nonExpiredFilters.isEmpty()) return null
|
||||
val tokens = nonExpiredFilters
|
||||
.map { filterToRegexToken(it) }
|
||||
|
||||
return Pattern.compile(TextUtils.join("|", tokens), Pattern.CASE_INSENSITIVE)
|
||||
|
|
Loading…
Reference in a new issue