Skip to content

Commit

Permalink
make sure that we don't break import state checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcz committed Jul 5, 2024
1 parent e2f6239 commit 2a92ed0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/tomczarniecki/jpasskeep/Entry.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ public void setNotes(String notes) {
this.notes = notes;
}

public void updateFrom(Entry other) {
this.setDescription(other.getDescription());
this.setCategory(other.getCategory());
this.setUsername(other.getUsername());
this.setPassword(other.getPassword());
this.setNotes(other.getNotes());
}

public int compareTo(Entry other) {
return this.getDescription().compareToIgnoreCase(other.getDescription());
}
Expand Down
15 changes: 6 additions & 9 deletions src/main/java/com/tomczarniecki/jpasskeep/MainListModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,8 @@ public void setEntry(Entry entry) {
entries.put(entry.getKey(), entry);
} else if (state.equals(ImportState.Changed)) {
for (Entry current : entries.values()) {
if (current.getDescription().equals(entry.getDescription())) {
current.setCategory(entry.getCategory());
current.setUsername(entry.getUsername());
current.setPassword(entry.getPassword());
current.setNotes(entry.getNotes());
if (current.compareTo(entry) == 0) {
current.updateFrom(entry);
}
}
}
Expand Down Expand Up @@ -143,10 +140,10 @@ private boolean show(Entry entry) {
};
}

public ImportState stateForEntry(Entry otherEntry) {
for (Entry entry : entries.values()) {
if (entry.getDescription().equals(otherEntry.getDescription())) {
if (entry.equals(otherEntry)) {
public ImportState stateForEntry(Entry entry) {
for (Entry current : entries.values()) {
if (current.compareTo(entry) == 0) {
if (current.equals(entry)) {
return ImportState.Equal;
}
return ImportState.Changed;
Expand Down

0 comments on commit 2a92ed0

Please sign in to comment.