Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY2223S1#94 from peppapighs/93-fix-add-…
Browse files Browse the repository at this point in the history
…task-relative-index

Fix: use relative person index when adding task
  • Loading branch information
ShenyiCui authored Oct 22, 2022
2 parents ed277f5 + 21c809b commit 6d00267
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/java/swift/logic/commands/AddTaskCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public CommandResult execute(Model model) throws CommandException {
}
model.addTask(toAdd);
for (Index index : contactIndices) {
model.addBridge(model.getAddressBook().getPersonList().get(index.getZeroBased()), toAdd);
model.addBridge(model.getFilteredPersonList().get(index.getZeroBased()), toAdd);
}

return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd));
Expand Down
9 changes: 3 additions & 6 deletions src/test/java/swift/logic/commands/AddTaskCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

import org.junit.jupiter.api.Test;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import swift.commons.core.GuiSettings;
import swift.commons.core.index.Index;
import swift.logic.commands.exceptions.CommandException;
import swift.model.AddressBook;
import swift.model.Model;
import swift.model.ReadOnlyAddressBook;
import swift.model.ReadOnlyUserPrefs;
Expand Down Expand Up @@ -250,11 +250,8 @@ public void addBridge(Person person, Task task) {
}

@Override
public ReadOnlyAddressBook getAddressBook() {
AddressBook ab = new AddressBook();
ab.addPerson(new PersonBuilder().build());
return ab;
public ObservableList<Person> getFilteredPersonList() {
return FXCollections.observableArrayList(new PersonBuilder().build());
}
}

}

0 comments on commit 6d00267

Please sign in to comment.