Skip to content

Commit

Permalink
fix: refresh selected project on send and due:'' if no date set
Browse files Browse the repository at this point in the history
  • Loading branch information
hkgnp committed Sep 19, 2023
1 parent 61bf801 commit 6bf96f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/features/send/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ export const sendTask = async (
sendDeadline = parseBlkDeadline(blk.deadline);
} else if (deadline) {
sendDeadline = deadline;
} else {
} else if (sendDefaultDeadline) {
sendDeadline = "today";
} else {
sendDeadline = "";
}

// Send tasks
try {
await api.addTask({
content,
content: content.trim(),
dueString: sendDeadline,
...(projectId && { projectId: projectId }),
...(label && { labels: [label ?? sendDefaultLabel] }),
Expand Down
10 changes: 7 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { PluginSettings } from "./settings/types";
import { render } from "preact";
import { SendTask } from "./features/send/components/SendTask";
import { removeTaskFlags, sendTask } from "./features/send";
import { getAllProjects, getAllLabels } from "./features/helpers";
import {
getAllProjects,
getAllLabels,
getIdFromString,
} from "./features/helpers";

const main = async () => {
console.log("logseq-todoist-plugin loaded");
Expand Down Expand Up @@ -42,8 +46,8 @@ const main = async () => {
);

// SEND TASKS
const { sendDefaultProject } = logseq.settings! as Partial<PluginSettings>;
logseq.Editor.registerSlashCommand("Todoist: Send Task", async (e) => {
const { sendDefaultProject } = logseq.settings! as Partial<PluginSettings>;
const content: string = await logseq.Editor.getEditingBlockContent();
if (!content || content.length === 0) {
await logseq.UI.showMsg("Cannot send empty task", "error");
Expand All @@ -68,7 +72,7 @@ const main = async () => {
);
logseq.showMainUI();
} else {
await sendTask(e.uuid, content);
await sendTask(e.uuid, content, getIdFromString(sendDefaultProject));
}
});
};
Expand Down

0 comments on commit 6bf96f0

Please sign in to comment.