[mob][photos] Make implementation of abstract fn isSameFilter() more accurate when the fn is used to compare two same sub-HierarchicalSearchFilter types

This commit is contained in:
ashilkn 2024-10-10 17:36:21 +05:30
parent 6c5b0a6578
commit 66a13392a9
5 changed files with 35 additions and 0 deletions

View File

@ -43,6 +43,12 @@ class AlbumFilter extends HierarchicalSearchFilter {
@override
bool isSameFilter(HierarchicalSearchFilter other) {
if (other is AlbumFilter) {
return other.collectionID == collectionID;
}
// (other is AlbumFilter) can be false and this.resultType() can be same as
// other.resultType() if other is a TopLevelGenericFilter of resultType
// ResultType.collection
return resultType() == other.resultType() && other.name() == name();
}

View File

@ -38,6 +38,12 @@ class ContactsFilter extends HierarchicalSearchFilter {
@override
bool isSameFilter(HierarchicalSearchFilter other) {
if (other is ContactsFilter) {
return other.user.id == user.id;
}
// (other is ContactsFilter) can be false and this.resultType() can be same as
// other.resultType() if other is a TopLevelGenericFilter of resultType
// ResultType.shared
return resultType() == other.resultType() && other.name() == name();
}

View File

@ -49,6 +49,12 @@ class FaceFilter extends HierarchicalSearchFilter {
@override
bool isSameFilter(HierarchicalSearchFilter other) {
if (other is FaceFilter) {
return other.id == id;
}
// (other is FaceFilter) can be false and this.resultType() can be same as
// other.resultType() if other is a TopLevelGenericFilter of resultType
// ResultType.faces
return resultType() == other.resultType() && other.name() == name();
}

View File

@ -57,6 +57,12 @@ class FileTypeFilter extends HierarchicalSearchFilter {
@override
bool isSameFilter(HierarchicalSearchFilter other) {
if (other is FileTypeFilter) {
return other.fileType == fileType;
}
// (other is FileTypeFilter) can be false and this.resultType() can be same as
// other.resultType() if other is a TopLevelGenericFilter of resultType
// ResultType.fileType
return resultType() == other.resultType() && other.name() == name();
}

View File

@ -41,6 +41,17 @@ class LocationFilter extends HierarchicalSearchFilter {
@override
bool isSameFilter(HierarchicalSearchFilter other) {
if (other is LocationFilter) {
return other.locationTag.radius.toString() +
other.locationTag.centerPoint.toString() +
other.locationTag.name ==
locationTag.radius.toString() +
locationTag.centerPoint.toString() +
locationTag.name;
}
// (other is LocationFilter) can be false and this.resultType() can be same as
// other.resultType() if other is a TopLevelGenericFilter of resultType
// ResultType.location
return resultType() == other.resultType() && other.name() == name();
}