fix(calendar): wrong parent when creating day note from unhoisted workspace calendar root

This commit is contained in:
Elian Doran
2026-02-21 12:16:55 +02:00
parent ad3cdc3364
commit b8a6cf0099
3 changed files with 20 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
import { dayjs } from "@triliumnext/commons";
import type { FNoteRow } from "../entities/fnote.js";
import froca from "./froca.js";
import server from "./server.js";
@@ -14,8 +15,13 @@ async function getTodayNote() {
return await getDayNote(dayjs().format("YYYY-MM-DD"));
}
async function getDayNote(date: string) {
const note = await server.get<FNoteRow>(`special-notes/days/${date}`, "date-note");
async function getDayNote(date: string, calendarRootId?: string) {
let url = `special-notes/days/${date}`;
if (calendarRootId) {
url += `?calendarRootId=${calendarRootId}`;
}
const note = await server.get<FNoteRow>(url, "date-note");
await ws.waitForMaxKnownEntityChangeId();

View File

@@ -307,11 +307,11 @@ function useEditing(note: FNote, isEditable: boolean, isCalendarRoot: boolean, c
// Called upon when clicking the day number in the calendar, opens or creates the day note but only if in a calendar root.
const onDateClick = useCallback(async (e: DateClickArg) => {
const eventNote = await date_notes.getDayNote(e.dateStr);
const eventNote = await date_notes.getDayNote(e.dateStr, note.noteId);
if (eventNote) {
appContext.triggerCommand("openInPopup", { noteIdOrPath: eventNote.noteId });
}
}, []);
}, [ note ]);
return {
select: onCalendarSelection,

View File

@@ -1,16 +1,19 @@
import dateNoteService from "../../services/date_notes.js";
import sql from "../../services/sql.js";
import cls from "../../services/cls.js";
import specialNotesService, { type LauncherType } from "../../services/special_notes.js";
import becca from "../../becca/becca.js";
import type { Request } from "express";
import becca from "../../becca/becca.js";
import cls from "../../services/cls.js";
import dateNoteService from "../../services/date_notes.js";
import specialNotesService, { type LauncherType } from "../../services/special_notes.js";
import sql from "../../services/sql.js";
function getInboxNote(req: Request) {
return specialNotesService.getInboxNote(req.params.date);
}
function getDayNote(req: Request) {
return dateNoteService.getDayNote(req.params.date);
const calendarRootId = req.query.calendarRootId;
const calendarRoot = calendarRootId ? becca.getNoteOrThrow(String(calendarRootId)) : null;
return dateNoteService.getDayNote(req.params.date, calendarRoot);
}
function getWeekFirstDayNote(req: Request) {
@@ -59,9 +62,8 @@ function getDayNotesForMonth(req: Request) {
}
return result;
} else {
return sql.getMap(query);
}
return sql.getMap(query);
}
async function saveSqlConsole(req: Request) {