opt: danmaku filter (#486)

This commit is contained in:
My-Responsitories
2025-03-23 12:07:57 +08:00
committed by GitHub
parent 066f3d4132
commit 99b14d0f0e
9 changed files with 141 additions and 189 deletions

View File

@@ -69,21 +69,13 @@ class PlDanmakuController {
queryDanmaku(segmentIndex);
}
if (plPlayerController.danmakuWeight == 0 &&
plPlayerController.filterCount == 0) {
plPlayerController.filters.count == 0) {
return dmSegMap[progress ~/ 100];
} else {
return dmSegMap[progress ~/ 100]
?.where(
(element) => element.weight >= plPlayerController.danmakuWeight)
.where(filterDanmaku)
.toList();
?..retainWhere((element) =>
element.weight >= plPlayerController.danmakuWeight &&
plPlayerController.filters.retain(element));
}
}
bool filterDanmaku(DanmakuElem elem) {
return !(plPlayerController.dmUid.contains(elem.midHash) ||
plPlayerController.dmFilterString
.any((i) => elem.content.contains(i)) ||
plPlayerController.dmRegExp.any((i) => i.hasMatch(elem.content)));
}
}