From 9a1d3efe75fe16cc09c21b5b635234910773f94f Mon Sep 17 00:00:00 2001 From: Kaartic Sivaraam Date: Sat, 19 Mar 2022 16:58:53 +0530 Subject: [PATCH] Stop filtering out all categories that have a year in it As a fix for #750, a validation was added to filter out categories that were of form "... taken on ... 1990" or "... needing ... 2005". The conditional added for the fix was a bit loose than it should be as a result of which it filtered out all categories that had a year in its name. This is incorrect. Fix this by tigheting the conditional so that only categories that have a year, is not the present or previous year AND (contains "taken on" OR "needing") is filtered out. While doing so, turn an implicit precedence into an explicit one. --- .../java/fr/free/nrw/commons/category/CategoriesModel.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/category/CategoriesModel.kt b/app/src/main/java/fr/free/nrw/commons/category/CategoriesModel.kt index 298cfd12e..128563416 100644 --- a/app/src/main/java/fr/free/nrw/commons/category/CategoriesModel.kt +++ b/app/src/main/java/fr/free/nrw/commons/category/CategoriesModel.kt @@ -42,10 +42,10 @@ class CategoriesModel @Inject constructor( return item.matches(".*(19|20)\\d{2}.*".toRegex()) && !item.contains(yearInString) && !item.contains(prevYearInString) - || item.matches("(.*)needing(.*)".toRegex()) - || item.matches("(.*)taken on(.*)".toRegex()) - || item.matches(".*0s.*".toRegex()) - && !item.matches(".*(200|201)0s.*".toRegex()) + && (item.matches("(.*)needing(.*)".toRegex()) + || item.matches("(.*)taken on(.*)".toRegex())) + || (item.matches(".*0s.*".toRegex()) + && !item.matches(".*(200|201)0s.*".toRegex())) } /**