Skip to content

Commit

Permalink
Filter empty items
Browse files Browse the repository at this point in the history
  • Loading branch information
watkins-matt committed Aug 17, 2024
1 parent dbfd7fe commit 0565ef7
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions custom_components/google_keep_sync/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async def async_create_todo_item(self, item: TodoItem) -> None:

@property
def todo_items(self) -> list[TodoItem]:
"""Get the current set of To-do items."""
"""Get the current set of To-do items, filtering out empty entries."""
items = [
TodoItem(
summary=item.text,
Expand All @@ -148,10 +148,23 @@ def todo_items(self) -> list[TodoItem]:
),
)
for item in self._gkeep_list.items
if item.text
and len(item.text.strip())
> 0 # Filter out empty or whitespace-only entries
]
total_items = len(self._gkeep_list.items)
filtered_items = len(items)
_LOGGER.debug(
"Retrieved %d todo items for list: %s", len(items), self._gkeep_list_id
"Retrieved %d todo items for list: %s",
filtered_items,
self._gkeep_list_id,
)
if filtered_items < total_items:
_LOGGER.warning(
"Filtered out %d empty items from list: %s",
total_items - filtered_items,
self._gkeep_list_id,
)
return items


Expand Down

0 comments on commit 0565ef7

Please sign in to comment.