Skip to content

Commit 8ab2518

Browse files
committed
fix: handle empty task title
1 parent 3eae724 commit 8ab2518

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "logseq-ticktick-plugin",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "TickTick plugin for Logseq.",
55
"main": "dist/index.html",
66
"scripts": {

src/main.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ const createTask: (task: NewTask, block: BlockEntity) => Promise<void> = async (
7878
const newTask = await ticktick.createTask(task);
7979
await logseq.Editor.updateBlock(
8080
block.uuid,
81-
`TODO ${priorityToTag(newTask.priority)}[${newTask.title}](${
82-
newTask.taskUrl
81+
`TODO ${priorityToTag(newTask.priority)}[${newTask.title}](${newTask.taskUrl
8382
})`,
8483
);
8584
} catch (error) {
@@ -125,7 +124,6 @@ const main: () => Promise<void> = async () => {
125124
}
126125

127126
const flatContentTree = flattenTree(contentTree);
128-
console.log(flatContentTree);
129127

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

138+
if (task.title.length == 0) {
139+
await logseq.UI.showMsg('Task title cannot be empty.', 'warning', {
140+
timeout: 3000,
141+
});
142+
return;
143+
}
144+
140145
createTask(task, flatContentTree[0]);
141146
});
142147
};

0 commit comments

Comments
 (0)