Skip to content

Commit

Permalink
Update tasks api call
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed May 8, 2024
1 parent 539248a commit eed7772
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/components/Item/ItemContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ function checkCheckbox(stateManager: StateManager, title: string, checkboxIndex:
return;
}

const match = line.match(/^(?:\s*>)*(\s*[-+*]\s+?\[)([^\]])(\]\s+)/);
const match = line.match(/^(\s*>)*(\s*[-+*]\s+?\[)([^\]])(\]\s+)/);

if (match) {
if (count === checkboxIndex) {
const updates = toggleItemString(line, stateManager.file);
if (updates) {
results.push(updates);
} else {
const check = match[2] === ' ' ? 'x' : ' ';
results.push(match[1] + check + match[3] + line.slice(match[0].length));
const check = match[3] === ' ' ? 'x' : ' ';
results.push(match[1] + match[2] + check + match[4] + line.slice(match[0].length));
}
} else {
results.push(line);
Expand Down
6 changes: 3 additions & 3 deletions src/parsers/helpers/inlineMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function getTasksPlugin() {
export function toggleItemString(item: string, file: TFile): string | null {
const plugin = getTasksPlugin();
if (!plugin) return null;
return plugin.apiV1?.toggleLine?.(item, file.path)?.text ?? null;
return plugin.apiV1?.executeToggleTaskDoneCommand?.(item, file.path) ?? null;
}

export function toggleItem(item: Item, file: TFile): [string[], number] | null {
Expand All @@ -192,10 +192,10 @@ export function toggleItem(item: Item, file: TFile): [string[], number] | null {
const originalLines = item.data.titleRaw.split(/\n\r?/g);

let which = -1;
const result = plugin.apiV1?.toggleLine?.(prefix + originalLines[0], file.path);
const result = plugin.apiV1?.executeToggleTaskDoneCommand?.(prefix + originalLines[0], file.path);
if (!result) return null;

const resultLines = result.text.split(/\n/g).map((line: string, index: number) => {
const resultLines = result.split(/\n/g).map((line: string, index: number) => {
if (item.data.isComplete && line.startsWith('- [ ]')) {
which = index;
} else if (!item.data.isComplete && line.startsWith('- [x]')) {
Expand Down

0 comments on commit eed7772

Please sign in to comment.