Prevent importing duplicate saved searches

This commit is contained in:
M66B 2022-12-31 10:46:25 +01:00
parent df05998a60
commit 20858227fc
2 changed files with 14 additions and 3 deletions

View File

@ -1118,8 +1118,18 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
for (int s = 0; s < jsearches.length(); s++) {
JSONObject jsearch = (JSONObject) jsearches.get(s);
EntitySearch search = EntitySearch.fromJSON(jsearch);
search.id = null;
db.search().insertSearch(search);
boolean found = false;
for (EntitySearch other : db.search().getSearches())
if (other.equals(search)) {
found = true;
break;
}
if (!found) {
search.id = null;
db.search().insertSearch(search);
}
}
}

View File

@ -82,7 +82,8 @@ public class EntitySearch {
public boolean equals(Object obj) {
if (obj instanceof EntitySearch) {
EntitySearch other = (EntitySearch) obj;
return (this.id.equals(other.id) &&
return (Objects.equals(this.account_uuid, other.account_uuid) &&
Objects.equals(this.folder_name, other.folder_name) &&
this.name.equals(other.name) &&
Objects.equals(this.order, other.order) &&
Objects.equals(this.color, other.color) &&