Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/releases/unreleased.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- Keep each task's ID in the property your collection's task type maps it to, such as `tasknote_id`, instead of always writing `id`. A plain `id` property is then left as your own data. Collections that use `id` are unchanged (tasknotes#2574, requested by @minchinweb).

- Show reminders as ready as soon as notification access is approved in mdbase, instead of still asking for approval until the page is reloaded.

- Keep a reminder's generated notification text in step with its time: changing "15 minutes before" to 2 minutes now reads "2 minutes before". Text you wrote yourself is never changed.
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ packages:

catalog:
"@mdbase-dev/sdk": 0.1.17
"@tasknotes/model": 0.3.0
"@tasknotes/model": 0.3.1
28 changes: 28 additions & 0 deletions src/domain/tasknotes-model.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it, vi } from "vitest";

import { buildCalendarEntries } from "@tasknotes/model/calendar";
import { DEFAULT_FIELD_MAPPING } from "@tasknotes/model/mapping";

import { calendarOccurrenceChoice } from "./calendar-edit";
import { TaskNotesTaskModel } from "./tasknotes-model";
Expand Down Expand Up @@ -1020,3 +1021,30 @@ function priority(value: string, label: string, weight: number) {
function canonicalLocal(value: string): string {
return new Date(value).toISOString().replace(".000Z", "Z");
}

// tasknotes#2574: a collection's type can store the stable ID under another
// property, freeing `id` for the user's own data.
describe("a remapped task ID", () => {
const model = new TaskNotesTaskModel({
fieldMapping: { ...DEFAULT_FIELD_MAPPING, id: "tasknote_id" },
});

it("writes, reads and keeps the ID under the mapped property", () => {
const created = model.create({ title: "Remapped" }, { id: "abc" });
expect(created.id).toBe("abc");
expect(created.frontmatter.tasknote_id).toBe("abc");
expect(created.frontmatter).not.toHaveProperty("id");

const task = model.read({
path: created.path,
frontmatter: { ...created.frontmatter, id: "mine" },
body: "",
});
expect(task.id).toBe("abc");

const updated = model.update(task, { title: "Renamed" });
expect(updated.frontmatter.tasknote_id).toBe("abc");
expect(updated.frontmatter.id).toBe("mine");
expect(model.summaryFields()).toContain("tasknote_id");
});
});
5 changes: 3 additions & 2 deletions src/domain/tasknotes-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { updateToNextScheduledOccurrence } from "@tasknotes/model/recurrence";
import {
mapTaskFromFrontmatter,
mapTaskToFrontmatter,
toUserField,
} from "@tasknotes/model/mapping";
import {
applyFrontmatterPatch,
Expand Down Expand Up @@ -202,7 +203,7 @@ export class TaskNotesTaskModel {
summaryFields(): string[] {
return [
...new Set([
"id",
toUserField(this.config.fieldMapping, "id"),
"mobileRevision",
"tags",
...Object.values(this.config.fieldMapping),
Expand Down Expand Up @@ -983,7 +984,7 @@ export class TaskNotesTaskModel {
)
? { [this.config.fieldMapping.skippedInstances]: [] }
: {}),
id,
[toUserField(this.config.fieldMapping, "id")]: id,
mobileRevision: revision,
};
}
Expand Down
Loading