Skip to content

Commit

Permalink
fix #4: 'task undo' errors out when undo removes task
Browse files Browse the repository at this point in the history
  • Loading branch information
thehunmonkgroup committed Jun 5, 2022
1 parent 989d964 commit 95eaebf
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions manage_notes_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def remove_notes_annotation(data):
return data

def manage_notes_annotation(data_before, data_after):
# Deletion case, just return the task as is.
if data_before and not data_after:
return data_before
notes_exist = check_notes(data_after)
notes_annotation_exists = check_notes_annotation(data_after)
if check_notes_updated(data_before, data_after):
Expand Down Expand Up @@ -111,13 +114,18 @@ def exit_error():
first_line, second_line = read_stdin()
task_before, task_after = load_task_data(first_line, second_line)
if task_before:
log("Modifying current task")
log("Task before modification")
if task_after:
log("Modifying current task")
log("Task before modification")
else:
log("Deleting current task")
log("Task before deletion")
log(json.dumps(task_before, sort_keys=True, indent=2))
else:
log("Adding new task")
log("Task after modification")
log(json.dumps(task_after, sort_keys=True, indent=2))
if task_after:
log("Task after modification")
log(json.dumps(task_after, sort_keys=True, indent=2))
modified_task = manage_notes_annotation(task_before, task_after)
log("Task after hook adjustments")
log(json.dumps(modified_task, sort_keys=True, indent=2))
Expand Down

0 comments on commit 95eaebf

Please sign in to comment.