Skip to content

Commit

Permalink
fix: Enable clearing of ToDo description from HA ToDo panel
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerSelwyn committed Mar 25, 2024
1 parent 7df8aca commit 68660eb
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions custom_components/o365/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ async def async_update_todo_item(self, item: TodoItem) -> None:
self.todolist.get_task, item.uid
)
if (
(item.summary and item.summary != o365_task.subject)
or (item.description and item.description != o365_task.body)
item.summary != o365_task.subject
or item.description != o365_task.body
or (item.due and item.due != o365_task.due)
):
await self.async_update_todo(
Expand All @@ -314,6 +314,7 @@ async def async_update_todo_item(self, item: TodoItem) -> None:
description=item.description,
due=item.due,
o365_task=o365_task,
hatodo=True,
)
if item.status:
completed = None
Expand All @@ -332,6 +333,7 @@ async def async_update_todo(
due=None,
reminder=None,
o365_task=None,
hatodo=False,
):
"""Update a task for this task list."""
if not self._validate_task_permissions():
Expand All @@ -341,7 +343,9 @@ async def async_update_todo(
o365_task = await self.hass.async_add_executor_job(
self.todolist.get_task, todo_id
)
await self._async_save_task(o365_task, subject, description, due, reminder)
await self._async_save_task(
o365_task, subject, description, due, reminder, hatodo
)
self._raise_event(EVENT_UPDATE_TODO, todo_id)
await self.coordinator.async_refresh()
return True
Expand Down Expand Up @@ -402,11 +406,13 @@ async def _async_uncomplete_task(self, o365_task, todo_id):
self.hass.async_add_executor_job(o365_task.save)
self._raise_event(EVENT_UNCOMPLETED_TODO, todo_id)

async def _async_save_task(self, o365_task, subject, description, due, reminder):
async def _async_save_task(
self, o365_task, subject, description, due, reminder, hatodo=False
):
# sourcery skip: raise-from-previous-error
if subject:
if subject or hatodo:
o365_task.subject = subject
if description:
if description or hatodo:
o365_task.body = description

if due:
Expand Down

0 comments on commit 68660eb

Please sign in to comment.