Skip to content

Commit

Permalink
Fix bugs, optimize deletion of compelted tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Nixellion committed Jan 17, 2023
1 parent e429673 commit d1b84cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,16 +453,18 @@ def notifier_task_hash(task, label=""):
debug(output_text)

# Cleanup completed tasks
delete_ids = []
for item in todoist_api.get_completed_tasks():
if config['remove_completed_tasks']:
remember_task(item['content'])
if config['clean_up_completed_tasks']:
print(f"Deleting task '{item['content']}'")
todoist_api.delete_item(item)
delete_ids.append(item['id'])
else:
print(f"Config tells me to skip clean_up_completed_tasks: {item['content']}")
elif not config['remove_completed_tasks']:
print(f"Config tells me to skip remove_completed_tasks: {item['content']}")

if len(delete_ids) > 0:
todoist_api.delete_items(delete_ids)

# Copy if copy
if config['export_file_as']:
Expand Down
2 changes: 1 addition & 1 deletion todoist_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ def add_item(self, item_data, quick=False):
with open(os.path.join(appdir, 'config.yaml'), 'r') as f:
config = yaml.safe_load(f.read())
api = TodoistAPI(config['todoist_token'])
print(api.get_completed_tasks()['items'])
print(api.get_completed_tasks())

0 comments on commit d1b84cb

Please sign in to comment.