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
19 changes: 15 additions & 4 deletions src/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,20 @@ export class List {
return this.data.note || "";
}

/** Date of last change */
public get lastModifiedAt(): Date {
return this.#companion.getRealTimestamp(this.data.lastModified);
/** Date of creation, or undefined if not available */
public get createdAt(): Date | undefined {
if (this.data.created !== undefined) {
return this.#companion.getRealTimestamp(this.data.created);
}
return undefined;
}

/** Date of last change, or undefined if not available */
public get lastModifiedAt(): Date | undefined {
if (this.data.lastModified !== undefined) {
return this.#companion.getRealTimestamp(this.data.lastModified);
}
return undefined;
}

/** Date of completion, or undefined if not completed */
Expand Down Expand Up @@ -413,7 +424,7 @@ export class List {

this.itemIds.splice(priority, 0, newId);

const parentid = this.id === "home" ? ROOT : this.id;
const parentid = this.id === ROOT ? "None" : this.id;

this.#companion.addOperation(this.data.treeId, {
type: "create",
Expand Down
3 changes: 3 additions & 0 deletions src/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export function toJson(list: List): any {
name: list.name,
note: list.note,
isCompleted: list.isCompleted,
createdAt: list.createdAt?.toISOString(),
lastModifiedAt: list.lastModifiedAt?.toISOString(),
completedAt: list.completedAt?.toISOString(),
items: list.items.map((sublist) => toJson(sublist)),
};
}
Expand Down
2 changes: 2 additions & 0 deletions src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const TreeDataSchema = z.object({
prnt: z.string().or(z.null()),
pr: z.number(),
cp: z.number().optional(),
ct: z.number().optional(),
lm: z.number(),
metadata: z.object({
mirror: z.object({
Expand All @@ -76,6 +77,7 @@ export const TreeDataSchema = z.object({
parentId: i.prnt !== null ? i.prnt : ROOT,
priority: i.pr,
completed: i.cp,
created: i.ct,
lastModified: i.lm,
originalId: i.metadata?.mirror?.originalId,
isMirrorRoot: i.metadata?.mirror?.isMirrorRoot === true,
Expand Down