Skip to content

Commit

Permalink
Fix #543 (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdarcy authored Oct 12, 2023
1 parent 53a2aaa commit 1d76230
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/__tests__/main/CreateRecurringTodo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,11 @@ describe('Create recurring todos', () => {
const fileContent = await fs.readFile('./src/__tests__/__mock__/recurrence.txt', 'utf8');
expect(fileContent.split('\n').pop()).toEqual(`${dateTodayString} Line 1 rec:+1d t:2023-09-20 due:${dateTomorrowString}`);
});


test('Should add a new todo and set the priority to the value of the pri extension', async () => {
const recurringTodo = await createRecurringTodo(`x ${dateTodayString} ${dateTodayString} Line 1 rec:1d pri:A`, '1d');
const fileContent = await fs.readFile('./src/__tests__/__mock__/recurrence.txt', 'utf8');
expect(fileContent.split('\n').pop()).toEqual(`(A) ${dateTodayString} Line 1 rec:1d due:${dateTomorrowString} pri:A`);
});

});
6 changes: 6 additions & 0 deletions src/main/modules/TodoObject/CreateRecurringTodo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ const createRecurringTodo = async (string: string, recurrence: string): Promise<
recurringTodoObject.setCreated(null);
}

const previousPriorityIndex = recurringTodoObject.extensions().findIndex((extension) => extension.key === 'pri');
const previousPriorityString = recurringTodoObject.extensions()[previousPriorityIndex]?.value;
if(previousPriorityString && previousPriorityString !== 'null') {
recurringTodoObject.setPriority(previousPriorityString)
}

if (recurrence && completedDate) {
const strictRecurrence: boolean = recurrence.startsWith('+');
const recurrenceInterval: any = strictRecurrence ? recurrence.slice(1) : recurrence;
Expand Down

0 comments on commit 1d76230

Please sign in to comment.