From 35933127d808359e9f4ad56799416b9263458a20 Mon Sep 17 00:00:00 2001
From: Alexander Haselhoff <alexander.haselhoff@outlook.com>
Date: Tue, 12 May 2020 23:12:14 +0200
Subject: [PATCH] Applied fix to the sequential label logic

---
 autodoist.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/autodoist.py b/autodoist.py
index f538ca4..61aaa49 100644
--- a/autodoist.py
+++ b/autodoist.py
@@ -144,7 +144,6 @@ def main():
             logging.exception('Error trying to sync with Todoist API: %s' % str(e))
         else:
             for project in api.projects.all():
-                print(project.data['name'])
 
                 # Get project type
                 project_type, project_type_changed = get_project_type(project)
@@ -236,7 +235,7 @@ def main():
                         
                         # Add labels to top items if they have no childern
                         # if len(child_items) == 0:
-                        if len(child_items) >= 0:
+                        if len(child_items) == 0:
                             if item['parent_id'] == 0:
                                 if project_type == 'serial':
                                     if not first_found:
@@ -262,7 +261,8 @@ def main():
                             # Process serial tagged items
                             if item_type == 'serial':
                                 for child_item in child_items:
-                                    if child_item['checked'] == 0 and not child_first_found and label_id in item['labels']:
+                                    if child_item['checked'] == 0 and not child_first_found and not first_found:
+                                        first_found = True
                                         child_first_found = True
                                         add_label(child_item, label_id)
                                         child_item['parent_type'] = item_type