Skip to content

Commit

Permalink
fix: handle empty task title
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschll committed Aug 27, 2024
1 parent 3eae724 commit 8ab2518
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logseq-ticktick-plugin",
"version": "1.1.0",
"version": "1.1.1",
"description": "TickTick plugin for Logseq.",
"main": "dist/index.html",
"scripts": {
Expand Down
11 changes: 8 additions & 3 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ const createTask: (task: NewTask, block: BlockEntity) => Promise<void> = async (
const newTask = await ticktick.createTask(task);
await logseq.Editor.updateBlock(
block.uuid,
`TODO ${priorityToTag(newTask.priority)}[${newTask.title}](${
newTask.taskUrl
`TODO ${priorityToTag(newTask.priority)}[${newTask.title}](${newTask.taskUrl
})`,
);
} catch (error) {
Expand Down Expand Up @@ -125,7 +124,6 @@ const main: () => Promise<void> = async () => {
}

const flatContentTree = flattenTree(contentTree);
console.log(flatContentTree);

const subtasks: Subtask[] = flatContentTree.slice(1).map((child) => {
const subtask: Subtask = {
Expand All @@ -137,6 +135,13 @@ const main: () => Promise<void> = async () => {
const task = parseTask(flatContentTree[0]?.content || '');
task.items = subtasks;

if (task.title.length == 0) {
await logseq.UI.showMsg('Task title cannot be empty.', 'warning', {
timeout: 3000,
});
return;
}

createTask(task, flatContentTree[0]);
});
};
Expand Down

0 comments on commit 8ab2518

Please sign in to comment.